[pitivi: 1/8] Add the -d command line option to start a post mortem pdb on uncaught exceptions.



commit c6bac37c5e87a2128c4baf7739a4892b0ff7fae1
Author: Alessandro Decina <alessandro d gmail com>
Date:   Fri Jul 31 18:05:48 2009 +0200

    Add the -d command line option to start a post mortem pdb on uncaught exceptions.

 pitivi/application.py |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 4a32090..98c0bea 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -224,6 +224,7 @@ class InteractivePitivi(Pitivi):
     import_help = _("""Import each MEDIA_FILE into the project.""")
 
     add_help = _("""Add each MEDIA_FILE to timeline after importing.""")
+    debug_help = _("""Run pitivi in the Python Debugger""")
 
     def run(self, argv):
         # check for dependencies
@@ -239,6 +240,9 @@ class InteractivePitivi(Pitivi):
         parser = self._createOptionParser()
         options, args = parser.parse_args(argv)
 
+        if options.debug:
+            sys.excepthook = self._excepthook
+
         # validate options
         if not options.import_sources and options.add_to_timeline:
             parser.error("-a requires -i")
@@ -279,6 +283,8 @@ class InteractivePitivi(Pitivi):
                 dest="import_sources", action="store_true", default=False)
         parser.add_option("-a", "--add-to-timeline", help=self.add_help,
                 action="store_true", default=False)
+        parser.add_option("-d", "--debug", help=self.debug_help,
+                action="store_true", default=False)
 
         return parser
 
@@ -323,6 +329,12 @@ class InteractivePitivi(Pitivi):
 
         return True
 
+    def _excepthook(self, exc_type, value, tback):
+        import traceback
+        import pdb
+        traceback.print_tb(tback)
+        pdb.post_mortem(tback)
+
 def main(argv):
     ptv = InteractivePitivi()
     ptv.run(sys.argv[1:])



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]