Ñò
ÎÑAHc           @   sà   d  Z  d d k l Z d e i d Z e i Z e i Z d d k	 Z	 d d k
 Z
 d d k l Z l Z d d k l Z l Z l Z d d k l Z l Z d d	 k l Z d d
 k Td d d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s   sys.excepthook for IPython itself, leaves a detailed report on disk.

$Id: CrashHandler.py 2908 2007-12-30 21:07:46Z vivainio $iÿÿÿÿ(   t   Releases   %s <%s>t   FernandoN(   t   pprintt   pformat(   t   Itplt   itplt   printpl(   t   ColorSchemet   ColorSchemeTable(   t   ultraTB(   t   *t   CrashHandlerc           B   s,   e  Z d  Z e d „ Z d „  Z d „  Z RS(   sî   Customizable crash handlers for IPython-based systems.

    Instances of this class provide a __call__ method which can be used as a
    sys.excepthook, i.e., the __call__ signature is:

        def __call__(self,etype, evalue, etb)

    c         C   sL   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d |  _ d S(   s/  New crash handler.

        Inputs:

        - IP: a running IPython instance, which will be queried at crash time
        for internal information.

        - app_name: a string containing the name of your application.

        - contact_name: a string with the name of the person to contact.

        - contact_email: a string with the email address of the contact.

        - bug_tracker: a string with the URL for your project's bug tracker.

        - crash_report_fname: a string with the filename for the crash report
        to be saved in.  These reports are left in the ipython user directory
        as determined by the running IPython instance.

        Optional inputs:
        
        - show_crash_traceback(True): if false, don't print the crash
        traceback on stderr, only generate the on-disk report


        Non-argument instance attributes:

        These instances contain some non-argument attributes which allow for 
        further customization of the crash handler's behavior.  Please see the
        source for further details.
        sV  
Oops, $self.app_name crashed. We do our best to make it stable, but...

A crash report was automatically generated with the following information:
  - A verbatim copy of the crash traceback.
  - A copy of your input history during this session.
  - Data on your current $self.app_name configuration.

It was left in the file named:
	'$self.crash_report_fname'
If you can email this file to the developers, the information in it will help
them in understanding and correcting the problem.

You can mail it to: $self.contact_name at $self.contact_email
with the subject '$self.app_name Crash Report'.

If you want to do it now, the following command will work (under Unix):
mail -s '$self.app_name Crash Report' $self.contact_email < $self.crash_report_fname

To ensure accurate tracking of this issue, please file a report about it at:
$self.bug_tracker
N(   t   IPt   app_namet   contact_namet   contact_emailt   bug_trackert   crash_report_fnamet   show_crash_tracebackt   user_message_template(   t   selfR   R   R   R   R   R   R   (    (    sL   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/CrashHandler.pyt   __init__+   s    $							c      
   C   sF  d } y |  i  i i } Wn t i ƒ  } n Xt i i | ƒ p t i ƒ  } n t i i | |  i ƒ } | |  _ t	 i
 d | d d ƒ } | i | | | d d ƒ} |  i o t i | IJn y t | d ƒ }	 Wn t i d IJd	 SXt d
 d d d
 |  i ƒ }
 t i |
 IJ|	 i |  i | ƒ ƒ |	 i ƒ  t d ƒ d	 S(   s<   Handle an exception, call for compatible with sys.excepthookt   NoColort   color_schemet   long_headeri   t   contexti   t   ws&   Could not create crash report on disk.Ns   
R
   iF   s   Press enter to exit:(   R   t   rct
   ipythondirt   ost   getcwdt   patht   isdirt   joinR   R	   t	   VerboseTBt   textR   t   syst   stderrt   openR   R   t   writet   make_reportt   closet	   raw_input(   R   t   etypet   evaluet   etbR   t   rptdirt   report_namet	   TBhandlert	   tracebackt   reportt   msg(    (    sL   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/CrashHandler.pyt   __call__t   s0    		

c         C   s  d d d d } g  } | i  } | d d d d ƒ | d t i ƒ | d t i ƒ | d t i t i f ƒ | | d ƒ | t |  i	 i
 i ƒ  ƒ ƒ | | d	 | ƒ yU | | d
 ƒ x" |  i	 i d D] } | | ƒ qÑ W| d ƒ | |  i	 i d ƒ Wn n Xd i | ƒ S(   s*   Return a string containing a crash report.s   

R
   iK   s   IPython post-mortem report

s   IPython version: %s 

s   SVN revision   : %s 

s2   Platform info  : os.name -> %s, sys.platform -> %ss'   Current user configuration structure:

s   Crash traceback:

s   History of session input:t   _ihs7   
*** Last line of input (may not be in above history):
s   
t    (   t   appendR    t   versiont   revisionR   t   nameR$   t   platformR   R   R   t   dictt   user_nst   _last_input_lineR!   (   R   R1   t   sec_sepR2   t   rpt_addt   line(    (    sL   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/CrashHandler.pyR(   Ÿ   s*    	 
(   t   __name__t
   __module__t   __doc__t   TrueR   R4   R(   (    (    (    sL   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/CrashHandler.pyR   !   s   G	+t   IPythonCrashHandlerc           B   s    e  Z d  Z d „  Z d „  Z RS(   sD   sys.excepthook for IPython itself, leaves a detailed report on disk.c      	   C   sR   d } d } d } t  i | d  \ } } d } t i |  | | | | | | ƒ d  S(   Nt   Villet   IPythons0   http://projects.scipy.org/ipython/ipython/reporti   s   IPython_crash_report.txt(   R    t   authorsR   R   (   R   R   t   AUTHOR_CONTACTR   R   R   R   R   (    (    sL   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/CrashHandler.pyR   ½   s    c         C   s  d d d d } g  } | i  } | d d d d ƒ | d t i ƒ | d t i ƒ | d t i t i f ƒ | | d ƒ | t |  i	 i
 i ƒ  ƒ ƒ | | d	 | ƒ yU | | d
 ƒ x" |  i	 i d D] } | | ƒ qÑ W| d ƒ | |  i	 i d ƒ Wn n Xd i | ƒ S(   s*   Return a string containing a crash report.s   

R
   iK   s   IPython post-mortem report

s   IPython version: %s 

s   SVN revision   : %s 

s2   Platform info  : os.name -> %s, sys.platform -> %ss'   Current user configuration structure:

s   Crash traceback:

s   History of session input:R5   s7   
*** Last line of input (may not be in above history):
s   
R6   (   R7   R    R8   R9   R   R:   R$   R;   R   R   R   R<   R=   R>   R!   (   R   R1   R?   R2   R@   RA   (    (    sL   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/CrashHandler.pyR(   Ë   s*    	 
(   RB   RC   RD   R   R(   (    (    (    sL   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/CrashHandler.pyRF   º   s   	(    (   RD   RH   R    RI   t
   __author__t   licenset   __license__R8   t   __version__R   R$   R   R   t   IPython.ItplR   R   R   t   IPython.ColorANSIR   R   R	   t   IPython.genutilsR   RF   (    (    (    sL   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/CrashHandler.pyt   <module>   s   			
™