Mini Shell

Direktori : /usr/lib64/python3.6/site-packages/pyanaconda/payload/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/pyanaconda/payload/__pycache__/manager.cpython-36.opt-1.pyc

3

C��e�$�@s�ddlZddlmZddlmZddlmZmZmZm	Z	m
Z
mZmZm
Z
ddlmZmZddlmZmZddlmZddlmZee�Zd	d
gZGdd
�d
e�ZGdd
�d
e�Ze�ZdS)�N)�IntEnum)�	DBusError)�THREAD_STORAGE�THREAD_PAYLOAD�THREAD_PAYLOAD_RESTART�THREAD_WAIT_FOR_CONNECTING_NM�THREAD_SUBSCRIPTION�PAYLOAD_TYPE_DNF�THREAD_STORAGE_WATCHER�THREAD_EXECUTE_STORAGE)�_�N_)�	threadMgr�AnacondaThread)�PayloadError)�get_module_logger�
payloadMgr�PayloadStatec@s0eZdZdZdZdZdZdZdZdZ	dZ
d
Zd	S)rz3Enum for payload state after payload was restarted.r������N���)�__name__�
__module__�__qualname__�__doc__�STARTED�WAITING_STORAGE�WAITING_NETWORK�VERIFYING_AVAILABILITY�DOWNLOADING_PKG_METADATA�DOWNLOADING_GROUP_METADATA�FINISHED�ERROR�r'r'�/usr/lib64/python3.6/manager.pyr'sc@sjeZdZdZed�Zed�Zdd�Zedd��Z	dd	�Z
ddd
�Zedd��Zdd�Z
dd�Zdd�ZdS)�PayloadManageraZFramework for starting and watching the payload thread.

    This class defines several states (PayloadState enum), and events can
    be triggered upon reaching a state. Depending on whether a state has
    already been reached when a listener is added, the event code may be
    run in either the calling thread or the payload thread. The event code
    will block the payload thread regardless, so try not to run anything
    that takes a long time.

    All states except ERROR are expected to happen linearly, and adding
    a listener for a state that has already been reached or passed will
    immediately trigger that listener. For example, if the payload thread is
    currently in DOWNLOADING_GROUP_METADATA, adding a listener for
    WAITING_NETWORK will immediately run the code being added
    for WAITING_NETWORK.

    The payload thread data should be accessed using the payloadMgr object,
    and the running thread can be accessed using threadMgr with the
    THREAD_PAYLOAD constant, if you need to wait for it or something. The
    thread should be started using payloadMgr.restart_thread.
    z$Failed to set up installation sourcez"Error downloading package metadatacCsHtj�|_i|_tj|_d|_x$tjj	�D]\}}g|jt|�<q*WdS)N)
�	threadingZLock�_event_lock�_event_listenersrr�
_thread_state�_error�__members__�items)�self�_name�valuer'r'r(�__init__Os
zPayloadManager.__init__cCs
t|j�S)N)rr.)r1r'r'r(�errorYszPayloadManager.errorc	CsR|j�B|j|j|�|tjkr4||jkrD|�n||jkrD|�WdQRXdS)z�Add a listener for an event.

        :param int event_id: The event to listen for, one of the EVENT_* constants
        :param function func: An object to call when the event is reached
        N)r+r,�appendrr&r-)r1�event_id�funcr'r'r(�add_listener]s


zPayloadManager.add_listenerFTcCs:tjd�tjt�rdStjtt|j||||fd��dS)a�Start or restart the payload thread.

        This method starts a new thread to restart the payload thread, so
        this method's return is not blocked by waiting on the previous payload
        thread. If there is already a payload thread restart pending, this method
        has no effect.

        :param payload.Payload payload: The payload instance
        :param bool fallback: Whether to fall back to the default repo in case of error
        :param bool checkmount: Whether to check for valid mounted media
        :param bool onlyOnChange: Restart thread only if existing repositories changed.
                                  This won't restart thread even when a new repository was added!!
        zRestarting payload threadN)�name�target�args)�log�debugr�getr�addr�_restart_thread)r1�payload�fallback�
checkmount�onlyOnChanger'r'r(�restart_threadts

zPayloadManager.restart_threadcCstjt�ptjt�S)z(Is the payload thread running right now?)r�existsrr)r1r'r'r(�running�szPayloadManager.runningcCs,tjt�tjtt|j||||fd��dS)N)r:r;r<)r�waitrr@r�_run_thread)r1rBrCrDrEr'r'r(rA�s

zPayloadManager._restart_threadc	CsDtjd|j�|j�&||_x|j|D]
}|�q(WWdQRXdS)Nz!Updating payload thread state: %s)r=r>r:r+r-r,)r1r7r8r'r'r(�
_set_state�s
zPayloadManager._set_statecCs�d|_|jtj�|jtj�tjt�tjt�tjt	�|jtj
�tjt�tjt�|j
�|jtkr~|jtj�dS|r�tjd�|jtj�|j�r�tjd�|jtj�dS|jtj�y|j||d�|j�WnPtttfk
�r0}z,tjd|�|j|_|jtj�|j�dSd}~XnX|jtj�|j �|j!�|j"�s�tjd�|j#|_|jtj�|j�dS|j$�|jtj�dS)Nz!Testing repositories availabilityz:Payload isn't restarted, repositories are still available.)rCrDzPayloadError: %szNo base repo configured)%r.rKrrr rrIrr
rr!rrZsetup�typer	r%r=r>r"Zverify_available_repositoriesr#Zupdate_base_repoZadd_driver_repos�OSErrorrrr5�ERROR_SETUPr&Zunsetupr$Zgather_repo_metadata�releaseZ	base_repo�ERROR_MDZ
post_setup)r1rBrCrDrE�er'r'r(rJ�sR








zPayloadManager._run_threadN)FTF)rrrrr
rNrPr4�propertyr5r9rFrHrArKrJr'r'r'r(r)5s

r))r*�enumrZdasbus.errorrZpyanaconda.core.constantsrrrrrr	r
rZpyanaconda.core.i18nrr
Zpyanaconda.threadingrrZpyanaconda.payload.errorsrZpyanaconda.anaconda_loggersrrr=�__all__r�objectr)rr'r'r'r(�<module>s(=