home *** CD-ROM | disk | FTP | other *** search
Wrap
# Source Generated with Decompyle++ # File: in.pyc (Python 2.6) import os import sys from pprint import pprint, pformat from IPython import Release from IPython import ultraTB from IPython.ColorANSI import ColorScheme, ColorSchemeTable from IPython.Itpl import Itpl, itpl, printpl from IPython.genutils import * class CrashHandler: def __init__(self, IP, app_name, contact_name, contact_email, bug_tracker, crash_report_fname, show_crash_traceback = True): self.IP = IP self.app_name = app_name self.contact_name = contact_name self.contact_email = contact_email self.bug_tracker = bug_tracker self.crash_report_fname = crash_report_fname self.show_crash_traceback = show_crash_traceback self.user_message_template = "\nOops, $self.app_name crashed. We do our best to make it stable, but...\n\nA crash report was automatically generated with the following information:\n - A verbatim copy of the crash traceback.\n - A copy of your input history during this session.\n - Data on your current $self.app_name configuration.\n\nIt was left in the file named:\n\t'$self.crash_report_fname'\nIf you can email this file to the developers, the information in it will help\nthem in understanding and correcting the problem.\n\nYou can mail it to: $self.contact_name at $self.contact_email\nwith the subject '$self.app_name Crash Report'.\n\nIf you want to do it now, the following command will work (under Unix):\nmail -s '$self.app_name Crash Report' $self.contact_email < $self.crash_report_fname\n\nTo ensure accurate tracking of this issue, please file a report about it at:\n$self.bug_tracker\n" def __call__(self, etype, evalue, etb): color_scheme = 'NoColor' try: rptdir = self.IP.rc.ipythondir except: rptdir = os.getcwd() if not os.path.isdir(rptdir): rptdir = os.getcwd() report_name = os.path.join(rptdir, self.crash_report_fname) self.crash_report_fname = report_name TBhandler = ultraTB.VerboseTB(color_scheme = color_scheme, long_header = 1) traceback = TBhandler.text(etype, evalue, etb, context = 31) if self.show_crash_traceback: print >>sys.stderr, traceback try: report = open(report_name, 'w') except: print >>sys.stderr, 'Could not create crash report on disk.' return None msg = itpl('\n' + '*' * 70 + '\n' + self.user_message_template) print >>sys.stderr, msg report.write(self.make_report(traceback)) report.close() raw_input('Press enter to exit:') def make_report(self, traceback): sec_sep = '\n\n' + '*' * 75 + '\n\n' report = [] rpt_add = report.append rpt_add('*' * 75 + '\n\n' + 'IPython post-mortem report\n\n') rpt_add('IPython version: %s \n\n' % Release.version) rpt_add('BZR revision : %s \n\n' % Release.revision) rpt_add('Platform info : os.name -> %s, sys.platform -> %s' % (os.name, sys.platform)) rpt_add(sec_sep + 'Current user configuration structure:\n\n') rpt_add(pformat(self.IP.rc.dict())) rpt_add(sec_sep + 'Crash traceback:\n\n' + traceback) try: rpt_add(sec_sep + 'History of session input:') for line in self.IP.user_ns['_ih']: rpt_add(line) rpt_add('\n*** Last line of input (may not be in above history):\n') rpt_add(self.IP._last_input_line + '\n') except: pass return ''.join(report) class IPythonCrashHandler(CrashHandler): def __init__(self, IP): AUTHOR_CONTACT = 'Fernando' app_name = 'IPython' bug_tracker = 'https://bugs.launchpad.net/ipython/+filebug' (contact_name, contact_email) = Release.authors[AUTHOR_CONTACT][:2] crash_report_fname = 'IPython_crash_report.txt' CrashHandler.__init__(self, IP, app_name, contact_name, contact_email, bug_tracker, crash_report_fname) def make_report(self, traceback): sec_sep = '\n\n' + '*' * 75 + '\n\n' report = [] rpt_add = report.append rpt_add('*' * 75 + '\n\n' + 'IPython post-mortem report\n\n') rpt_add('IPython version: %s \n\n' % Release.version) rpt_add('BZR revision : %s \n\n' % Release.revision) rpt_add('Platform info : os.name -> %s, sys.platform -> %s' % (os.name, sys.platform)) rpt_add(sec_sep + 'Current user configuration structure:\n\n') rpt_add(pformat(self.IP.rc.dict())) rpt_add(sec_sep + 'Crash traceback:\n\n' + traceback) try: rpt_add(sec_sep + 'History of session input:') for line in self.IP.user_ns['_ih']: rpt_add(line) rpt_add('\n*** Last line of input (may not be in above history):\n') rpt_add(self.IP._last_input_line + '\n') except: pass return ''.join(report)