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