File: bug-buddy-integration.py

package info (click to toggle)
gnome-python 2.28.1%2Bdfsg-1.2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,312 kB
  • ctags: 1,032
  • sloc: sh: 10,219; ansic: 7,997; xml: 2,464; python: 1,886; makefile: 396
file content (26 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Some sample code demonstrating how to integrate python errors with GNOME bug-buddy.

Code from bug #346106 (Fernando Herrera)
"""
import sys

def bug_catcher(exctype, value, tb):
    import traceback
    import tempfile
    import os
    if exctype is not KeyboardInterrupt:
        msg = "".join(traceback.format_exception(exctype, value, tb))
        print >> sys.stderr, msg
        fd, name = tempfile.mkstemp()
        try:
            os.write(fd,msg)
            os.system("bug-buddy --include=\"%s\" --appname=\"%s\"" % (name, sys.argv[0]))
        finally:
            os.unlink(name)
    raise SystemExit


sys.excepthook = bug_catcher

raise ValueError