MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/leapp/messaging/__init__.pyo
�
g��fc@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZmZdd	lmZd
efd��YZdS(i����N(tconfigparser(tRawMessageDialog(tCommandlineRenderer(tCannotConsumeErrorMessages(tAnswerStore(tWorkflowCommand(tDialogModelt
ErrorModel(tget_api_modelst
BaseMessagingcBseZdZeddd�Zd�Zed��Zed��Z	d�Z
d�Zed��Zd�Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zed�Zd�Zd�Zd�Zd�ZRS(s�
    BaseMessaging is the Base class for all messaging implementations. It provides the basic interface that is
    supported within the framework. These are called the `produce` and `consume` methods.
    cCs�tj�|_t�|_|jj�|_|pBtd|j�|_|jj�|_	|jj�|_
|jj�|_||_|r�|fnd|_
|jj�|_|jjtt�|_dS(Ntmanager((tmultiprocessingtManagert_managerRt_dialog_renderertlistt_dataRt_answerst	_new_datat	_commandst_errorst_storedt_config_modelst_dialogstValuetbooltFalset_stop_after_phase(tselftstoredtconfig_modeltanswer_store((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyt__init__s	cCs|jj||�dS(sK
        Loads answers from a given answer file

        :param answer_file: Path to file to load as answer file
        :type answer_file: str
        :param workflow: :py:class:`leapp.workflows.Workflow` instance to load the answers for.
        :type workflow: :py:class:`leapp.workflows.Workflow`
        :return: None
        N(Rtload_and_translate_for_workflow(Rtanswer_filetworkflow((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytload_answers&s
cCs
t|j�S(sZ
        :return: List of commands that have been sent to the workflow execution.
        (RR(R((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytcommands2scCs|jS(so
        :return: If the messages are stored immediately, this function returns True, otherwise False.
        (R(R((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyR9scCs
t|j�S(sy
        Gets all dialogs actually encountered during workflow run

        :return: List of encountered dialogs
        (RR(R((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytdialogs@scCs
t|j�S(s[
        Gets all produced errors.

        :return: List of newly produced errors
        (RR(R((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyterrorsHscCs
|jj�S(s�
        Returns True if execution stop was requested after the current

        :return: True if the executed was requested to be stopped.
        (Rtget(R((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytstop_after_phasePscCs
t|j�S(sf
        Gets all newly produced messages.

        :return: List of newly processed messages
        (RR(R((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytmessagesYscCs
t��dS(s�
        Loads all messages that are requested from the `consumes` attribute of :py:class:`leapp.actors.Actor`

        :param consumes: Tuple or list of :py:class:`leapp.models.Model` types to preload
        :return: None
        N(tNotImplementedError(Rtconsumes((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyt
_perform_loadascCs
t��dS(s3
        This method performs the actual message sending, which can be sent over the network or stored
        in a database.

        :param message: The message data to process
        :type message: dict
        :return: Pass through a message that might get updated through the sending process.
        N(R+(Rtmessage((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyt_process_messagejs	cCs0t|krt��n|j||j�dS(sG
        Loads all messages that are requested from the `consumes` attribute of :py:class:`leapp.actors.Actor`

        :param consumes: Tuple or list of :py:class:`leapp.models.Model` types to preload
        :return: None
        :raises leapp.exceptions.CannotConsumeErrorMessages: When trying to consume ErrorModel
        N(RRR-R(RR,((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytloaduscCse|rtj|�}ntd|d|jd|d|dtjj��}|j|||j�dS(s�
        Reports an execution error

        :param message: Message to print the error
        :type message: str
        :param severity: Severity of the error
        :type severity: leapp.models.error_severity.ErrorSeverity
        :param actor: Actor name that produced the message
        :type actor: leapp.actors.Actor
        :param details: A dictionary where additional context information can be passed along with the error
        :type details: dict
        :return: None
        R.tactortseveritytdetailsttimeN(tjsontdumpsRtnametdatetimetnowt_do_produceR(RR.R2R1R3tmodel((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytreport_error�s
!cCsJtd|d|d|dddtjj��}|j|||j�dS(NR.R3R1R2tfatalR4(RR8R9R:R(RR.ttracet	actornameR;((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytreport_stacktrace�scCs|jjt�dS(sk
        If called, it will cause the workflow to stop the execution after the current phase ends.
        N(RtsettTrue(R((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytrequest_stop_after_phase�scCsT|j|j�}g|jj�D](}|jdd�d|kr"|^q"}|S(Nt.ii(tget_answersRtanswerfile_sectionstkeystsplit(Rtdialogtuserchoiceststres((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyt_unanswered_questions�s>c	Cs�|jj|�|j|�}|r�|jr7|jn3tjdjt|jj	���j
d��j�}|jt
d|jd|jd|�|�nP|j|j�}x;|j�D]-\}}|j|�}|r�||_q�q�WdS(Nt,sutf-8R1RFtkey(RtappendRMROthashlibtsha1tjointsortedRFRGtencodet	hexdigesttproduceRR7RERtitemstcomponent_by_keytvalue(	RRIR1t
unansweredt
stable_keyRJt	componentRZtdialog_component((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytregister_dialog�s0	cCs8t|t�r(|jj|j��ntd��dS(s�
        Called to send a command to the workflow execution

        :param command: A command to send to the workflow execution.
        :type command: Instance of :py:class:`leapp.messaging.commands.WorkflowCommand`
        :return: None
        s'Expected an instance of WorkflowCommandN(t
isinstanceRRRPRUt	TypeError(Rtcommand((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyRb�scCs|j|||j�S(sX
        Called to send a message available for other actors.

        :param model: Model to send as message payload
        :type model: :py:class:`leapp.models.Model`
        :param actor: Actor that sends the message
        :type actor: :py:class:`leapp.actors.Actor`
        :return: the updated message dict
        :rtype: dict
        (R:R(RR;R1((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyRW�scCs|j|||jdt�S(sn
        Called to pre-fill sent messages and make them available for other actors.

        :param model: Model to send as message payload
        :type model: :py:class:`leapp.models.Model`
        :param actor: Actor that sends the message
        :type actor: :py:class:`leapp.actors.Actor`
        :return: the updated message dict
        :rtype: dict
        R(R:RR(RR;R1((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytfeed�scCsEtjjdd�s+tj�tjd<ntj|j�dt	�}it
|�jd6t|t
�swt
|�jn|d6|jjd6tjj�j�dd6tjjdd	�d
6tjjdd�d
6tjdd6i|d6tj|jd��j�d6d6}|r4|jr4|j|j��n|j|�|S(NtLEAPP_HOSTNAMEt	sort_keysttypeR1ttopictZtstamptLEAPP_CURRENT_PHASEsNON-WORKFLOW-EXECUTIONtphasetLEAPP_EXECUTION_IDsTESTING-CONTEXTtcontextthostnametdatasutf-8thashR.(tostenvironR(tNonetsockettgetfqdnR5R6tdumpRBRft__name__R`tstrR7RgR8tutcnowt	isoformatRQtsha256RURVRR/tcopyRP(RR;R1ttargetRRoR.((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyR:�s$%
&
cCs|j|j�S(N(RER(RRI((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyRE�scCs|j|j|j�S(N(trequest_answersRR(RRI((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyR~�scCs#td|�j|j|j�dS(s�
        Display a message in user interterface currently in use (CLI, GUI).

        It uses one of the dialog renderers in :py:mod:`leapp.dialogs.renderer`.

        :param message: Message to show
        :type message: str
        R.N(RR~RR(RR.((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytshow_messages	cs�td�|D��}t|j�t|j�}d�tt|�d�|jD��|r�td�|D��}g|D]}|d|kr{|^q{}n�fd�|D�S(s7
        Returns all consumable messages and filters them by `types`

        :param types: Variable number of :py:class:`leapp.models.Model` derived types to filter messages to be consumed
        :param actor: Actor that consumes the data
        :return: Iterable with messages matching the criteria
        css!|]}t|d|�VqdS(t	_resolvedN(tgetattr(t.0tt((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pys	<genexpr>scSsi|]}||j�qS((Rw(R�R;((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pys
<dictcomp>s	R,css|]}|jVqdS(N(Rw(R�t	requested((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pys	<genexpr>sRfc3s7|]-}�|djtj|dd��VqdS(RfR.RoN(tcreateR5tloads(R�R.(tlookup(s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pys	<genexpr>s(ttupleRRRRRfRRA(RR1ttypesR*tfilteredR.((R�s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pytconsumes&,N(Rwt
__module__t__doc__RBRsR R$tpropertyR%RR&R'R)R*R-R/R0R<R@RCRMR_RbRWRcR:RER~RR�(((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyR	s2
															
	
	
			(R8RQR5RRqRtt	six.movesRt
leapp.dialogsRtleapp.dialogs.rendererRtleapp.exceptionsRtleapp.messaging.answerstoreRtleapp.messaging.commandsRtleapp.modelsRRtleapp.utilsRtobjectR	(((s</usr/lib/python2.7/site-packages/leapp/messaging/__init__.pyt<module>s