Mini Shell

Direktori : /usr/lib/python3.6/site-packages/meh/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/meh/__pycache__/handler.cpython-36.opt-1.pyc

3

��\e.�@s�ddlmZmZmZmZmZmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
dd�ZGdd�de�ZGdd�de�ZdS)	�)�MAIN_RESPONSE_DEBUG�MAIN_RESPONSE_SAVE�MAIN_RESPONSE_SHELL�MAIN_RESPONSE_QUIT�DumpInfo�
ExceptionInfoNcCs |dkrtjddd�j|�SdS)N�z
python-mehT)Zfallback)�gettextZtranslation)�x�r�/usr/lib/python3.6/handler.py�<lambda>sr
c@seZdZddd�Zdd�ZdS)�	NoNetworkrcCstj|�||_dS)N)�	Exception�__init__�msg)�selfrrrrrs
zNoNetwork.__init__cCsdS)NzNo network is availabler)rrrr�__str__#szNoNetwork.__str__N)r)�__name__�
__module__�__qualname__rrrrrrrs
rc@s�eZdZdd�Zdd�Zedd�dd��Zdd	�Zed
d�dd��Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�ExceptionHandlercCs.||_||_||_d|_d|_d|_d|_dS)a�Create a new ExceptionHandler instance.  Subclasses of this one may
           be created, provided they are careful to provide all the methods
           this one does.  Instance attributes:

           conf     -- A filled in Config instance.  At least the programName
                       and programVersion are required.
           exnClass -- An instance of ExceptionDump or a subclass of it.  This
                       is required to know how to represent the Python
                       exception internally.
           intfClass-- An instance of AbstractIntf.  This is required to know
                       what UI classes to use.
        �
Nr)�conf�exnClass�intf�	_exitcode�_exn�exnFile�exnText)rZconfObjZ	intfClassrrrrr's
zExceptionHandler.__init__cCs
||_dS)N)r)r�coderrr�_setExitCode=szExceptionHandler._setExitCodecCs|jS)N)r)�srrrr
@szExceptionHandler.<lambda>cCs
|j|�S)N)r!)r"�vrrrr
AscCs
||_dS)N)r)r�errr�_setExnCszExceptionHandler._setExncCs|jS)N)r)r"rrrr
FscCs
|j|�S)N)r%)r"r#rrrr
GscCs
t|jt|jt|jt|ji}t|j	j
tj�r8t
j|j�t
jt
_|j|�|j|j	|j�|_|j�\}|_|jj|j�|_|j|j�|j�|j|�xd|jjt |j�|j�}|s�|j|j	�|j!�}|j"�y|||j	�Wq�t#k
r�w�Yq�Xq�W|j"�dS)asThis is the main exception handling entry point.  When Python
           gets an exception it doesn't know how to handle, this method will
           be called.  It then saves the traceback and displays the main
           dialog asking the user what to do next.  Once this method is
           called, there's no good way to go back to what you were doing
           before.

           All arguments are passed in from the handler created by calling
           self.install().  This method should not usually be overridden by
           a subclass.

           :type dump_info: an instance of the meh.DumpInfo class

        N)$r�runQuitr�runDebugr�runSaver�runShell�
isinstance�exc_info�value�bdbZBdbQuit�sys�exit�exitcode�__excepthook__�
excepthook�preWriteHookrr�exn�openFilerZtraceback_and_object_dump�objectr�write�close�
postWriteHookrZmainExceptionWindow�strZrunZdestroy�KeyError)r�	dump_infoZresponseHash�fobj�winZrcrrr�handleExceptionIs2


z ExceptionHandler.handleExceptioncCsdS)a5Subclasses may supply a function with this name that will be
           called immediately before the traceback is written to disk in
           order to have any sort of special pre-write processing that needs
           to be done.

           :type dump_info: an instance of the meh.DumpInfo class
        Nr)rr<rrrr3�szExceptionHandler.preWriteHookcCsdS)agSubclasses may supply a function with this name that will be
           called immediately after the traceback is written to disk, but
           immediately before the UI is run.  This is to provide a place for
           any special handling to happen once there is a file on disk.

           :type dump_info: an instance of the meh.DumpInfo class
        Nr)rr<rrrr9�szExceptionHandler.postWriteHookcs��fdd�t_dS)a�Install ourselves as the top level exception handler with Python.
           If this method is not called after an ExceptionHandler instance is
           created, none of the rest of this code will ever be called.

           obj -- A Python object that may be dumped to a file when the
                  exception is saved.  This should be something like the top
                  level object in a program.
        cs�jtt|||����S)N)r?rr)Ztyr,�tb)�objrrrr
�sz*ExceptionHandler.install.<locals>.<lambda>N)r.r2)rrAr)rArr�install�s	zExceptionHandler.installcCs6ddl}|jdd|jjd�\}}tj|d�}||fS)avCreate a randomly named output file to write the exception dump to.
           This requires a programName be set in the Config instance.  The
           return value is a (file descriptor, path) pair.  The file must be
           closed by the caller when writing is done.  Subclasses should not
           override this method unless they know what they're doing.
        rNrz%s-tb-z/tmp�w)�tempfileZmkstempr�programName�os�fdopen)rrD�fd�pathZforrrr5�szExceptionHandler.openFilecCstj|j�dS)aThis method is called when the "Exit" button is clicked.  It may
           be overridden by a subclass, but the basic behavior of eventually
           quitting should be preserved.

           :type exc_info: an instance of the meh.ExceptionInfo class
        N)r.r/r0)rr+rrrr&�szExceptionHandler.runQuitcCs,td�ttd��ddl}|j|j�dS)z�This method is called when the "Debug" button is clicked.  It may
           be overridden by a subclass if specialized behavior is required to
           enter debug mode.

           :type exc_info: an instance of the meh.ExceptionInfo class
        rzIUse 'continue' command to quit the debugger and get back to the main menurN)�print�_�pdbZpost_mortem�stack)rr+rLrrrr'�szExceptionHandler.runDebugcCs4td�ttd��tjddgddd�}|j�dS)	a	This method is called when user requests to run a shell. It may
           be overridden by a subclass if specialized behavior is required to
           run shell (e.g. TTY switching).

           :type exc_info: an instance of the meh.ExceptionInfo class

        rz+Exit the shell to get back to the main menuZbashz--loginT�/)�shell�cwdN)rJrK�
subprocess�Popen�wait)rr+�procrrrr)�s	zExceptionHandler.runShellcCsnt�}|j|jj�|jdd�}d|kr4|jj|d<|r�|j|d<|j|d<|j	|d<|j
|d<|j|d<d	|j|j|j	|jf|d
<nr|jj|d<|jjj
dd�}t|�d
kr�|\}}n|d}d}||d<||d<d|d<|jj|d<dj|j�|d
<|jj|d<|jj|d<|jj|d<d|jjt|j�f|d<d|jj}|j||<xh|jjj�D]X\}\}	}
y|	�}|�r~|||<Wn0tk
�r�}zd|||<WYdd}~XnX�q\Wxr|jjD]f}
yNt|
d��:}tjj|
�}||k�r�|j�||<n|j�||d<WdQRXWn�w�YnX�q�Wd|d<djtj |j!|j"|j#��|d<t$j%f|�}|j&j'|�dS)z�This method is called when the "Save" button is clicked.  It may
           be overridden by a subclass, but that's going to be a lot of work.

           :type exc_info: an instance of the meh.ExceptionInfo class
        �pkg_infoNZ	componentZpkg_nameZpkg_versionZpkg_releaseZ	pkg_epochZpkg_archz%s-%s-%s.%s�package�-��r�1�0z"{0.programName}-{0.programVersion}ZhashmarkernameZduphash�reasonz/The following was filed automatically by %s:
%s�descriptionz%s-tbzCaused error: %s�rZ_file�PythonZanalyzerrZ	backtrace)(�dict�updater4Zenvironment_info�poprrE�name�version�releaseZepochZarchZprogramVersion�rsplit�lenZprogramArch�format�hashZdescr:rZcallbackDict�itemsrZfileList�openrFrI�basename�read�join�	traceback�format_exception�typer,rM�reportZ'createPythonUnhandledExceptionSignaturerZsaveExceptionWindow)rr+ZparamsrU�partsrdreZtb_item_nameZ	item_name�callbackZ_anc�ret�excZfpathr=�filenameZ	signaturerrrr(�sl







$
zExceptionHandler.runSaveN)rrrrr!�propertyr0r%r4r?r3r9rBr5r&r'r)r(rrrrr&s 

:

	r)Zmehrrrrrrr-rFr.rrrorQr	rKrrr6rrrrr�<module>s