Windows: Miscellaneous tweaks

This commit is contained in:
Paweł Jastrzębski
2015-10-13 19:08:55 +02:00
parent a2651747cd
commit 3bedc3b928
2 changed files with 16 additions and 8 deletions
+3 -3
View File
@@ -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
View File
@@ -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)