From 38afbf7392ec4110aa4dec4b3ad304f041d767c7 2010-01-17 22:15:31 From: Fernando Perez Date: 2010-01-17 22:15:31 Subject: [PATCH] Moved system info into its own utility, so we can use in in test suite too. --- diff --git a/IPython/core/crashhandler.py b/IPython/core/crashhandler.py index 46a6594..f5c80b8 100644 --- a/IPython/core/crashhandler.py +++ b/IPython/core/crashhandler.py @@ -26,9 +26,12 @@ from pprint import pformat # Our own from IPython.core import release from IPython.core import ultratb +from IPython.utils.genutils import sys_info + from IPython.external.Itpl import itpl #**************************************************************************** + class CrashHandler(object): """Customizable crash handlers for IPython-based systems. @@ -166,21 +169,13 @@ $self.bug_tracker def make_report(self,traceback): """Return a string containing a crash report.""" - import platform sec_sep = self.section_sep - report = [] + report = ['*'*75+'\n\n'+'IPython post-mortem report\n\n'] rpt_add = report.append + rpt_add(sys_info()) - rpt_add('*'*75+'\n\n'+'IPython post-mortem report\n\n') - rpt_add('IPython version: %s \n' % release.version) - rpt_add('BZR revision : %s \n' % release.revision) - rpt_add('Platform info : os.name -> %s, sys.platform -> %s\n' % - (os.name,sys.platform) ) - rpt_add(' : %s\n' % platform.platform()) - rpt_add('Python info : %s\n' % sys.version) - try: config = pformat(self.app.config) rpt_add(sec_sep+'Current user configuration structure:\n\n') diff --git a/IPython/utils/genutils.py b/IPython/utils/genutils.py index 1757204..4b07306 100644 --- a/IPython/utils/genutils.py +++ b/IPython/utils/genutils.py @@ -42,6 +42,7 @@ else: # Other IPython utilities import IPython +from IPython.core import release from IPython.external.Itpl import itpl,printpl from IPython.utils import platutils from IPython.utils.generics import result_display @@ -213,6 +214,31 @@ def fatal(msg,exit_val=1): warn(msg,exit_val=exit_val,level=4) +def sys_info(): + """Return useful information about IPython and the system, as a string. + + Examples + -------- + In [1]: print(sys_info()) + IPython version: 0.11.bzr.r1340 # random + BZR revision : 1340 + Platform info : os.name -> posix, sys.platform -> linux2 + : Linux-2.6.31-17-generic-i686-with-Ubuntu-9.10-karmic + Python info : 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) + [GCC 4.4.1] + """ + import platform + out = [] + out.append('IPython version: %s' % release.version) + out.append('BZR revision : %s' % release.revision) + out.append('Platform info : os.name -> %s, sys.platform -> %s' % + (os.name,sys.platform) ) + out.append(' : %s' % platform.platform()) + out.append('Python info : %s' % sys.version) + out.append('') # ensure closing newline + return '\n'.join(out) + + #--------------------------------------------------------------------------- # Debugging routines #