Print exception tracebacks.
This commit is contained in:
parent
1314da3ffb
commit
01c2afc264
2 changed files with 17 additions and 6 deletions
10
dosage
10
dosage
|
@ -120,7 +120,7 @@ def saveComicStrip(strip, basepath):
|
||||||
if saved:
|
if saved:
|
||||||
allskipped = False
|
allskipped = False
|
||||||
except Exception as msg:
|
except Exception as msg:
|
||||||
out.error('Could not save image at %s to %s: %s' % (image.referrer, image.filename, msg))
|
out.exception('Could not save image at %s to %s: %s' % (image.referrer, image.filename, msg))
|
||||||
errors += 1
|
errors += 1
|
||||||
return errors, allskipped
|
return errors, allskipped
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ def displayHelp(comics):
|
||||||
for scraperobj in getScrapers(comics):
|
for scraperobj in getScrapers(comics):
|
||||||
displayComicHelp(scraperobj)
|
displayComicHelp(scraperobj)
|
||||||
except ValueError as msg:
|
except ValueError as msg:
|
||||||
out.error(msg)
|
out.exception(msg)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -155,14 +155,14 @@ def getComics(options):
|
||||||
"""Retrieve comics."""
|
"""Retrieve comics."""
|
||||||
errors = 0
|
errors = 0
|
||||||
if options.handler:
|
if options.handler:
|
||||||
for name in options.handler:
|
for name in set(options.handler):
|
||||||
events.addHandler(name, options.basepath, options.baseurl)
|
events.addHandler(name, options.basepath, options.baseurl)
|
||||||
events.getHandler().start()
|
events.getHandler().start()
|
||||||
try:
|
try:
|
||||||
for scraperobj in getScrapers(options.comic, options.basepath, options.adult, options.multimatch):
|
for scraperobj in getScrapers(options.comic, options.basepath, options.adult, options.multimatch):
|
||||||
errors += getStrips(scraperobj, options)
|
errors += getStrips(scraperobj, options)
|
||||||
except ValueError as msg:
|
except ValueError as msg:
|
||||||
out.error(msg)
|
out.exception(msg)
|
||||||
errors += 1
|
errors += 1
|
||||||
finally:
|
finally:
|
||||||
events.getHandler().end()
|
events.getHandler().end()
|
||||||
|
@ -189,7 +189,7 @@ def getStrips(scraperobj, options):
|
||||||
out.info("Stop retrieval because image file already exists")
|
out.info("Stop retrieval because image file already exists")
|
||||||
break
|
break
|
||||||
except Exception as msg:
|
except Exception as msg:
|
||||||
out.error(msg)
|
out.exception(msg)
|
||||||
errors += 1
|
errors += 1
|
||||||
finally:
|
finally:
|
||||||
out.context = ''
|
out.context = ''
|
||||||
|
|
|
@ -5,6 +5,7 @@ import time
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
import traceback
|
||||||
from .ansicolor import Colorizer
|
from .ansicolor import Colorizer
|
||||||
|
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
|
@ -35,9 +36,19 @@ class Output(object):
|
||||||
"""Write a warning message."""
|
"""Write a warning message."""
|
||||||
self.write("WARN: %s" % s, color='bold;yellow')
|
self.write("WARN: %s" % s, color='bold;yellow')
|
||||||
|
|
||||||
def error(self, s):
|
def error(self, s, tb=None):
|
||||||
"""Write an error message."""
|
"""Write an error message."""
|
||||||
self.write("ERROR: %s" % s, color='light;red')
|
self.write("ERROR: %s" % s, color='light;red')
|
||||||
|
#if tb is not None:
|
||||||
|
# self.write('Traceback (most recent call last):', 1)
|
||||||
|
|
||||||
|
def exception(self, s):
|
||||||
|
"""Write error message with traceback info."""
|
||||||
|
self.error(s)
|
||||||
|
type, value, tb = sys.exc_info()
|
||||||
|
self.writelines(traceback.format_stack(), 1)
|
||||||
|
self.writelines(traceback.format_tb(tb)[1:], 1)
|
||||||
|
self.writelines(traceback.format_exception_only(type, value), 1)
|
||||||
|
|
||||||
def write(self, s, level=0, color=None):
|
def write(self, s, level=0, color=None):
|
||||||
"""Write message with indentation, context and optional timestamp."""
|
"""Write message with indentation, context and optional timestamp."""
|
||||||
|
|
Loading…
Reference in a new issue