diff options
| author | Paweł Jastrzębski <[email protected]> | 2016-11-26 17:59:40 +0100 |
|---|---|---|
| committer | Paweł Jastrzębski <[email protected]> | 2016-11-26 17:59:40 +0100 |
| commit | 30b8770e34926f3d5ee6e55d36abbb1d5b1e354c (patch) | |
| tree | 23db694127cc34949f7c37bb333d58000664f88e | |
| parent | Decreased ferocity of margin cropping (diff) | |
| download | kcc-30b8770e34926f3d5ee6e55d36abbb1d5b1e354c.tar.gz kcc-30b8770e34926f3d5ee6e55d36abbb1d5b1e354c.tar.bz2 kcc-30b8770e34926f3d5ee6e55d36abbb1d5b1e354c.zip | |
Improved error reporting
| -rw-r--r-- | kcc/KCC_gui.py | 9 | ||||
| -rwxr-xr-x | kcc/comic2ebook.py | 8 | ||||
| -rw-r--r-- | kcc/comic2panel.py | 10 | ||||
| -rw-r--r-- | kcc/shared.py | 5 |
4 files changed, 20 insertions, 12 deletions
diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 4a5608a..b60c2be 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -317,10 +317,15 @@ class WorkerThread(QtCore.QThread): GUI.progress.content = '' self.errors = True _, _, traceback = sys.exc_info() + if len(err.args) == 1: + MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s" + % (jobargv[-1], str(err), sanitizeTrace(traceback)), 'error') + else: + MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s" + % (jobargv[-1], str(err.args[0]), err.args[1]), 'error') + GUI.sentry.extra_context({'realTraceback': err.args[1]}) if ' is corrupted.' not in str(err): GUI.sentry.captureException() - MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s" - % (jobargv[-1], str(err), sanitizeTrace(traceback)), 'error') MW.addMessage.emit('Error during conversion! Please consult ' '<a href="https://github.com/ciromattia/kcc/wiki/Error-messages">wiki</a> ' 'for more details.', 'error', False) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 3321e12..e16ea4f 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -46,7 +46,7 @@ try: from scandir import walk except ImportError: walk = os.walk -from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace, saferRemove +from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace, saferRemove, sanitizeTrace from . import comic2panel from . import image from . import cbxarchive @@ -482,7 +482,7 @@ def imgDirectoryProcessing(path): raise UserWarning("Conversion interrupted.") if len(workerOutput) > 0: rmtree(os.path.join(path, '..', '..'), True) - raise RuntimeError("One of workers crashed. Cause: " + workerOutput[0]) + raise RuntimeError("One of workers crashed. Cause: " + workerOutput[0][0], workerOutput[0][1]) for file in options.imgPurgeIndex: if os.path.isfile(file): saferRemove(file) @@ -492,7 +492,7 @@ def imgDirectoryProcessing(path): def imgFileProcessingTick(output): - if isinstance(output, str): + if isinstance(output, tuple): workerOutput.append(output) workerPool.terminate() else: @@ -526,7 +526,7 @@ def imgFileProcessing(work): output.append(img.saveToDir()) return output except Exception: - return str(sys.exc_info()[:2]) + return str(sys.exc_info()[1]), sanitizeTrace(sys.exc_info()[2]) def getWorkFolder(afile): diff --git a/kcc/comic2panel.py b/kcc/comic2panel.py index def8250..5e2b4f9 100644 --- a/kcc/comic2panel.py +++ b/kcc/comic2panel.py @@ -24,7 +24,7 @@ from shutil import rmtree, copytree, move from optparse import OptionParser, OptionGroup from multiprocessing import Pool from PIL import Image, ImageStat, ImageOps -from .shared import getImageFileName, walkLevel, walkSort, saferRemove +from .shared import getImageFileName, walkLevel, walkSort, saferRemove, sanitizeTrace try: from PyQt5 import QtCore except ImportError: @@ -81,7 +81,7 @@ def mergeDirectory(work): savePath = os.path.split(imagesValid[0]) result.save(os.path.join(savePath[0], os.path.splitext(savePath[1])[0] + '.png'), 'PNG') except Exception: - return str(sys.exc_info()[1]) + return str(sys.exc_info()[1]), sanitizeTrace(sys.exc_info()[2]) def sanitizePanelSize(panel, opt): @@ -205,7 +205,7 @@ def splitImage(work): pageNumber += 1 saferRemove(filePath) except Exception: - return str(sys.exc_info()[1]) + return str(sys.exc_info()[1]), sanitizeTrace(sys.exc_info()[2]) def main(argv=None, qtGUI=None): @@ -267,7 +267,7 @@ def main(argv=None, qtGUI=None): raise UserWarning("Conversion interrupted.") if len(mergeWorkerOutput) > 0: rmtree(options.targetDir, True) - raise RuntimeError("One of workers crashed. Cause: " + mergeWorkerOutput[0]) + raise RuntimeError("One of workers crashed. Cause: " + mergeWorkerOutput[0][0], mergeWorkerOutput[0][1]) print("Splitting images...") for root, dirs, files in walk(options.targetDir, False): for name in files: @@ -290,7 +290,7 @@ def main(argv=None, qtGUI=None): raise UserWarning("Conversion interrupted.") if len(splitWorkerOutput) > 0: rmtree(options.targetDir, True) - raise RuntimeError("One of workers crashed. Cause: " + splitWorkerOutput[0]) + raise RuntimeError("One of workers crashed. Cause: " + splitWorkerOutput[0][0], splitWorkerOutput[0][1]) if options.inPlace: rmtree(options.sourceDir) move(options.targetDir, options.sourceDir) diff --git a/kcc/shared.py b/kcc/shared.py index 88d1782..c228d30 100644 --- a/kcc/shared.py +++ b/kcc/shared.py @@ -144,7 +144,10 @@ def removeFromZIP(zipfname, *filenames): def sanitizeTrace(traceback): return ''.join(format_tb(traceback))\ - .replace('C:\\Users\\Pawel\\Documents\\Projekty\\KCC\\', '') \ + .replace('C:/Users/Pawel/Documents/Projekty/KCC/', '')\ + .replace('C:/Python35/', '')\ + .replace('c:/python35/', '')\ + .replace('C:\\Users\\Pawel\\Documents\\Projekty\\KCC\\', '')\ .replace('C:\\Python35\\', '')\ .replace('c:\\python35\\', '') |