%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/landscape/lib/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/testing.cpython-312.pyc

�

�~�e�a�
��ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddlm
Z
ddlmZddlmZddl
mZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddl m!Z!Gd�de	j,�Z"Gd�de	j,�Z#Gd�d�Z$Gd�de$�Z%Gd�de�Z&Gd�de�Z'Gd�de(�Z)Gd�d �Z*Gd!�d"�Z+Gd#�d$�Z,Gd%�d&�Z-Gd'�d(�Z.ddd)d*d*d*dddddgd+�fd,�Z/d9d-�Z0d.�Z1Gd/�d0�Z2Gd1�d2�Z3Gd3�d4�Z4Gd5�d6�Z5Gd7�d8e�Z6y):�N)�ERROR)�	Formatter)�Handler)�Deferred)�ConnectError)�
StringType)�Failure)�TestCase)�_PY3)�ConfigParser)�	cstringio)�stringio)�BaseConfiguration)�EventHandlingReactorMixin)�	LoginInfoc�*�eZdZes
ej
Zyy)�CompatTestCaseN)�__name__�
__module__�__qualname__rr
�assertItemsEqual�assertCountEqual���7/usr/lib/python3/dist-packages/landscape/lib/testing.pyrrs���#�4�4��rrc�,��eZdZgZ�fd�Z�fd�Z�xZS)�HelperTestCasec�:��t�|��g|_t|jvr |jjdt�d}|jD]A}|�}t
|d�r|j|�}|jj|��C|S)Nr�set_up)	�super�setUp�_helper_instances�LogKeeperHelper�helpers�insert�hasattrr�append)�self�result�helper_factory�helper�	__class__s    �rr!zHelperTestCase.setUp's����
��
��!#����$�,�,�.��L�L����?�3���"�l�l�	2�N�#�%�F��v�x�(����t�,���"�"�)�)�&�1�		2��
rc���t|j�D] }t|d�s�|j|��"t�|��y)N�	tear_down)�reversedr"r&r.r �tearDown)r(r+r,s  �rr0zHelperTestCase.tearDown7sB����t�5�5�6�	'�F��v�{�+�� � ��&�	'�	���r)rrrr$r!r0�
__classcell__�r,s@rrr#s����G�� �rrc�H�eZdZd�Z								dd�Zd�Z				dd�Zd	d�Zy)
�
FSTestCasec��t|d�5}|j�}ddd�|j|�y#1swY�xYw)N�rb)�open�read�assertEqual)r(�filename�expected_content�fd�actual_contents     r�assertFileContentzFSTestCase.assertFileContent@s?��
�(�D�
!�	'�R��W�W�Y�N�	'����)�>�:�	'�	'�s	�9�ANc	�����|�7|�tj�}tjj	||��nH��Ftj
|||�\}	�tj|	�|�tj��|�&t�|�5}
|
j|�ddd�|j|j���r��fd�}|j|��S#1swY�@xYw)a�Create a temporary file and return the path to it.

        @param content: Initial content for the file.
        @param suffix: Suffix to be given to the file's basename.
        @param prefix: Prefix to be given to the file's basename.
        @param basename: Full basename for the file.
        @param dirname: Put file inside this directory.

        The file is removed after the test runs.
        Nc�V��	tj��z�y#t$rYywxYw�N)�os�remove�OSError)�backupsuffix�paths��r�
remove_backupz*FSTestCase.makeFile.<locals>.remove_backupjs+�����I�I�d�\�1�2������s��	(�()�tempfile�mkdtemprBrF�join�mkstemp�close�unlinkr7�write�
addCleanup�_clean_file)r(�content�suffix�prefix�basename�dirnamerF�moderEr<�filerGs      ` `   r�makeFilezFSTestCase.makeFileEs����*����"�*�*�,���7�7�<�<���2�D�
�\��'�'����@�H�B���H�H�R�L����	�	�$�����d�D�!�
$�T��
�
�7�#�
$�����(�(�$�/��
�
�O�O�M�*���
$�
$�s�C#�#C,c��	tjj|�rtj|�ytj
|�y#t$rYywxYw)ztTry to remove a filesystem path, whether it's a directory or file.

        @param path: the path to remove
        N)rBrF�isdir�shutil�rmtreerMrD)r(rFs  rrPzFSTestCase._clean_filets@��
	��w�w�}�}�T�"��
�
�d�#��	�	�$����	��	�s�4A
�A
�
	A�Ac��|�tj|�ntj|||�}|j	|j
|�|S)a@Create a temporary directory and return the path to it.

        @param suffix: Suffix to be given to the file's basename.
        @param prefix: Prefix to be given to the file's basename.
        @param dirname: Put directory inside this parent directory.

        The directory is removed after the test runs.
        )rB�makedirsrHrIrOrP)r(rRrSrUrFs     r�makeDirzFSTestCase.makeDir�sC�����K�K����#�#�F�F�G�<�D�����(�(�$�/��rc��|�|j�}||_|j|||��}tj|d�|S)z=Return the path to the script after writing it to a temp dir.)rUrTi�)r_�bindirrXrB�chmod)r(�config�namerQrar:s      r�write_scriptzFSTestCase.write_script�s@���>��\�\�^�F���
��=�=��&�4�=�H��
����5�!��r)N��tmpNNN�wN)rfrgNNrA)rrrr>rXrPr_rerrrr4r4?sD��;������
�
��-�^����
��,rr4c�.��eZdZ�fd�Z�fd�Zd�Z�xZS)�ConfigTestCasec���t�|��tj|_|jd�gt_y�Nrf)r r!r�default_config_filenames�_old_config_filenamesrX�r(r,s �rr!zConfigTestCase.setUp�s/���
��
��%6�%O�%O��"�6:�m�m�B�6G�5H��2rc�L��|jt_t�|��yrA)rnrrmr r0ros �rr0zConfigTestCase.tearDown�s���59�5O�5O��2�
���rc	���t|�}t�}|j|�t|�}t�}|j|�|jt	|j��t	|j���|j�D]D}|jt
|j|��t
|j|����Fy)z�
        Compare two configuration files for equality.  The order of parameters
        and comments may be different but the actual parameters and sections
        must be the same.
        N)r
r�	read_filer9�set�sections�dict�items)r(�first�second�first_fp�first_parser�	second_fp�
second_parser�sections        r�assertConfigEqualz ConfigTestCase.assertConfigEqual�s����U�#��#�~�����x�(��f�%�	�$��
����	�*������%�%�'�(��
�&�&�(�)�	
�$�,�,�.�	�G�����\�'�'��0�1��]�(�(��1�2�
�	r)rrrr!r0r~r1r2s@rrjrj�s���I��
rrjc�,�eZdZd�Zd�Zd�Zd�Zdd�Zy)�TwistedTestCasec���g}|j|j�|s|jd|�d��yt|dt�r|jd|�d|d�d��y|dS)z�See C{twisted.trial._synctest._Assertions.successResultOf}.

        This is a copy of the original method, which is available only
        since Twisted 12.3.0 (from 2012-12-20).
        zSuccess result expected on �, found no result insteadrz, found failure result (�	) insteadN��addBothr'�fail�
isinstancer	�r(�deferredr)s   r�successResultOfzTwistedTestCase.successResultOf�s�����������'���I�I�-�h�\�:*�*�
���q�	�7�
+��I�I�-�h�\�:)�)/���
�Y�@�
�
�!�9�rc���g}|j|j�|s|jd|�d��yt|dt�s|jd|�d|d�d��y|dS)z�See C{twisted.trial._synctest._Assertions.failureResultOf}.

        This is a copy of the original method, which is available only
        since Twisted 12.3.0 (from 2012-12-20).
        zFailure result expected on r�rz, found success result (r�Nr�r�s   r�failureResultOfzTwistedTestCase.failureResultOf�s�����������'���I�I�-�h�\�:*�*�
��F�1�I�w�/��I�I�-�h�\�:)�)/���
�Y�@�
�
�!�9�rc�z�g}|j|j�|r|jd|�d|d�d��yy)z�See C{twisted.trial._synctest._Assertions.assertNoResult}.

        This is a copy of the original method, which is available only
        since Twisted 12.3.0 (from 2012-12-20).
        zNo result expected on z, found rz insteadN)r�r'r�r�s   r�assertNoResultzTwistedTestCase.assertNoResult�sK����������'���I�I�(���5����
�X�/�
�rc���|jt|t��g��fd�}|j|�|j��y)Nc�(���jd�y�NT)r')r)�calleds �r�callbackz9TwistedTestCase.assertDeferredSucceeded.<locals>.callbacks����M�M�$�r)�
assertTruer�r�addCallback)r(r�r�r�s   @r�assertDeferredSucceededz'TwistedTestCase.assertDeferredSucceeded�s<������
�8�X�6�7���	 �	���X�&�����rNc�x�|jt|t��|j|j|�S)zS
        Assert that the given C{deferred} results in the given C{result}.
        )r�r�rr�r9r�s   r�
assertSuccesszTwistedTestCase.assertSuccess	s0��	
���
�8�X�6�7��#�#�D�$4�$4�f�=�=rrA)rrrr�r�r�r�r�rrrr�r��s���*�*� �>rr�c��eZdZd�Zd�Zy)�ErrorHandlerc�D�tj|g|��i|��g|_yrA)r�__init__�errors)r(�args�kwargss   rr�zErrorHandler.__init__s!������/��/��/���rc�b�|jtk\r|jj|�yyrA)�levelnorr�r')r(�records  r�emitzErrorHandler.emits%���>�>�U�"��K�K���v�&�#rN)rrrr�r�rrrr�r�s���'rr�c��eZdZd�Zy)�LoggedErrorsErrorc�t�d}t�}|jdD]}||j|�dzz
}�|S)Nz!The following errors were logged
r�
)rr��format)r(�out�	formatter�errors    r�__str__zLoggedErrorsError.__str__sD��2���K�	��Y�Y�q�\�	2�E��9�#�#�E�*�T�1�1�C�	2��
rN)rrrr�rrrr�r�s��rr�c�"�eZdZdZd�Zd�Zd�Zy)r#z�Record logging information.

    Puts a 'logfile' attribute on your test case, which is a StringIO
    containing all log output.
    c���g|_g|_t�|_||_tj�x|_}t�|_	tj|j�}d}|jtj|��|j|_|j|_||jg|_
|j#t
j$�y)Nz%(levelname)8s: %(message)s)�ignored_exception_regexes�ignored_exception_typesr��
error_handler�
log_helper�logging�	getLogger�loggerr
�logfile�
StreamHandler�setFormatterr�handlers�old_handlers�level�	old_level�setLevel�NOTSET)r(�	test_caser��handlerr�s     rrzLogKeeperHelper.set_up+s���)+��&�')��$�)�^���#�	��$+�$5�$5�$7�7�	��6�%�K�	���'�'�	�(9�(9�:��.�����W�.�.�v�6�7�"�O�O��������"�D�$6�$6�7���������'rc���tj�}|j|j�|j|_g}|jjD]�}|jD]:}|js�|jds� t|jd|�s�:�K|jD]}|j|j�s��y|j|���|rt|��y�Nr)r�r�r�r�r�r�r�r�r��exc_info�
issubclassr��match�messager'r�)r(r�r�r�r��ignored_type�
ignored_regexs       rr.zLogKeeperHelper.tear_down:s����"�"�$��������'��+�+������(�(�/�/�
	*�F� $� <� <�
*���O�O�����*�"�6�?�?�1�#5�|�D��

*�&*�%C�%C�*�M�$�*�*�6�>�>�:��*��M�M�&�)�
	*��#�F�+�+�rc��t|t�r/|jjt	j
|��y|jj|�yrA)r�rr�r'�re�compiler�)r(�
type_or_regexs  r�
ignore_errorszLogKeeperHelper.ignore_errorsPs=���m�Z�0��*�*�1�1�"�*�*�]�2K�L��(�(�/�/�
�>rN)rrr�__doc__rr.r�rrrr#r#$s���
(�,�,?rr#c��eZdZd�Zd�Zy)�EnvironSnapshotc�J�tjj�|_yrA)rB�environ�copy�	_snapshot�r(s rr�zEnvironSnapshot.__init__Xs�������*��rc���tjj|j�t	tj�D]"}||jvs�tj|=�$yrA)rBr��updater��list)r(�keys  r�restorezEnvironSnapshot.restore[sG��
�
�
���$�.�.�)���
�
�#�	$�C��$�.�.�(��J�J�s�O�	$rN)rrrr�r�rrrr�r�Ws��+�$rr�c��eZdZd�Zd�Zy)�EnvironSaverHelperc�"�t�|_yrA)r�r��r(r�s  rrzEnvironSaverHelper.set_upcs��(�*��rc�8�|jj�yrA)r�r�r�s  rr.zEnvironSaverHelper.tear_downfs������� rN�rrrrr.rrrr�r�bs��+�!rr�c�B�eZdZdd�Zd	d�Zd	d�Zd�Zd
d�Zed��Z	y)�	MockPopenNc�j�||_||_t|�|_g|_||_d|_yrA)�output�err_outr
�stdout�popen_inputs�return_codes�received_input)r(r�r�r�s    rr�zMockPopen.__init__ks4����������'������(���"��rc�,�|j||||��S)N)�stdinr��stderr)�popen�r(r�r�r�r�s     r�__call__zMockPopen.__call__ss���z�z�$�e�F�6�z�J�Jrc�<�|jj|�|SrA)r�r'r�s     rr�zMockPopen.popenvs����� � ��&��rc��|jSrA)�
returncoder�s r�waitzMockPopen.waitzs�����rc�@�||_|j|jfSrA)r�r�r�)r(�inputs  r�communicatezMockPopen.communicate}s��#����{�{�D�L�L�(�(rc�R�|j�y|jjd�Sr�)r��popr�s rr�zMockPopen.returncode�s(�����$��� � �$�$�Q�'�'rrl)NNNrA)
rrrr�r�r�r�r��propertyr�rrrr�r�js0��#�K���)��(��(rr�c��eZdZd�Zd�Zy)�StandardIOHelperc���tj|_tj|_t�x|_t_t�x|_t_tsd|j_yy)NzUTF-8)�sysr��
old_stdoutr��	old_stdinrr�encodingr�s  rrzStandardIOHelper.set_up�sO��"�z�z�	��!�i�i�	��(0�
�2�	��3�:�&.�j�0�	��#�)��'.�I�O�O�$�rc�X�|jt_|jt_yrA)r�r�r�r�r�r�s  rr.zStandardIOHelper.tear_down�s���)�)��
��'�'��	rNr�rrrr�r��s��/�(rr�z/dev/rf)rrrrc
�|�t|d�}
	|
jtjtj
|||j
d�|j
d�|j
d�|j
d�|||	|
||d|d|d|dd��|
j�y#|
j�wxYw)	z3Append binary login data to the specified filename.�abzutf-8r���rN)r7rN�struct�packr�
RAW_FORMAT�encoderL)r:�
login_type�pid�
tty_device�id�username�hostname�termination_status�exit_status�
session_id�entry_time_seconds�entry_time_milliseconds�remote_ip_addressrWs              r�append_login_datar�s��� ��$��D���
�
��K�K��$�$����!�!�'�*��	�	�'�"�����(�����(�"���"�'�!�!�$�!�!�$�!�!�$�!�!�$��#
�	
�,	
�
�
����
�
��s�B
B)�)B;c#� K�	|��|dz
}�
�w)z>Generator starts at zero and yields integers that grow by one.rr)�is r�mock_counterr�s����
���	�Q����s�c��td�S)zCGenerator starts at 100 and yields int timestamps that grow by one.�d)rrrr�	mock_timer�s
�����rc�,�eZdZdZd�Zdidddddfd�Zy)�StubProcessFactoryzx
    A L{IReactorProcess} provider which records L{spawnProcess} calls and
    allows tests to get at the protocol.
    c��g|_yrA)�spawnsr�s rr�zStubProcessFactory.__init__�s	����rrNrc
�L�|jj|||||||||	f	�yrA)r!r')
r(�protocol�
executabler��envrF�uid�gid�usePTY�childFDss
          r�spawnProcesszStubProcessFactory.spawnProcess�s6��	
��������������

�	
r)rrrr�r�r*rrrrr�s(���
���
�����
rrc�"�eZdZdZd�Zd�Zd�Zy)�DummyProcessz/A process (transport) that doesn't do anything.c��g|_yrA)�signalsr�s rr�zDummyProcess.__init__�s	����rc�:�|jj|�yrA)r.r')r(�signals  r�
signalProcesszDummyProcess.signalProcess�s�������F�#rc��yrAr)r(r<s  r�closeChildFDzDummyProcess.closeChildFD�s��rN)rrrr�r�r1r3rrrr,r,�s��9��$�
rr,c�J�eZdZdZdZdZdZdZdZdZ	dZ
d	�Z					d
d�Zd�Z
y
)�ProcessDataBuilderzBuilder creates sample data for the process info plugin to consume.

    @param sample_dir: The directory for sample data.
    zR (running)zT (stopped)zT (tracing stop)zD (disk sleep)zS (sleeping)zX (dead)z
Z (zombie)c��||_yrA)�_sample_dir)r(�
sample_dirs  rr�zProcessDataBuilder.__init__s
��%��rNc
�T�d|dd�d|�d|d�d|d�d|	d�d	�}
tjj|jt	|��}tj
|�tjj|d
�}t
|d�}
	|
j|
�|
j�|�d|d��}tjj|d
�}t
|d�}
	|
j|�|
j�|rdj|��}
nd}
tjj|d�}t
|d�}
	|
j|
�|
j�y#|
j�wxYw#|
j�wxYw#|
j�wxYw)aCreates sample data for a process.

        @param started_after_boot: The amount of time, in jiffies,
            between the system uptime and start of the process.
        @param process_name: Used to generate the process name that appears in
            /proc/%(pid)s/status
        @param generate_cmd_line: If true, place the process_name in
            /proc/%(pid)s/cmdline, otherwise leave it empty (this simulates a
            kernel process)
        @param stat_data: Array of items to write to the /proc/<pid>/stat file.
        z	
Name:   N�z	
State:  zE
Tgid:   24759
Pid:    24759
PPid:   17238
TracerPid:      0
Uid:    �dz    0    0    0
Gid:    zk    0    0    0
FDSize: 256
Groups: 4 20 24 25 29 30 44 46 106 110 112 1000
VmPeak:    11680 kB
VmSize:    a� kB
VmLck:         0 kB
VmHWM:      6928 kB
VmRSS:      6924 kB
VmData:     1636 kB
VmStk:       196 kB
VmExe:      1332 kB
VmLib:      4240 kB
VmPTE:        20 kB
Threads:        1
SigQ:   0/4294967295
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000059816eff
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
�statuszw+z*0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 �statzA/usr/sbin/{process_name}--pid-file/var/run/{process_name}.pid
)�process_namerf�cmdline)
rBrFrJr7�str�mkdirr7rNrLr�)r(�
process_id�stater&r'�started_after_bootr>�generate_cmd_line�	stat_data�vmsize�sample_data�process_dirr:rWs              r�create_datazProcessDataBuilder.create_datas���0	�	�c�r�	��	�	��	�


�Q��	�	�Q���
�1�:����@�g�g�l�l�4�#3�#3�S��_�E��
������7�7�<�<��X�6���H�d�#��	��J�J�{�#��J�J�L���+�+=�a�*@��I��7�7�<�<��V�4���H�d�#��	��J�J�y�!��J�J�L���
�F�)���
��K��7�7�<�<��Y�7���H�d�#��	��J�J�{�#��J�J�L��7
�J�J�L��
�J�J�L�� 
�J�J�L�s$�E+�$F�	F�+E=�F�F'c��tjj|jt	|��}tj|�y)z>Remove sample data for the process that matches C{process_id}.N)rBrFrJr7r@r[r\)r(rBrIs   r�remove_datazProcessDataBuilder.remove_datals,���g�g�l�l�4�#3�#3�S��_�E���
�
�k�"r)rNTNi�-)rrrr��RUNNING�STOPPED�TRACING_STOP�
DISK_SLEEP�SLEEPING�DEAD�ZOMBIEr�rJrLrrrr5r5�sN���
�G��G�%�L�!�J��H��D�
�F�&������[�z#rr5c��eZdZd�Zy)�
FakeReactorIDc� �d|_||_yr�)�active�_data)r(�datas  rr�zFakeReactorID.__init__ss�������
rN)rrrr�rrrrUrUrs��rrUc���eZdZdZiZ�fd�Zd�Zd�Zd�Zd�Z	�fd�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�FakeReactorawA fake reactor with the same API of L{LandscapeReactor}.

    This reactor emulates the asychronous interface of L{LandscapeReactor}, but
    implementing it in a synchronous way, for easier unit-testing.

    Note that the C{listen_unix} method is *not* emulated, but rather inherited
    blindly from L{UnixReactorMixin}, this means that there's no way to control
    it in a synchronous way (see the docstring of the mixin). A better approach
    would be to fake the AMP transport (i.e. fake the twisted abstractions
    around Unix sockets), and implement a fake version C{listen_unix}, but this
    hasn't been done yet.
    c�t��t�|��d|_g|_i|_g|_ddlm}||_y)Nr)�reactor)	r r��
_current_time�_calls�hosts�_threaded_callbacks�twisted.internetr]�_reactor)r(r]r,s  �rr�zFakeReactor.__init__�s8���
������������
�#%�� �	-���
rc�,�t|j�SrA)�floatr^r�s r�timezFakeReactor.time�s���T�'�'�(�(rc�d�|j|z}||||f}|j|�t|�SrA)r^�_insort_callrU)r(�seconds�fr�r��scheduled_time�calls       r�
call_laterzFakeReactor.call_later�s9���+�+�g�5����4��0�����$���T�"�"rc��|jD�cgc]}|d��	}}tj||d�}|jj||�ycc}wr�)r_�bisect�bisect_leftr%)r(rl�c�times�indexs     rrhzFakeReactor._insort_call�sN�� $�{�{�+�!��1��+��+��"�"�5�$�q�'�2�������5�$�'��,s�Ac�N���������������fd���j�����S)Nc����j���j�_	��i���y#t$r�jr�j	���wxYwrA)rmrX�	ExceptionrW�cancel_call)r�rlrj�faker�rir(s�������rrxz$FakeReactor.call_every.<locals>.fake�sV�������$�7�=�=�D�J�
��4�"�6�"���
��;�;��$�$�T�*��
�s	�-�(A�rm)r(rirjr�r�rlrxs`````@@r�
call_everyzFakeReactor.call_every�s$���
	�
	����w��-���rc����t|�turE|j|jvr%|jj	|j�d|_yt�|�|�y�NF)�typerUrXr_rCrWr rw)r(rr,s  �rrwzFakeReactor.cancel_call�sI�����8�}�$��x�x�4�;�;�&����"�"�2�8�8�,��B�I��G���#rc�(�|jd|�yr�ry)r(rjs  r�call_when_runningzFakeReactor.call_when_running�s������1�rc�J����|jj���fd��y)z5Schedule a function for execution in the main thread.c�����i���SrAr)r�rjr�s���r�<lambda>z*FakeReactor.call_in_main.<locals>.<lambda>�s����4�0B�6�0B�rN)rar')r(rjr�r�s ```r�call_in_mainzFakeReactor.call_in_main�s���� � �'�'�(B�Crc�N�|j|||||�|j�y)asEmulate L{LandscapeReactor.call_in_thread} without spawning threads.

        Note that running threaded callbacks here doesn't reflect reality,
        since they're usually run while the main reactor loop is active. At
        the same time, this is convenient as it means we don't need to run
        the the real Twisted reactor with to test actions performed on
        completion of specific events (e.g. L{MessageExchange.exchange} uses
        call_in_thread to run the HTTP request in a separate thread, because
        we use libcurl which is blocking). IOW, it's easier to test things
        synchronously.
        N)�
_in_thread�_run_threaded_callbacks)r(r��errbackrjr�r�s      r�call_in_threadzFakeReactor.call_in_thread�s$��	
����'�1�d�F�;��$�$�&rc�L���G��fd�d�}|�j�<|�S)Nc���eZdZ��fd�Zy)�)FakeReactor.listen_unix.<locals>.FakePortc�<���jj��yrA)�
_socket_pathsr�)�oselfr(�socket_paths ��r�
stopListeningz7FakeReactor.listen_unix.<locals>.FakePort.stopListening�s����"�"�&�&�{�3rN)rrrr�)r(r�s��r�FakePortr��s���
4rr�)r�)r(r��factoryr�s``  r�listen_unixzFakeReactor.listen_unix�s'���	4�	4�+2����;�'��z�rc���|jj|�}ddlm}|r|||�}|j	�|St�}t
td��}|j||�|S)Nr)�
FakeConnectorzNo such file or directory)	r��get�landscape.lib.tests.test_ampr��connect�objectr	r�clientConnectionFailed)r(rFr��serverr��	connector�failures       r�connect_unixzFakeReactor.connect_unix�sm���#�#�'�'��-��>��%�g�v�6�I�����
����I��l�+F�G�H�G��*�*�9�g�>��rc���|jd�d|_|jr.|j|jdd�|jr�.|jd�y)zAContinuously advance this reactor until reactor.stop() is called.�runTr�stopN)�fire�_running�advancer_r�s rr�zFakeReactor.run�sJ���	�	�%����
��m�m��L�L����Q���*�+��m�m��	�	�&�rc��d|_yr|)r�r�s rr�zFakeReactor.stop�s	����
rc���|jr�|jdd|j|zkr{|jjd�}||d|jz
z}|d|_	|d|di|d��|jr#|jdd|j|zkr�{|xj|z
c_y#t$r}t	j
|�Yd}~�hd}~wwxYw)aHAdvance this reactor C{seconds} into the future.

        This method is not part of the L{LandscapeReactor} API and is specific
        to L{FakeReactor}. It's meant to be used only in unit tests for
        advancing time and triggering the relevant scheduled calls (see
        also C{call_later} and C{call_every}).
        rrrrN)r_r^r�rvr��	exception)r(rirl�es    rr�zFakeReactor.advance�s���
�K�K�D�K�K��N�1�-��1C�1C�g�1M�M��;�;�?�?�1�%�D�
�t�A�w��!3�!3�3�3�G�!%�a��D��
%���Q���a��,�D��G�,�
�K�K�D�K�K��N�1�-��1C�1C�g�1M�M�	
���g�%����
%��!�!�!�$�$��
%�s�*C�	C(�	C#�#C(c��	||i|��}|r|j||�yy#t$r[}tj�}|�#|jtj
||��n|j|g|���Yd}~yYd}~yd}~wwxYw)N)r�)r�rvr�r�r�r�)	r(r�r�rjr�r�r)r�r�s	         rr�zFakeReactor._in_threads���
	4���'��'�F���!�!�(�F�3����	6��|�|�~�H����!�!�'�-�-��X�!�F�!��!�!�'�5�H�5�5�G��	6�s� �	B�AA?�?Bc���|jr/	|jjd��|jr�.yy#t$r}tj|�Yd}~�2d}~wwxYwr�)rar�rvr�r�)r(r�s  rr�z#FakeReactor._run_threaded_callbackssW���&�&�
%�/��(�(�,�,�Q�/�1��&�&���
%��!�!�!�$�$��
%�s� =�	A%�A � A%c�J�|jd|j�}||_y)Ng�?)rzr��_run_threaded_callbacks_id)r(rs  r�_hook_threaded_callbacksz$FakeReactor._hook_threaded_callbacks%s ��
�_�_�S�$�">�">�
?��*,��'rc�:�|j|j�yrA)rwr�r�s r�_unhook_threaded_callbacksz&FakeReactor._unhook_threaded_callbacks)s������8�8�9r)rrrr�r�r�rfrmrhrzrwrr�r�r�r�r�r�r�r�r�r�r�r1r2s@rr[r[xsj���� �M� �)�#�(�� $��D�
'�����&�24�%�-�:rr[)r)7ror��os.pathrBr�r[rr�rH�unittestrrr�twisted.internet.deferr�twisted.internet.errorr�twisted.python.compatr�twisted.python.failurer	�twisted.trial.unittestr
�landscape.lib.compatrrr
r�landscape.lib.configr�landscape.lib.reactorr�landscape.lib.sysstatsrrrr4rjr�r�rvr�r#r�r�r�r�rrrrr,r5rUr[rrr�<module>r�sV��
���	�
�
�
������+�/�,�*�+�%�-�*�)�2�;�,�5�X�&�&�5��X�&�&��8_�_�D"�Z�"�JH>�h�H>�V'�7�'��	��0?�0?�f$�$�!�!�(�(�<(�(� �	��	�
�
������"�(�V��
!
�!
�H

�

�q#�q#�h��r:�+�r:r

Zerion Mini Shell 1.0