From 5d3db722a4846991c24b6b5f0211cfa2f0cfeaca Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Wed, 2 Jan 2019 17:42:57 -0600 Subject: [PATCH] Run in debug mode Add and load debug module that will throw DataExplore into the debugger on exceptions. --- main.py | 1 + pandastable/debug.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) mode change 100644 => 100755 main.py create mode 100644 pandastable/debug.py diff --git a/main.py b/main.py old mode 100644 new mode 100755 index d83e8d2..be6a7ee --- a/main.py +++ b/main.py @@ -20,6 +20,7 @@ """ from pandastable.app import DataExplore, TestApp +from pandastable import debug def main(): """Run the application from outside the module - used for diff --git a/pandastable/debug.py b/pandastable/debug.py new file mode 100644 index 0000000..d25281e --- /dev/null +++ b/pandastable/debug.py @@ -0,0 +1,21 @@ +# When loaded, this python module will automagically start up the +# debugger in response to exceptions. Many thanks to tzot on +# StackExchange: https://stackoverflow.com/a/242531/289934 + +import sys + +def info(type, value, tb): + if hasattr(sys, 'ps1') or not sys.stderr.isatty(): + # we are in interactive mode or we don't have a tty-like + # device, so we call the default hook + sys.__excepthook__(type, value, tb) + else: + import traceback, pdb + # we are NOT in interactive mode, print the exception... + traceback.print_exception(type, value, tb) + print + # ...then start the debugger in post-mortem mode. + # pdb.pm() # deprecated + pdb.post_mortem(tb) # more "modern" + +sys.excepthook = info