tAdd debug mode with ipython. - zs - Zeitungsschau rss to email converter
 (HTM) git clone git://r-36.net/zs
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 01445b45c7a7c31d732339989a71c957a633bad6
 (DIR) parent cc1e0defe58a83c1d59a31d72b7e8e7dec726883
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Sat, 10 Feb 2018 16:18:47 +0100
       
       Add debug mode with ipython.
       
       Diffstat:
         zs                                  |      13 +++++++++++++
       
       1 file changed, 13 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/zs b/zs
       t@@ -122,6 +122,16 @@ def run(db, selfeed=None, dryrun=False, onlychanges=False):
                                except smtplib.SMTPSenderRefused:
                                        return
        
       +class ExceptionHook:
       +        instance = None
       +
       +        def __call__(self, *args, **kwargs):
       +                if self.instance is None:
       +                        from IPython.core import ultratb
       +                        self.instance = ultratb.FormattedTB(mode='Verbose',
       +                                        color_scheme='Linux', call_pdb=1)
       +                return self.instance(*args, **kwargs)
       +
        def usage(app):
                app = os.path.basename(app)
                sys.stderr.write("usage: %s [-dhs] cmd\n" % (app))
       t@@ -151,6 +161,9 @@ def main(args):
                if len(largs) < 1:
                        usage(args[0])
        
       +        if dodebug == True:
       +                sys.excepthook = ExceptionHook()
       +
                if largs[0] == "testfeed":
                        if len(largs) < 2:
                                print("usage: %s testfeed URI\n" % \