OwlCyberSecurity - MANAGER
Edit File: popen.cpython-311.pyc
� ������h�'�����������������������v����d�dl�Z�d�dlmZmZmZ�d�dlmZ�d�dlmZm Z �d�dl mZmZ�d�dl mZ�d�dlmZ�d�dlmZmZmZmZmZmZmZ�d d lmZmZmZ�eeef���������Z eeee���������f���������Z!de!defd �Z"�G�d��de#������������Z$defd�Z%�G�d��de#������������Z&�G�d��de#������������Z'dZ(�ee(e'j)��������e'j*��������g�������������dS�)�����N)�wraps�partial�reduce)� TextIOWrapper)�chain�zip_longest)�STDOUT�PIPE)� TemporaryFile)�extend_docstring)�Union�Callable�List�Optional�Sequence�Tuple�Dict����)�Mock�call�_Call�command�returnc������������������n�����t����������|�t����������������������sd���������������������d��|�D���������������������������}�|�S�)N� c��������������3����>���K����|�]}t����������j��������|������������V����d�S��N)�pipes�quote)�.0�parts��� �c/builddir/build/BUILD/cloudlinux-venv-1.0.8/venv/lib/python3.11/site-packages/testfixtures/popen.py� <genexpr>zshell_join.<locals>.<genexpr>���s,����������A�A��5�;�t�,�,�A�A�A�A�A�A�����)� isinstance�str�join)r���s��� r"���� shell_joinr(������s:�������g�s�#�#��B��(�(�A�A��A�A�A�A�A���Nr$���c��������������������:�����e�Zd�ZdZ � � � � �d dededed ed ef d�ZdS�)�PopenBehaviourzp An object representing the behaviour of a :class:`MockPopen` when simulating a particular command. r$���r������������stdout�stderr� returncode�pid� poll_countc������������������L�����||�_���������||�_��������||�_��������||�_��������||�_��������d�S�r���)r-���r.���r/���r0���r1���)�selfr-���r.���r/���r0���r1���s��� r"����__init__zPopenBehaviour.__init__���s+�������������$������$����r$���N)r$���r$���r���r+���r,���)�__name__� __module__�__qualname__�__doc__�bytes�intr4�����r$���r"���r*���r*������sx������������������ ����� %��%��%���%��� %� ��%��� %��%��%��%��%��%r$���r*���c������������������<�������t��������������������������fd���������������}|S�)Nc������������������J�������|�j����������j��������fg|�R�i�|�����|�g|�R�i�|��S�r���)�_recordr5���)r3����args�kw�funcs��� �r"����recorderzrecord.<locals>.recorder,���sJ����������d�m�%�3��3�3�3��3�3�3��t�D�&�4�&�&�&�2�&�&�&r$���)r���)rA���rB���s���` r"����recordrC���+���s3������� �4�[�[�'��'��'��'���[�'���Or$���c������������ ��������6����e�Zd�ZU�dZdZeed<���dZeed<���dZ eed<��� � � � � � � �dd �Z d��Zd��Zd ��Z eddedefd���������������Zeddededeeef���������fd���������������Zedee���������fd���������������Zededdfd���������������Zedd���������������Zedd���������������ZdS�)�MockPopenInstancez; A mock process as returned by :class:`MockPopen`. N�stdinr-���r.���r���FTr;���c������������������h����t������������������������|�_��������|j��������j��������|�_��������||�_��������g�|�_��������|j��������|�_��������t����������|������������}|j��������� ��������������������||j ��������������������}|�t����������d|z���������������t����������|������������r �|||�������������}||�_ ��������|j��������}|j��������}|t ����������k����rit#����������j��������t'����������|���������������������d������������|���������������������d������������������������������������}d���������������������d��|D���������������������������}d�}|j��������|�_��������d||fd||ffD�]�\��}}}d�}|t.����������u�rdt1������������������������}|���������������������|�������������|������������������������������������|���������������������d�������������|s|s|rt9����������|||� ������������}t;����������|�||���������������|t.����������k����rIt������������������������|�_��������d D�]3} t?����������|�j ��������d| f������������}!|!tC����������|�j��������| ������������_"���������4|j#��������|�_#��������d�|�_$��������||�_%��������d�S�)Nz Nothing specified for command %r)r���rF���Tr$���c��������������3�������K����|�]}|�|V���� d�S�r���r;���)r ����ls��� r"���r#���z-MockPopenInstance.__init__.<locals>.<genexpr>i���s'����������#B�#B�!��#B�A�#B�#B�#B�#B�#B�#Br$���r-���r.���r���)�encoding�errors)�write�closerF���)&r����mock�Popen_instance�class_instance_mock� root_call�calls� all_callsr(����commands�get�default_behaviour�KeyError�callable� behaviourr-���r.���r ���r���� from_iterabler���� splitlinesr'���r1���r ���r���rL����flush�seekr����setattrrF���r���r>����getattr�side_effectr0���r/���r?���)"r3���� mock_classrQ���r?����bufsize� executablerF���r-���r.���� preexec_fn� close_fds�shell�cwd�env�universal_newlines�startupinfo� creationflags�restore_signals�start_new_session�pass_fdsrJ���rK����text�cmdrY����stdout_value�stderr_value� line_iterator�name�option� mock_value�value�method� record_writess"��� r"���r4���zMockPopenInstance.__init__D���sS�������&�&�� �)3��)G�� �� )����"$�� �%/�%9���������'�+�+�C��1M�N�N� ����=��C�D�D�D��I���� <�!� �#�U�;�;�;�I�)2��� �'�� �'���V���!�/���'�'��-�-��'�'��-�-�1��1�����M���8�8�#B�#B�}�#B�#B�#B�B�B�L��L�(�3��� �v�|�,� �v�|�,�) �� '�� '�$�D�&�*���E���~�~�%�������J�'�'�'���� � � �� � �1� � � �%��S���S���S�)�%�(�6�R�R�R�E��D�$��&�&�&�&��D�=�=����D�J�*�� H�� H�� '���w��6G� H� H� �:G��� �F�+�+�7�7�!� ���)-���!�� � � r$���c����������� �����������|�j���������|�j��������fD�]}�t����������t����������||������������|i�|����t����������|�j��������f|�j��������|�j��������ffD�]4\��}}|����������������������t����������t����������||������������|i�|����������������5d�S�r���) rP���rN���r���r_���r���rR���rQ���rS����append)r3����namesr?���r@���rN���� base_call�stores��� r"���r>���zMockPopenInstance._record����s��������,�d�i�7�� 6�� 6�D�(�F�7�E�4�(�(�$�5�"�5�5�5�5� �4�:�� �^�T�^�,�! �� I�� I��I�u�� �L�L�:���� �:�:�D�G�B�G�G�H�H�H�H� I�� Ir$���c�����������������������|�S�r���r;����r3���s��� r"���� __enter__zMockPopenInstance.__enter__����s�������r$���c������������������|�����|��������������������������������������|�j��������|�j��������fD�]}|r|�������������������������������������d�S�r���)�waitr-���r.���rM���)r3����exc_type�exc_val�exc_tb�streams��� r"����__exit__zMockPopenInstance.__exit__����sG������� � �����k�4�;�.�� �� �F��� �������� �� r$����timeoutr���c������������������2�����|�j���������j��������|�_��������|�j��������S�)z/Simulate calls to :meth:`subprocess.Popen.wait`)rY���r/���)r3���r����s��� r"���r����zMockPopenInstance.wait����s��������.�3�����r$����inputc�����������������������|�j���������j��������|�_��������|�j��������o|�j�������������������������������������������|�j��������o|�j�������������������������������������������fS�)z6Simulate calls to :meth:`subprocess.Popen.communicate`)rY���r/���r-����readr.���)r3���r����r����s��� r"����communicatezMockPopenInstance.communicate����sJ��������.�3�����2��� 0� 0� 2� 2���2��� 0� 0� 2� 2�4�� 4r$���c������������������r�����|�j���������r|�j���������|�xj���������dz��c_���������dS�|�j��������j��������|�_��������|�j��������S�)z/Simulate calls to :meth:`subprocess.Popen.poll`Nr���)r1���r/���rY���r����s��� r"����pollzMockPopenInstance.poll����s@��������o�� �$�/�"9��O�O�q� �O�O��4� ��.�3�����r$����signalc�����������������������dS�)z6Simulate calls to :meth:`subprocess.Popen.send_signal`Nr;���)r3���r����s��� r"����send_signalzMockPopenInstance.send_signal����� ������� �r$���c�����������������������dS�)z4Simulate calls to :meth:`subprocess.Popen.terminate`Nr;���r����s��� r"���� terminatezMockPopenInstance.terminate����r����r$���c�����������������������dS�)z/Simulate calls to :meth:`subprocess.Popen.kill`Nr;���r����s��� r"����killzMockPopenInstance.kill����r����r$���)r���NNNNNFFNNFNr���TFr;���NNNr���)NN)r���N)r5���r6���r7���r8���rF���r����__annotations__r-���r���r.���r4���r>���r����r����rC����floatr:���r�����AnyStrr���r����r���r����r����r����r����r;���r$���r"���rE���rE���3���s���������������������E�4�����!�F�M� � � ��!�F�M� � � ��.2�15�DH�.3�DH�35�26�@"��@"��@"��@"�DI��I��I����������������E���S���������V�� ��4��4���4���4�%�PV�X^�P^�J_��4��4��4���V�4��� �h�s�m�� �� �� ���V� ��� �#�� �$�� �� �� ���V� ��� �� �� ���V� ��� �� �� ���V� �� �� r$���rE���c�������������������������e�Zd�ZU�dZdZeed<���d��Zd��Z � � � � � �dd e de de d edededeee f���������fd�Z � �dd�Zd��ZdS�)� MockPopena�� A specialised mock for testing use of :class:`subprocess.Popen`. An instance of this class can be used in place of the :class:`subprocess.Popen` and is often inserted where it's needed using :func:`unittest.mock.patch` or a :class:`~testfixtures.Replacer`. NrV���c������������������H�����i�|�_���������t������������������������|�_��������g�|�_��������d�S�r���)rT���r���rN���rS���r����s��� r"���r4���zMockPopen.__init__����s!������35�� ��&�&�� ��&(����r$���c������������������0�����|�t����������|||||������������S�|S�r���)r*����r3���r-���r.���r/���r0���r1���rY���s��� r"����_resolve_behaviourzMockPopen._resolve_behaviour����s-��������!��� �C������ ���r$���r$���r���r+���r,���r���r-���r.���r/���r0���r1���rY���c������������������d�����|�����������������������||||||������������|�j��������t����������|������������<���dS�)z� Set the behaviour of this mock when it is used to simulate the specified command. :param command: A :class:`str` representing the command to be simulated. N)r����rT���r(���)r3���r���r-���r.���r/���r0���r1���rY���s��� r"����set_commandzMockPopen.set_command����s;������ �.2�-D�-D��F�J��Z��. ��. �� �j��)�)�*�*�*r$���c������������������D�����|�����������������������||||||������������|�_��������dS�)z� Set the behaviour of this mock when it is used to simulate commands that have no explicit behavior specified using :meth:`~MockPopen.set_command`. N)r����rV���r����s��� r"����set_defaultzMockPopen.set_default����s/�������"&�!8�!8��F�J��Z��" ��" ����r$���c������������������������|�j���������j��������|i�|���t����������j��������|i�|��}|�j�����������������������������|�������������t����������|�|g|�R�i�|��S�r���)rN����Popenr���rS���r{���rE���)r3���r?���r@���rQ���s��� r"����__call__zMockPopen.__call__����se�������� ���$��$�$�$��J��+��+�+� �����i�(�(�(� ��y�>�4�>�>�>�2�>�>�>r$���)r$���r$���r���r+���r,���N)r5���r6���r7���r8���rV���r*���r����r4���r����r&���r9���r:���r ���r���r����r����r����r;���r$���r"���r����r��������s���������������������)-��~�,�,�,�(��(��(������� �����9=� �� �� ��� ��� � �� ��� ��� ���^�X�5�6� �� �� �� �(�>?�6:� �� �� �� �?��?��?��?��?r$���r����a��� :param stdout: :class:`bytes` representing the simulated content written by the process to the stdout pipe. :param stderr: :class:`bytes` representing the simulated content written by the process to the stderr pipe. :param returncode: An integer representing the return code of the simulated process. :param pid: An integer representing the process identifier of the simulated process. This is useful if you have code the prints out the pids of running processes. :param poll_count: Specifies the number of times :meth:`~MockPopenInstance.poll` can be called before :attr:`~MockPopenInstance.returncode` is set and returned by :meth:`~MockPopenInstance.poll`. If supplied, ``behaviour`` must be either a :class:`PopenBehaviour` instance or a callable that takes the ``command`` string representing the command to be simulated and the ``stdin`` supplied when instantiating the :class:`subprocess.Popen` with that command and should return a :class:`PopenBehaviour` instance. )+r���� functoolsr���r���r����ior���� itertoolsr���r���� subprocessr ���r ����tempfiler����testfixtures.utilsr����typingr ���r���r���r���r���r���r���rN���r���r���r����Callr&���r9���r�����Commandr(����objectr*���rC���rE���r�����set_command_paramsr����r����r;���r$���r"����<module>r�������s ����������,��,��,��,��,��,��,��,��,��,��������������(��(��(��(��(��(��(��(��#��#��#��#��#��#��#��#��"��"��"��"��"��"��/��/��/��/��/��/��I��I��I��I��I��I��I��I��I��I��I��I��I��I��I��I��I��I��+��+��+��+��+��+��+��+��+��+�� �s�E�z� �� ��X�c�]�"� #������C���������%��%��%��%��%�V��%��%��%�*�H���������L ��L ��L ��L ��L ���L ��L ��L �^=?��=?��=?��=?��=?���=?��=?��=?�@���6����#��'��)>�?�A��A��A��A��Ar$���