minor fixes

This commit is contained in:
Maximilian Hils 2016-07-27 19:38:36 -07:00
parent 3636ed7d41
commit 83102b853f
2 changed files with 4 additions and 3 deletions

View File

@ -61,13 +61,13 @@ def scriptenv(path, args):
try: try:
yield yield
except Exception: except Exception:
_, _, tb = sys.exc_info() etype, value, tb = sys.exc_info()
scriptdir = os.path.dirname(os.path.abspath(path)) scriptdir = os.path.dirname(os.path.abspath(path))
for i, s in enumerate(reversed(traceback.extract_tb(tb))): for i, s in enumerate(reversed(traceback.extract_tb(tb))):
tb = tb.tb_next tb = tb.tb_next
if not os.path.abspath(s[0]).startswith(scriptdir): if not os.path.abspath(s[0]).startswith(scriptdir):
break break
ctx.log.error("Script error: %s" % "".join(traceback.format_tb(tb))) ctx.log.error("Script error: %s" % "".join(traceback.format_exception(etype, value, tb)))
finally: finally:
sys.argv = oldargs sys.argv = oldargs
sys.path.pop() sys.path.pop()

View File

@ -92,6 +92,7 @@ def mitmdump(args=None): # pragma: no cover
if args.quiet: if args.quiet:
args.flow_detail = 0 args.flow_detail = 0
master = None
try: try:
dump_options = dump.Options(**cmdline.get_common_options(args)) dump_options = dump.Options(**cmdline.get_common_options(args))
dump_options.flow_detail = args.flow_detail dump_options.flow_detail = args.flow_detail
@ -110,7 +111,7 @@ def mitmdump(args=None): # pragma: no cover
sys.exit(1) sys.exit(1)
except (KeyboardInterrupt, _thread.error): except (KeyboardInterrupt, _thread.error):
pass pass
if master.has_errored: if master is None or master.has_errored:
print("mitmdump: errors occurred during run", file=sys.stderr) print("mitmdump: errors occurred during run", file=sys.stderr)
sys.exit(1) sys.exit(1)