mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 10:46:40 +00:00
Fix for fix for access denied errors
This commit is contained in:
@@ -332,7 +332,7 @@ def dirImgProcess(path):
|
|||||||
pass
|
pass
|
||||||
if not GUI.conversionAlive:
|
if not GUI.conversionAlive:
|
||||||
pool.terminate()
|
pool.terminate()
|
||||||
rmtree(os.path.join(path, '..', '..'), onerror=fixReadOnly)
|
rmtree(os.path.join(path, '..', '..'), True)
|
||||||
raise UserWarning("Conversion interrupted.")
|
raise UserWarning("Conversion interrupted.")
|
||||||
GUI.emit(QtCore.SIGNAL("progressBarTick"))
|
GUI.emit(QtCore.SIGNAL("progressBarTick"))
|
||||||
pool.join()
|
pool.join()
|
||||||
@@ -340,7 +340,7 @@ def dirImgProcess(path):
|
|||||||
try:
|
try:
|
||||||
splitpages = splitpages.get()
|
splitpages = splitpages.get()
|
||||||
except:
|
except:
|
||||||
rmtree(os.path.join(path, '..', '..'), onerror=fixReadOnly)
|
rmtree(os.path.join(path, '..', '..'), True)
|
||||||
raise RuntimeError("One of workers crashed. Cause: " + str(sys.exc_info()[1]))
|
raise RuntimeError("One of workers crashed. Cause: " + str(sys.exc_info()[1]))
|
||||||
splitpages = filter(None, splitpages)
|
splitpages = filter(None, splitpages)
|
||||||
splitpages.sort()
|
splitpages.sort()
|
||||||
@@ -349,7 +349,7 @@ def dirImgProcess(path):
|
|||||||
pagenumbermodifier += 1
|
pagenumbermodifier += 1
|
||||||
pagenumbermodifier += 1
|
pagenumbermodifier += 1
|
||||||
else:
|
else:
|
||||||
rmtree(os.path.join(path, '..', '..'), onerror=fixReadOnly)
|
rmtree(os.path.join(path, '..', '..'), True)
|
||||||
raise UserWarning("Source directory is empty.")
|
raise UserWarning("Source directory is empty.")
|
||||||
|
|
||||||
|
|
||||||
@@ -557,13 +557,13 @@ def getWorkFolder(afile):
|
|||||||
sanitizeTreeBeforeConversion(fullPath)
|
sanitizeTreeBeforeConversion(fullPath)
|
||||||
return workdir
|
return workdir
|
||||||
except OSError:
|
except OSError:
|
||||||
rmtree(workdir, onerror=fixReadOnly)
|
rmtree(workdir, True)
|
||||||
raise
|
raise
|
||||||
elif afile.lower().endswith('.pdf'):
|
elif afile.lower().endswith('.pdf'):
|
||||||
pdf = pdfjpgextract.PdfJpgExtract(afile)
|
pdf = pdfjpgextract.PdfJpgExtract(afile)
|
||||||
path, njpg = pdf.extract()
|
path, njpg = pdf.extract()
|
||||||
if njpg == 0:
|
if njpg == 0:
|
||||||
rmtree(path, onerror=fixReadOnly)
|
rmtree(path, True)
|
||||||
raise UserWarning("Failed to extract images.")
|
raise UserWarning("Failed to extract images.")
|
||||||
else:
|
else:
|
||||||
workdir = tempfile.mkdtemp('', 'KCC-TMP-')
|
workdir = tempfile.mkdtemp('', 'KCC-TMP-')
|
||||||
@@ -573,11 +573,11 @@ def getWorkFolder(afile):
|
|||||||
try:
|
try:
|
||||||
path = cbx.extract(workdir)
|
path = cbx.extract(workdir)
|
||||||
except OSError:
|
except OSError:
|
||||||
rmtree(workdir, onerror=fixReadOnly)
|
rmtree(workdir, True)
|
||||||
print 'UnRAR/7za not found or file failed to extract!'
|
print 'UnRAR/7za not found or file failed to extract!'
|
||||||
sys.exit(21)
|
sys.exit(21)
|
||||||
else:
|
else:
|
||||||
rmtree(workdir, onerror=fixReadOnly)
|
rmtree(workdir, True)
|
||||||
raise TypeError
|
raise TypeError
|
||||||
move(path, path + "_temp")
|
move(path, path + "_temp")
|
||||||
move(path + "_temp", os.path.join(path, 'OEBPS', 'Images'))
|
move(path + "_temp", os.path.join(path, 'OEBPS', 'Images'))
|
||||||
@@ -908,7 +908,7 @@ def main(argv=None, qtGUI=None):
|
|||||||
filepath.append(getOutputFilename(args[0], options.output, '.epub', ''))
|
filepath.append(getOutputFilename(args[0], options.output, '.epub', ''))
|
||||||
make_archive(tome + '_comic', 'zip', tome)
|
make_archive(tome + '_comic', 'zip', tome)
|
||||||
move(tome + '_comic.zip', filepath[-1])
|
move(tome + '_comic.zip', filepath[-1])
|
||||||
rmtree(tome, onerror=fixReadOnly)
|
rmtree(tome, True)
|
||||||
return filepath
|
return filepath
|
||||||
|
|
||||||
|
|
||||||
@@ -981,14 +981,6 @@ def checkOptions():
|
|||||||
options.profileData = image.ProfileData.Profiles[options.profile]
|
options.profileData = image.ProfileData.Profiles[options.profile]
|
||||||
|
|
||||||
|
|
||||||
#noinspection PyUnusedLocal
|
|
||||||
def fixReadOnly(func, path, exc_info):
|
|
||||||
if not os.access(path, os.W_OK):
|
|
||||||
os.chmod(path, stat.S_IWUSR)
|
|
||||||
func(path)
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
freeze_support()
|
freeze_support()
|
||||||
Copyright()
|
Copyright()
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import stat
|
|
||||||
from shutil import rmtree, copytree, move
|
from shutil import rmtree, copytree, move
|
||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
from multiprocessing import Pool, Queue, freeze_support
|
from multiprocessing import Pool, Queue, freeze_support
|
||||||
@@ -258,15 +257,15 @@ def main(argv=None, qtGUI=None):
|
|||||||
try:
|
try:
|
||||||
workers.get()
|
workers.get()
|
||||||
except:
|
except:
|
||||||
rmtree(options.targetDir, onerror=fixReadOnly)
|
rmtree(options.targetDir, True)
|
||||||
raise RuntimeError("One of workers crashed. Cause: " + str(sys.exc_info()[1]))
|
raise RuntimeError("One of workers crashed. Cause: " + str(sys.exc_info()[1]))
|
||||||
if GUI:
|
if GUI:
|
||||||
GUI.emit(QtCore.SIGNAL("progressBarTick"), 1)
|
GUI.emit(QtCore.SIGNAL("progressBarTick"), 1)
|
||||||
if options.inPlace:
|
if options.inPlace:
|
||||||
rmtree(options.sourceDir, onerror=fixReadOnly)
|
rmtree(options.sourceDir, True)
|
||||||
move(options.targetDir, options.sourceDir)
|
move(options.targetDir, options.sourceDir)
|
||||||
else:
|
else:
|
||||||
rmtree(options.targetDir, onerror=fixReadOnly)
|
rmtree(options.targetDir, True)
|
||||||
raise UserWarning("Source directory is empty.")
|
raise UserWarning("Source directory is empty.")
|
||||||
else:
|
else:
|
||||||
raise UserWarning("Provided path is not a directory.")
|
raise UserWarning("Provided path is not a directory.")
|
||||||
@@ -274,14 +273,6 @@ def main(argv=None, qtGUI=None):
|
|||||||
raise UserWarning("Target height is not set.")
|
raise UserWarning("Target height is not set.")
|
||||||
|
|
||||||
|
|
||||||
#noinspection PyUnusedLocal
|
|
||||||
def fixReadOnly(func, path, exc_info):
|
|
||||||
if not os.access(path, os.W_OK):
|
|
||||||
os.chmod(path, stat.S_IWUSR)
|
|
||||||
func(path)
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
freeze_support()
|
freeze_support()
|
||||||
Copyright()
|
Copyright()
|
||||||
|
|||||||
Reference in New Issue
Block a user