mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 18:56:28 +00:00
Windows: Fixed possible problems with file locks
OSX: Tweaked last fix
This commit is contained in:
@@ -84,10 +84,10 @@ class CBxArchive:
|
|||||||
for line in output.stdout:
|
for line in output.stdout:
|
||||||
if b"Everything is Ok" in line:
|
if b"Everything is Ok" in line:
|
||||||
extracted = True
|
extracted = True
|
||||||
if not extracted:
|
|
||||||
raise OSError
|
|
||||||
if sys.platform.startswith('darwin'):
|
if sys.platform.startswith('darwin'):
|
||||||
os.remove(self.origFileName)
|
os.remove(self.origFileName)
|
||||||
|
if not extracted:
|
||||||
|
raise OSError
|
||||||
|
|
||||||
def extract(self, targetdir):
|
def extract(self, targetdir):
|
||||||
if self.compressor == 'rar':
|
if self.compressor == 'rar':
|
||||||
|
|||||||
@@ -392,27 +392,36 @@ def fileImgProcess(work):
|
|||||||
print("Splitted " + afile)
|
print("Splitted " + afile)
|
||||||
img0 = image.ComicPage(split[0], opt.profileData)
|
img0 = image.ComicPage(split[0], opt.profileData)
|
||||||
applyImgOptimization(img0, opt)
|
applyImgOptimization(img0, opt)
|
||||||
img0.saveToDir(dirpath, opt.forcepng, opt.forcecolor, wipe)
|
img0.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
|
||||||
img1 = image.ComicPage(split[1], opt.profileData)
|
img1 = image.ComicPage(split[1], opt.profileData)
|
||||||
applyImgOptimization(img1, opt)
|
applyImgOptimization(img1, opt)
|
||||||
img1.saveToDir(dirpath, opt.forcepng, opt.forcecolor, wipe)
|
img1.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
|
||||||
|
if wipe:
|
||||||
|
os.remove(os.path.join(dirpath, img0.filename))
|
||||||
|
os.remove(os.path.join(dirpath, img1.filename))
|
||||||
if opt.quality == 2:
|
if opt.quality == 2:
|
||||||
img0b = image.ComicPage(split[0], opt.profileData, img0.fill)
|
img0b = image.ComicPage(split[0], opt.profileData, img0.fill)
|
||||||
applyImgOptimization(img0b, opt, img0)
|
applyImgOptimization(img0b, opt, img0)
|
||||||
img0b.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
|
img0b.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
|
||||||
img1b = image.ComicPage(split[1], opt.profileData, img1.fill)
|
img1b = image.ComicPage(split[1], opt.profileData, img1.fill)
|
||||||
applyImgOptimization(img1b, opt, img1)
|
applyImgOptimization(img1b, opt, img1)
|
||||||
img1b.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
|
img1b.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
|
||||||
|
os.remove(os.path.join(dirpath, img0b.filename))
|
||||||
|
os.remove(os.path.join(dirpath, img1b.filename))
|
||||||
|
os.remove(img.origFileName)
|
||||||
else:
|
else:
|
||||||
applyImgOptimization(img, opt)
|
applyImgOptimization(img, opt)
|
||||||
img.saveToDir(dirpath, opt.forcepng, opt.forcecolor, wipe)
|
img.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
|
||||||
|
if wipe:
|
||||||
|
os.remove(os.path.join(dirpath, img.filename))
|
||||||
if opt.quality == 2:
|
if opt.quality == 2:
|
||||||
img2 = image.ComicPage(os.path.join(dirpath, afile), opt.profileData, img.fill)
|
img2 = image.ComicPage(os.path.join(dirpath, afile), opt.profileData, img.fill)
|
||||||
if img.rotated:
|
if img.rotated:
|
||||||
img2.image = img2.image.rotate(90)
|
img2.image = img2.image.rotate(90)
|
||||||
img2.rotated = True
|
img2.rotated = True
|
||||||
applyImgOptimization(img2, opt, img)
|
applyImgOptimization(img2, opt, img)
|
||||||
img2.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
|
img2.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
|
||||||
|
os.remove(os.path.join(dirpath, img2.filename))
|
||||||
except Exception:
|
except Exception:
|
||||||
return str(sys.exc_info()[1])
|
return str(sys.exc_info()[1])
|
||||||
|
|
||||||
|
|||||||
@@ -117,15 +117,13 @@ class ComicPage:
|
|||||||
else:
|
else:
|
||||||
self.fill = None
|
self.fill = None
|
||||||
|
|
||||||
def saveToDir(self, targetdir, forcepng, color, wipe):
|
def saveToDir(self, targetdir, forcepng, color):
|
||||||
try:
|
try:
|
||||||
suffix = ""
|
suffix = ""
|
||||||
if not color and not forcepng:
|
if not color and not forcepng:
|
||||||
self.image = self.image.convert('L')
|
self.image = self.image.convert('L')
|
||||||
if self.rotated:
|
if self.rotated:
|
||||||
suffix += "-kccrot"
|
suffix += "-kccrot"
|
||||||
if wipe:
|
|
||||||
os.remove(os.path.join(targetdir, self.filename))
|
|
||||||
else:
|
else:
|
||||||
suffix += "-kcchq"
|
suffix += "-kcchq"
|
||||||
if self.noPV:
|
if self.noPV:
|
||||||
@@ -284,7 +282,6 @@ class ComicPage:
|
|||||||
pagetwo = self.image.crop(rightbox)
|
pagetwo = self.image.crop(rightbox)
|
||||||
pageone.save(fileone)
|
pageone.save(fileone)
|
||||||
pagetwo.save(filetwo)
|
pagetwo.save(filetwo)
|
||||||
os.remove(self.origFileName)
|
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
|
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
|
||||||
return fileone, filetwo
|
return fileone, filetwo
|
||||||
|
|||||||
Reference in New Issue
Block a user