ok

Mini Shell

Direktori : /opt/imunify360/venv/lib64/python3.11/site-packages/daemon/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/daemon/__pycache__/runner.cpython-311.pyc

�

k��f�)��Z�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZ	en
#e$reZYnwxYweZejde��Gd�d	e��ZGd
�dee��ZGd�d
ee��ZGd�dee��ZGd�d��Zdd�Z d�Z!d�Z"dS)z Daemon runner library.
    �)�absolute_import�unicode_literalsN���pidfile)�0_chain_exception_from_existing_exception_context�
DaemonContext�
basestring�unicodeu@The ‘runner’ module is not a supported API for this library.c�(��eZdZdZ�fd�Zd�Z�xZS)�DaemonRunnerErrorz3 Abstract base class for errors from DaemonRunner. c�b��|���t��j|i|��dS�N)�_chain_from_context�super�__init__)�self�args�kwargs�	__class__s   ��m/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/daemon/runner.pyrzDaemonRunnerError.__init__2s7���� � �"�"�"������$�)�&�)�)�)�)�)�c�(�t|d���dS)NT��as_cause�r�rs rrz%DaemonRunnerError._chain_from_context7s��8���M�M�M�M�M�Mr)�__name__�
__module__�__qualname__�__doc__rr�
__classcell__)rs@rr
r
/sT�������=�=�*�*�*�*�*�
N�N�N�N�N�N�Nrr
c��eZdZdZd�ZdS)�DaemonRunnerInvalidActionErrorz; Raised when specified action for DaemonRunner is invalid. c�(�t|d���dS)NFrrrs rrz2DaemonRunnerInvalidActionError._chain_from_context>s��8���N�N�N�N�N�NrN)rrr r!r�rrr$r$;s.������E�E�O�O�O�O�Orr$c��eZdZdZdS)�DaemonRunnerStartFailureErrorz, Raised when failure starting DaemonRunner. N�rrr r!r&rrr(r(C�������6�6�6�6rr(c��eZdZdZdS)�DaemonRunnerStopFailureErrorz, Raised when failure stopping DaemonRunner. Nr)r&rrr,r,Gr*rr,c�`�eZdZdZdZd�Zd�Zd�Zdd�Zd�Z	d	�Z
d
�Zd�Ze	eed�Z
d
�Zd�ZdS)�DaemonRunnera4 Controller for a callable running in a separate background process.

        The first command-line argument is the action to take:

        * 'start': Become a daemon and call `app.run()`.
        * 'stop': Exit the daemon process specified in the PID file.
        * 'restart': Stop, then start.

        zstarted with pid {pid:d}c��|���||_t��|_|�|��d|_|j�t|j|j��|_|j|j_dS)a# Set up the parameters of a new runner.

            :param app: The application instance; see below.
            :return: ``None``.

            The `app` argument must have the following attributes:

            * `stdin_path`, `stdout_path`, `stderr_path`: Filesystem paths
              to open and replace the existing `sys.stdin`, `sys.stdout`,
              `sys.stderr`.

            * `pidfile_path`: Absolute filesystem path to a file that will
              be used as the PID file for the daemon. If ``None``, no PID
              file will be used.

            * `pidfile_timeout`: Used as the default acquisition timeout
              value supplied to the runner's PID lock file.

            * `run`: Callable that will be invoked when the daemon is
              started.

            N)	�
parse_args�appr	�daemon_context�#_open_streams_from_app_stream_pathsr�pidfile_path�make_pidlockfile�pidfile_timeout�rr1s  rrzDaemonRunner.__init__Xsz��.	
���������+�o�o����0�0��5�5�5������'�+��$�c�&9�;�;�D�L�&*�l���#�#�#rc���t|jd��|j_t|jd��|j_t|jdd���|j_dS)ab Open the `daemon_context` streams from the paths specified.

            :param app: The application instance.

            Open the `daemon_context` standard streams (`stdin`,
            `stdout`, `stderr`) as stream objects of the appropriate
            types, from each of the corresponding filesystem paths
            from the `app`.
            �rtzw+tr)�	bufferingN)�open�
stdin_pathr2�stdin�stdout_path�stdout�stderr_path�stderrr7s  rr3z0DaemonRunner._open_streams_from_app_stream_pathszs[��%)����$>�$>���!�%)�#�/�5�%A�%A���"�%)����!�&5�&5�&5���"�"�"rc� �tj�|d��}d}d�|j�����}d�||���}t|��tj	|��dS)z� Emit a usage message, then exit.

            :param argv: The command-line arguments used to invoke the
                program, as a sequence of strings.
            :return: ``None``.

            r��|zusage: {progname} {usage})�progname�usageN)
�os�path�basename�join�action_funcs�keys�format�emit_message�sys�exit)r�argvrE�usage_exit_code�action_usage�messages      r�_usage_exitzDaemonRunner._usage_exit�s����7�#�#�D��G�,�,�����x�x�� 1� 6� 6� 8� 8�9�9��-�4�4�!��5�7�7���W�������!�!�!�!�!rNc���|�tj}d}t|��|kr|�|��t	|d��|_|j|jvr|�|��dSdS)a� Parse command-line arguments.

            :param argv: The command-line arguments used to invoke the
                program, as a sequence of strings.

            :return: ``None``.

            The parser expects the first argument as the program name, the
            second argument as the action to perform.

            If the parser fails to parse the arguments, emit a usage
            message and exit the program.

            NrCr)rOrQ�lenrUr�actionrK)rrQ�min_argss   rr0zDaemonRunner.parse_args�s���<��8�D����t�9�9�x������T�"�"�"��d�1�g�&�&����;�d�/�/�/����T�"�"�"�"�"�0�/rc��t|j��r|j���	|j���n=#t
j$r+td�|j�����}|�wxYwtj
��}|j�|���}t|��|j
���dS)z� Open the daemon context and run the application.

            :return: ``None``.
            :raises DaemonRunnerStartFailureError: If the PID file cannot
                be locked by this process.

            z(PID file {pidfile.path!r} already lockedr)�pidN)�is_pidfile_staler�
break_lockr2r;�lockfile�
AlreadyLockedr(rMrG�getpid�
start_messagerNr1�run)r�errorr[rTs    r�_startzDaemonRunner._start�s����D�L�)�)�	&��L�#�#�%�%�%�	���$�$�&�&�&�&���%�	�	�	�1�>�E�E� $��F�.�.�/�/�E��K�		�����i�k�k���$�+�+��+�4�4���W������������s�A	�	:Bc���|j���}	tj|tj��dS#t$r+}td�||�����}|�d}~wwxYw)z� Terminate the daemon process specified in the current PID file.

            :return: ``None``.
            :raises DaemonRunnerStopFailureError: If terminating the daemon
                fails with an OS error.

            z"Failed to terminate {pid:d}: {exc})r[�excN)	r�read_pidrG�kill�signal�SIGTERM�OSErrorr,rM)rr[rfrcs    r�_terminate_daemon_processz&DaemonRunner._terminate_daemon_process�s����l�#�#�%�%��	��G�C���(�(�(�(�(���	�	�	�0�8�?�?��S�@�*�*�+�+�E��K�����		���s�<�
A1�&A,�,A1c��|j���s*td�|j�����}|�t	|j��r|j���dS|���dS)z� Exit the daemon process specified in the current PID file.

            :return: ``None``.
            :raises DaemonRunnerStopFailureError: If the PID file is not
                already locked.

            z$PID file {pidfile.path!r} not lockedrN)r�	is_lockedr,rMr\r]rl)rrcs  r�_stopzDaemonRunner._stop�s����|�%�%�'�'�	�0�:�A�A� $��B�.�.�/�/�E��K��D�L�)�)�	-��L�#�#�%�%�%�%�%��*�*�,�,�,�,�,rc�V�|���|���dS)z Stop, then start.
            N)rordrs r�_restartzDaemonRunner._restart�s"��	
�
�
�������
�
�
�
�
r)�start�stop�restartc��	|j|j}n8#t$r+td�|j�����}|�wxYw|S)ae Get the function for the specified action.

            :return: The function object corresponding to the specified
                action.
            :raises DaemonRunnerInvalidActionError: if the action is
               unknown.

            The action is specified by the `action` attribute, which is set
            during `parse_args`.

            zUnknown action: {action!r})rX)rKrX�KeyErrorr$rM)r�funcrcs   r�_get_action_funczDaemonRunner._get_action_func�sm��	��$�T�[�1�D�D���	�	�	�2�0�7�7�#�{�8�,�,�-�-�E��K�		����
�s	��5A
c�D�|���}||��dS)z� Perform the requested action.

            :return: ``None``.

            The action is specified by the `action` attribute, which is set
            during `parse_args`.

            N)rx)rrws  r�	do_actionzDaemonRunner.do_actions&���$�$�&�&����T�
�
�
�
�
rr)rrr r!rarr3rUr0rdrlrorqrKrxrzr&rrr.r.Ks���������/�M� 3� 3� 3�D
5�
5�
5�"�"�"� #�#�#�#�4���2���"-�-�-�&��������L����*
�
�
�
�
rr.c��|�tj}|�d�|�����|���dS)z@ Emit a message to the specified stream (default `sys.stderr`). Nz
{message}
)rT)rOrA�writerM�flush)rT�streams  rrNrNsB��
�~����
�L�L��%�%�g�%�6�6�7�7�7�
�L�L�N�N�N�N�Nrc�,�t|t��s%td�|�����}|�tj�|��s%td�|�����}|�tj||��}|S)z= Make a PIDLockFile instance with the given filesystem path. zNot a filesystem path: {path!r})rHzNot an absolute path: {path!r})	�
isinstancer
�
ValueErrorrMrGrH�isabsr�TimeoutPIDLockFile)rH�acquire_timeoutrcr^s    rr5r5&s����d�J�'�'���<�C�C��D��������
�7�=�=������;�B�B��C���������)�$��@�@�H��Orc���d}|j��}|�\	tj|tj��n;#t
$rd}Yn-t$r!}|jtjkrd}Yd}~nd}~wwxYw|S)u� Determine whether a PID file is stale.

        :return: ``True`` iff the PID file is stale; otherwise ``False``.

        The PID file is “stale” if its contents are valid but do not
        match the PID of a currently-running process.

        FNT)	rgrGrhri�SIG_DFL�ProcessLookupErrorrk�errno�ESRCH)r�result�pidfile_pidrfs    rr\r\5s����F�"�'�"�$�$�K���		��G�K���0�0�0�0��!�	�	�	��F�F�F��	�	�	��y�E�K�'�'������������		�����Ms�5�A-�	A-�A(�(A-r)#r!�
__future__rrr�rGrirO�warningsr^�r�daemonrr	r
rr��	NameError�NotImplemented�type�
__metaclass__�warn�DeprecationWarning�	Exceptionr
r�r$�RuntimeErrorr(r,r.rNr5r\r&rr�<module>r�s5����;�:�:�:�:�:�:�:�����	�	�	�	�
�
�
�
�
�
�
�
���������������������������(������(�(�(�'����(�����
���
�J�����
	N�	N�	N�	N�	N�	�	N�	N�	N�O�O�O�O�O�%6�
�O�O�O�7�7�7�7�7�$5�|�7�7�7�7�7�7�7�7�#4�l�7�7�7�P�P�P�P�P�P�P�P�f�����������s�9�A�A

Zerion Mini Shell 1.0