mirror of
https://github.com/ciromattia/kcc
synced 2026-01-03 03:49:36 +00:00
Windows: Miscellaneous tweaks
This commit is contained in:
@@ -991,11 +991,11 @@ def detectCorruption(tmpPath, orgPath):
|
||||
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
|
||||
else:
|
||||
saferRemove(os.path.join(root, name))
|
||||
if imageSmaller > imageNumber * 0.5 and not options.upscale and not options.stretch:
|
||||
print("\nMore than half of images are smaller than target device resolution. "
|
||||
if imageSmaller > imageNumber * 0.25 and not options.upscale and not options.stretch:
|
||||
print("\nMore than 25% of images are smaller than target device resolution. "
|
||||
"Consider enabling stretching or upscaling to improve readability.")
|
||||
if GUI:
|
||||
GUI.addMessage.emit('More than half of images are smaller than target device resolution.', 'warning', False)
|
||||
GUI.addMessage.emit('More than 25% of images are smaller than target device resolution.', 'warning', False)
|
||||
GUI.addMessage.emit('Consider enabling stretching or upscaling to improve readability.', 'warning', False)
|
||||
GUI.addMessage.emit('', '', False)
|
||||
|
||||
|
||||
@@ -97,11 +97,11 @@ def check7ZFile(filePath):
|
||||
|
||||
|
||||
def saferReplace(old, new):
|
||||
for x in range(5):
|
||||
for x in range(50):
|
||||
try:
|
||||
os.replace(old, new)
|
||||
except PermissionError:
|
||||
sleep(5)
|
||||
sleep(0.1)
|
||||
else:
|
||||
break
|
||||
else:
|
||||
@@ -109,11 +109,11 @@ def saferReplace(old, new):
|
||||
|
||||
|
||||
def saferRemove(target):
|
||||
for x in range(5):
|
||||
for x in range(50):
|
||||
try:
|
||||
os.remove(target)
|
||||
except PermissionError:
|
||||
sleep(5)
|
||||
sleep(0.1)
|
||||
else:
|
||||
break
|
||||
else:
|
||||
@@ -129,7 +129,15 @@ def removeFromZIP(zipfname, *filenames):
|
||||
for item in zipread.infolist():
|
||||
if item.filename not in filenames:
|
||||
zipwrite.writestr(item, zipread.read(item.filename))
|
||||
copy(tempname, zipfname)
|
||||
for x in range(50):
|
||||
try:
|
||||
copy(tempname, zipfname)
|
||||
except PermissionError:
|
||||
sleep(0.1)
|
||||
else:
|
||||
break
|
||||
else:
|
||||
raise PermissionError
|
||||
finally:
|
||||
rmtree(tempdir, True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user