o
    û›hÙ"  ã                   @   sÂ   d Z ddlZddlZddlmZ ddlmZ ddlZddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlZdZdZG dd„ dƒZdee dedejddfdd„ZdS )ztsys.excepthook for IPython itself, leaves a detailed report on disk.

Authors:

* Fernando Perez
* Brian E. Granger
é    N)Úpformat)ÚPath)Úultratb)ÚApplication)Úauthor_email)Úsys_info)Ú__version__)ÚOptionalÚDicta†  Oops, {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 {app_name} configuration.

It was left in the file named:
	'{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: {contact_name} at {contact_email}
with the subject '{app_name} Crash Report'.

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

In your email, please also include information about:
- The operating system under which the crash happened: Linux, macOS, Windows,
  other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2,
  Windows 10 Pro), and whether it is 32-bit or 64-bit;
- How {app_name} was installed: using pip or conda, from GitHub, as part of
  a Docker container, or other, providing more detail if possible;
- How to reproduce the crash: what exact sequence of instructions can one
  input to get the same crash? Ideally, find a minimal yet complete sequence
  of instructions that yields the crash.

To ensure accurate tracking of this issue, please file a report about it at:
{bug_tracker}
a„  
If you suspect this is an IPython {version} bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at {email}

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    {config}Application.verbose_crash=True
c                   @   sš   e Zd ZU dZeZdZeee	e f e
d< 					ddede	e d	e	e d
e	e dedefdd„Zdee dedejddfdd„Zdedefdd„ZdS )ÚCrashHandlerzýCustomizable crash handlers for IPython applications.

    Instances of this class provide a :meth:`__call__` method which can be
    used as a ``sys.excepthook``.  The :meth:`__call__` signature is::

        def __call__(self, etype, evalue, etb)
    zO

***************************************************************************

ÚinfoNTFÚappÚcontact_nameÚcontact_emailÚbug_trackerÚshow_crash_tracebackÚcall_pdbc                 C   s:   d|j  | _|| _|| _|| _t|j |||| jd�| _dS )a¢  Create a new crash handler

        Parameters
        ----------
        app : Application
            A running :class:`Application` instance, which will be queried at
            crash time for internal information.
        contact_name : str
            A string with the name of the person to contact.
        contact_email : str
            A string with the email address of the contact.
        bug_tracker : str
            A string with the URL for your project's bug tracker.
        show_crash_traceback : bool
            If false, don't print the crash traceback on stderr, only generate
            the on-disk report
        call_pdb
            Whether to call pdb on crash

        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.

        zCrash_report_%s.txt)Zapp_namer   r   r   Úcrash_report_fnameN)Únamer   r   r   r   Údictr   )Úselfr   r   r   r   r   r   © r   úOc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/crashhandler.pyÚ__init__g   s   #üzCrashHandler.__init__ÚetypeÚevalueÚetbÚreturnc                 C   sb  t jt _d}t| jddƒ}|durt|tƒsJ ‚t|ƒ}nt ¡ }| 	¡ s)t ¡ }|| j
 }t|ƒ| _
t|ƒ| jd< tj|d| jd�}| jrN||||ƒ dS |j|||dd�}	| jrat|	t jd	� z	t|d
dd�}
W n   tdt jd	� Y dS |
�( tdt jd	� t| jjdi | j¤Žt jd	� |
 |  t|	ƒ¡¡ W d  ƒ n1 s¥w   Y  t d¡ dS )z<Handle an exception, call for compatible with sys.excepthookZNoColorÚipython_dirNr   T)Úcolor_schemeZlong_headerr   é   )Úcontext©ÚfileÚwzutf-8)Úencodingz&Could not create crash report on disk.zH
**********************************************************************
z.Hit <Enter> to quit (your terminal may close):r   )ÚsysÚ__excepthook__Ú
excepthookÚgetattrr   Ú
isinstanceÚstrr   ÚcwdÚis_dirr   r   r   Z	VerboseTBr   Útextr   ÚprintÚstderrÚopenÚmessage_templateÚformatÚwriteÚmake_reportÚbuiltin_modÚinput)r   r   r   r   r   r   ZrptdirZreport_nameZ	TBhandlerÚ	tracebackÚreportr   r   r   Ú__call__•   sD   


ýúzCrashHandler.__call__r8   c                 C   sx   | j }dg}|j}|tƒ ƒ zt| jjƒ}||ƒ |d| jj ƒ |dƒ ||ƒ W n   Y ||d | ƒ d |¡S )z*Return a string containing a crash report.zi***************************************************************************

IPython post-mortem report

zApplication name: %s

z'Current user configuration structure:

zCrash traceback:

Ú )Úsection_sepÚappendr   r   r   Úconfigr   Újoin)r   r8   Zsec_sepr9   Zrpt_addr>   r   r   r   r5   Ô   s   

zCrashHandler.make_report)NNNTF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú_default_message_templater2   r<   r
   r+   r	   Ú__annotations__r   Úboolr   ÚtypeÚBaseExceptionÚtypesÚTracebackTyper:   r5   r   r   r   r   r   Z   sB   
 ùþýüûú
ù.þýü
û?r   r   r   Útbr   c                 C   sJ   t  | ||¡ ddlm} | ¡ rd}nd}ttjt|t	d�t
jd� dS )zAa light excepthook, adding a small message to the usual tracebackr   )ÚInteractiveShellz%config zc.)Úemailr>   Úversionr"   N)r8   Úprint_exceptionZIPython.core.interactiveshellrL   Zinitializedr/   Ú_lite_message_templater3   r   rN   r&   r0   )r   r   rK   rL   r>   r   r   r   Úcrash_handler_liteê   s   rQ   )rC   r&   r8   Úpprintr   Úpathlibr   Úbuiltinsr6   ZIPython.corer   ZIPython.core.applicationr   ZIPython.core.releaser   ZIPython.utils.sysinfor   r   rN   Útypingr	   r
   rI   rD   rP   r   rG   rH   rJ   rQ   r   r   r   r   Ú<module>   s4   ! ÿÿÿþ