Mini Shell

Direktori : /lib64/python3.6/site-packages/pyanaconda/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/pyanaconda/__pycache__/exception.cpython-36.pyc

3

C��eDA�@s|ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlmZddl
mZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZmZddlmZddlm Z dd
l!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,e,e-�Z.Gdd�de�Z/Gdd�de�Z0dd�Z1dd�Z2dd�Z3dd�Z4dd �Z5d!d"�Z6dS)#�N)�Config)�ReverseExceptionDump)�ExceptionHandler)�	kickstart)�util)�product)�run_in_loop)�conf)�THREAD_EXCEPTION_HANDLING_TEST�IPMI_FAILED)�NonInteractiveError)�_)�UnusableStorageError)�	threadMgr)�hubQ)�App)�ExceptionSignal)�get_module_loggerc@seZdZedd��ZdS)�AnacondaReverseExceptionDumpcCsL|jrD|jrDtj|j|j�djd�}|d}|jd�d}|j�SdSdS)a~
        When traceback will be part of the exception message split the
        description from traceback. Description is used in name of the
        bug in Bugzilla.
        This is useful when saving exception in exception handler and
        raising this exception elsewhere (subprocess exception).

        :return: Exception description (bug name)
        :rtype: str
        rz

Traceback�
�N)�type�value�	traceback�format_exception_only�split�strip)�selfZ
parsed_exc�description�r�!/usr/lib64/python3.6/exception.py�desc9sz!AnacondaReverseExceptionDump.descN)�__name__�
__module__�__qualname__�propertyr!rrrr r7srcsHeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
�AnacondaExceptionHandlercs&t�j|||�||_||_||_dS)z|
        :see: python-meh's ExceptionHandler
        :param tty_num: the number of tty the interface is running on

        N)�super�__init__�	_gui_lock�
_intf_tty_num�_interactive)rZconfObjZ	intfClassZexnClass�tty_numZgui_lock�interactive)�	__class__rr r(Rsz!AnacondaExceptionHandler.__init__cs�|jj}|jj}t|tjj�r$|js:t|t�rr|j	t	j
krrtd�t|�}|j
jtd�|�|j|�tjd�nPt|t�r�|j|�tjd�n0t|t�r�|j|�tjd�nt�j|�dSdS)z�
        Helper method with one argument only so that it can be registered
        with run_in_loop to run on idle or called from a handler.

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

        z�The installation was stopped due to what seems to be a problem with your hardware. The exact error message is:

%s.

 The installer will now terminate.zHardware error occurredrFN)�exc_inforr�
issubclass�blivet�errorsZStorageErrorZhardware_fault�OSError�errnoZEIOr
�str�intfZ
messageWindow�_run_kickstart_scripts�sys�exit�
isinstancerrr'�handleException)r�	dump_info�tyrZhw_error_msg)r.rr �_main_loop_handleException^s"	





z3AnacondaExceptionHandler._main_loop_handleExceptionc

Cs�tjd�tj|j�}tjdj|��|jj}|jj}ynt	j
dd�ddlm}|j
d�d}|sht��|jjd�s�tjd	�t|j|�ntjd
�|j|�W�ntttfk
�r�tjd�tj��rXtjd�t|t�s�|j�rDt|t��rtd
�t|�}ntd�t|�}t|�|j|�tjd�t j!d�ntd�|j|�nPtjd�|j}t"j#��r�t"j$�}	|	j%t&t"j'�|d��nt(j)|j|j|j*f�YnXdS)z�
        Our own handleException method doing some additional stuff before
        calling the original python-meh's one.

        :type dump_info: an instance of the meh.DumpInfo class
        :see: python-meh's ExceptionHandler.handleException

        zrunning handleExceptionr�Gtkz3.0r)r?NFz7Gtk running, queuing exception handler to the main loopzAGtk not running, starting Gtk and running exception handler in itzGtk cannot be initializedz-In the main thread, running exception handlera
The installation was stopped due to an error which occurred while running in non-interactive cmdline mode. Since there cannot be any questions in cmdline mode, edit your kickstart file and retry installation. 
The exact error message is: 

%s. 

The installer will now terminate.z�
Running in cmdline mode, no interactive debugging allowed.
The exact error message is: 

%s.

The installer will now terminate.��zU
An unknown error has occured, look at the /tmp/anaconda-tb* file(s) for more detailsz;In a non-main thread, sending a message with exception data)Zexception_info)+�log�debugr�format_exceptionr/Zcritical�joinrr�giZrequire_versionZ
gi.repositoryr?Z
init_check�RuntimeErrorr)�acquirerr>�ImportError�
ValueErrorrZin_main_threadr0rr+r
r5�printr7�timeZsleepr8r9rZis_initializedZget_event_loopZenqueue_signalrZ
get_schedulerrZsend_exception�stack)
rr<Zexception_linesr=rr?ZinitializedZcmdline_error_msgr/Zlooprrr r;sP











z(AnacondaExceptionHandler.handleExceptioncCs�tjtjjdtj�rry,tjjdtjj|j�}t	j
|j|�Wn.t	jtfk
rpt
jd|jtjj�YnX|j|�tjt�dS)Nz/rootz/root/%szFailed to copy %s to %s/root)�os�accessr	�target�system_root�X_OK�path�basenameZexnFile�shutilZcopyfile�Error�IOErrorrB�errorr7rZipmi_reportr)rr<�destrrr �
postWriteHook�s
z&AnacondaExceptionHandler.postWriteHookc	Cs8|j}y tj|jj�tj|jj�WnYnXdS)z2Run the %traceback and %onerror kickstart scripts.N)�objectrZrunOnErrorScriptsZksdata�scriptsrZrunTracebackScripts)rr<�anacondarrr r7�sz/AnacondaExceptionHandler._run_kickstart_scriptscCs�tjjr|jdkrtjd�tjdtj�tj	dd�tj	dd�ddl
}tjj
�}|j|�}|d|j@|d<|j||j|�td�td�ddl}|j|j�tjjr�|jdkr�tj|j�dS)NrAz/dev/consoler��z
Entering debugger...zKUse 'continue' command to quit the debugger and get back to the main window)r	�systemZcan_switch_ttyr*rZ
vtActivaterN�open�O_RDWR�dup2�termiosr8�stdin�filenoZ	tcgetattrZECHOZ	tcsetattrZ	TCSADRAINrK�pdbZpost_mortemrM)rr/rdZsi�attrrgrrr �runDebug�s 


z!AnacondaExceptionHandler.runDebug)
r"r#r$r(r>r;rZr7ri�
__classcell__rr)r.r r&Ps!Zr&cCsNdddddddtjjdd	d
ddg}tjjd
�r<|jd
g�|jrZ|jjrZ|j|jjg�t	dt
j�tj�dddddddddddddddddd d!gd"d#d$d%d&g|d'�}|j
d(td)d*�|j
d+td,d*�|j
d-d.d/�d,d*�|j
d0td)d*�d
|k�r|j
d1td)d*�tj�s"|j
d2d3d/�d,d*�t||jjt|jj|j|j�}|j|�|S)4Nz/tmp/anaconda.logz/tmp/packaging.logz/tmp/program.logz/tmp/storage.logz/tmp/dnf.librepo.logz/tmp/hawkey.logz/tmp/lvm.logz/root/install.logz
/proc/cmdlinez/root/lorax-packages.logz/tmp/blivet-gui-utils.logz
/tmp/dbus.logz/tmp/syslogr]�z_intf._actionsz _intf._currentAction._xklwrapperz:_intf._currentAction._spokes["KeyboardSpoke"]._xkl_wrapperz(_intf._currentAction._storage_playgroundzK_intf._currentAction._spokes["CustomPartitioningSpoke"]._storage_playgroundz*_intf._currentAction.language.translationsz%_intf._currentAction.language.localesz6_intf._currentAction._spokes["PasswordSpoke"]._oldweakz7_intf._currentAction._spokes["PasswordSpoke"]._passwordz3_intf._currentAction._spokes["UserSpoke"]._passwordz2_intf._currentAction._spokes["UserSpoke"]._oldweakz!_intf.storage.bootloader.passwordz_intf.storage.dataz_intf.storage.ksdataz
_intf.dataz_bootloader.encrypted_passwordz_bootloader.passwordzpayload._groupsZ
passphraseZpasswordZ_oldweakZ	_passwordZtry_passphrase)ZprogramNameZprogramVersionZprogramArchZattrSkipListZ
localSkipListZfileListZlsblk_outputF)Z
attchmnt_onlyZnmcli_dev_listTrcSsdS)Nr]rrrrr �<lambda>8sz'initExceptionHandling.<locals>.<lambda>Zaddons�
journalctlZrelease_typecSsdS)Nzpre-releaserrrrr rlAs)r	rPrQrNrS�exists�extendZoptsZksfilerrZget_anaconda_version_string�unameZregister_callback�lsblk_callback�nmcli_dev_list_callback�list_addons_callback�journalctl_callbackrZisFinalr&r6Z
meh_interfacerr,Zgui_initializedZinteractive_modeZinstall)r]Z	file_list�configZhandlerrrr �initExceptionHandling
s^



rvcCsd}tjddd|g�S)z)Callback to get info about block devices.z@NAME,SIZE,OWNER,GROUP,MODE,FSTYPE,LABEL,UUID,PARTUUID,MOUNTPOINTZlsblkz--bytesz-o)r�execWithCapture)Zoptionsrrr rqKsrqcCstjdddg�S)z+Callback to get info about network devices.ZnmcliZdeviceZshow)rrwrrrr rrSsrrcCsLtjdtj��}d}x0tjddg�D]}|j|�dkr&||d7}q&W|S)z%Callback to get logs from journalctl.z\[%d\]:rrmz-bNr)�re�compilerN�getpidrZ
execReadlines�search)Zanaconda_log_line�ret�linerrr rtYsrtcCstjd�}djdd�|D��S)z`
    Callback to get info about the addons potentially affecting Anaconda's
    behaviour.

    z/usr/share/anaconda/addons/*z, css|]}|jdd�dVqdS)�/rAN)�rsplit)�.0Zaddonrrr �	<genexpr>qsz'list_addons_callback.<locals>.<genexpr>)�globrE)Z
addon_pkgsrrr rshs
rscCs8dd�}d}d}ddlm}tj|t|||fd��dS)	z�
    Function that can be used for testing exception handling in anaconda. It
    tries to prepare a worst case scenario designed from bugs seen so far.

    cSs8ttj��jdd�d}d||f}tt|dd��dS)N�.rArzO
def f%s(msg, non_ascii):
        raise RuntimeError(msg)

f%s(msg, non_ascii)
Zstr_eval�exec)r5rLr�evalry)�msg�	non_asciiZ	timestamp�coderrr �raise_exception}sz0test_exception_handling.<locals>.raise_exceptionuřz#NOTABUG: testing exception handlingr)�AnacondaThread)�namerP�argsN)�pyanaconda.threadingr�r�addr
)r�r�r�r�rrr �test_exception_handlingts	
r�)7r4r�rFrNrxrUr8rLrZ
blivet.errorsr1ZmehrZmeh.dumprZmeh.handlerrZ
pyanacondarZpyanaconda.corerrZpyanaconda.core.async_utilsrZ&pyanaconda.core.configuration.anacondar	Zpyanaconda.core.constantsr
rZpyanaconda.errorsrZpyanaconda.core.i18nr
Z(pyanaconda.modules.common.errors.storagerr�rZpyanaconda.ui.communicationrZ
simplelinerZsimpleline.event_loop.signalsrZpyanaconda.anaconda_loggersrr"rBrr&rvrqrrrtrsr�rrrr �<module>sH>>