home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / python-gnome2 / examples / bug-buddy-integration.py
Encoding:
Python Source  |  2006-07-24  |  668 b   |  27 lines

  1. """
  2. Some sample code demonstrating how to integrate python errors with GNOME bug-buddy.
  3.  
  4. Code from bug #346106 (Fernando Herrera)
  5. """
  6. import sys
  7.  
  8. def bug_catcher(exctype, value, tb):
  9.     import traceback
  10.     import tempfile
  11.     import os
  12.     if exctype is not KeyboardInterrupt:
  13.         msg = "".join(traceback.format_exception(exctype, value, tb))
  14.         print >> sys.stderr, msg
  15.         fd, name = tempfile.mkstemp()
  16.         try:
  17.             os.write(fd,msg)
  18.             os.system("bug-buddy --include=\"%s\" --appname=\"%s\"" % (name, sys.argv[0]))
  19.         finally:
  20.             os.unlink(name)
  21.     raise SystemExit
  22.  
  23.  
  24. sys.excepthook = bug_catcher
  25.  
  26. raise ValueError
  27.