mirror of
https://github.com/ciromattia/kcc
synced 2026-09-22 02:37:09 +00:00
Windows: Miscellenaus tweaks
This commit is contained in:
+3
-3
@@ -46,7 +46,7 @@ try:
|
|||||||
from scandir import walk
|
from scandir import walk
|
||||||
except ImportError:
|
except ImportError:
|
||||||
walk = os.walk
|
walk = os.walk
|
||||||
from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace
|
from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace, saferRemove
|
||||||
from . import comic2panel
|
from . import comic2panel
|
||||||
from . import image
|
from . import image
|
||||||
from . import cbxarchive
|
from . import cbxarchive
|
||||||
@@ -584,7 +584,7 @@ def imgDirectoryProcessing(path):
|
|||||||
raise RuntimeError("One of workers crashed. Cause: " + workerOutput[0])
|
raise RuntimeError("One of workers crashed. Cause: " + workerOutput[0])
|
||||||
for file in options.imgPurgeIndex:
|
for file in options.imgPurgeIndex:
|
||||||
if os.path.isfile(file):
|
if os.path.isfile(file):
|
||||||
os.remove(file)
|
saferRemove(file)
|
||||||
else:
|
else:
|
||||||
rmtree(os.path.join(path, '..', '..'), True)
|
rmtree(os.path.join(path, '..', '..'), True)
|
||||||
raise UserWarning("Source directory is empty.")
|
raise UserWarning("Source directory is empty.")
|
||||||
@@ -990,7 +990,7 @@ def detectCorruption(tmpPath, orgPath):
|
|||||||
else:
|
else:
|
||||||
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
|
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
|
||||||
else:
|
else:
|
||||||
os.remove(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.5 and not options.upscale and not options.stretch:
|
||||||
print("\nMore than half of images are smaller than target device resolution. "
|
print("\nMore than half of images are smaller than target device resolution. "
|
||||||
"Consider enabling stretching or upscaling to improve readability.")
|
"Consider enabling stretching or upscaling to improve readability.")
|
||||||
|
|||||||
+13
-1
@@ -22,7 +22,7 @@ from hashlib import md5
|
|||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from shutil import rmtree, move, copy
|
from shutil import rmtree, copy
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from zipfile import ZipFile, ZIP_DEFLATED
|
from zipfile import ZipFile, ZIP_DEFLATED
|
||||||
from re import split
|
from re import split
|
||||||
@@ -108,6 +108,18 @@ def saferReplace(old, new):
|
|||||||
raise PermissionError
|
raise PermissionError
|
||||||
|
|
||||||
|
|
||||||
|
def saferRemove(target):
|
||||||
|
for x in range(5):
|
||||||
|
try:
|
||||||
|
os.remove(target)
|
||||||
|
except PermissionError:
|
||||||
|
sleep(5)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise PermissionError
|
||||||
|
|
||||||
|
|
||||||
def removeFromZIP(zipfname, *filenames):
|
def removeFromZIP(zipfname, *filenames):
|
||||||
tempdir = mkdtemp('', 'KCC-')
|
tempdir = mkdtemp('', 'KCC-')
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user