about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaweł Jastrzębski <[email protected]>2015-10-13 18:45:25 +0200
committerPaweł Jastrzębski <[email protected]>2015-10-13 19:08:55 +0200
commit3bedc3b928b525c7009b62d7a2bcc373abf74422 (patch)
tree856dd5db3d7542410e805bb7a119cc6a702ebcca
parentBuild tweaks (diff)
downloadkcc-3bedc3b928b525c7009b62d7a2bcc373abf74422.tar.gz
kcc-3bedc3b928b525c7009b62d7a2bcc373abf74422.tar.bz2
kcc-3bedc3b928b525c7009b62d7a2bcc373abf74422.zip
Windows: Miscellaneous tweaks
-rwxr-xr-xkcc/comic2ebook.py6
-rw-r--r--kcc/shared.py18
2 files changed, 16 insertions, 8 deletions
diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py
index 20ba55f..27b6753 100755
--- a/kcc/comic2ebook.py
+++ b/kcc/comic2ebook.py
@@ -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)
 
diff --git a/kcc/shared.py b/kcc/shared.py
index c6de633..b363998 100644
--- a/kcc/shared.py
+++ b/kcc/shared.py
@@ -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)