[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.119.19.219: ~ $
U

{�1`�)�@sdZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZzeWnek
r�eZYnXeZe�de�Gdd	�d	e�ZGd
d�dee�ZGdd
�d
ee�ZGdd�dee�ZGdd�d�Zddd�Z dd�Z!dd�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.cs(eZdZdZ�fdd�Zdd�Z�ZS)�DaemonRunnerErrorz3 Abstract base class for errors from DaemonRunner. cs|��t�j||�dS)N)�_chain_from_context�super�__init__)�self�args�kwargs��	__class__��>/opt/alt/python38/lib/python3.8/site-packages/daemon/runner.pyr2szDaemonRunnerError.__init__cCst|dd�dS)NT�Zas_cause�r�rrrrr7sz%DaemonRunnerError._chain_from_context)�__name__�
__module__�__qualname__�__doc__rr�
__classcell__rrrrr/src@seZdZdZdd�ZdS)�DaemonRunnerInvalidActionErrorz; Raised when specified action for DaemonRunner is invalid. cCst|dd�dS)NFrrrrrrr>sz2DaemonRunnerInvalidActionError._chain_from_contextN)rrrrrrrrrr;src@seZdZdZdS)�DaemonRunnerStartFailureErrorz, Raised when failure starting DaemonRunner. N�rrrrrrrrrCsrc@seZdZdZdS)�DaemonRunnerStopFailureErrorz, Raised when failure stopping DaemonRunner. Nr rrrrr!Gsr!c@sreZdZdZdZdd�Zdd�Zdd�Zdd
d�Zdd
�Z	dd�Z
dd�Zdd�Ze	eed�Z
dd�Zdd�Zd	S)�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}cCsN|��||_t�|_|�|�d|_|jdk	r@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_pathsrZpidfile_path�make_pidlockfileZpidfile_timeout�rr$rrrrXs

�zDaemonRunner.__init__cCs8t|jd�|j_t|jd�|j_t|jddd�|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`.
            Zrtzw+tr)�	bufferingN)�openZ
stdin_pathr%�stdinZstdout_path�stdoutZstderr_path�stderrr(rrrr&zs
�z0DaemonRunner._open_streams_from_app_stream_pathscCsHtj�|d�}d}d�|j���}dj||d�}t|�t�	|�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})�prognameZusageN)
�os�path�basename�join�action_funcs�keys�format�emit_message�sys�exit)r�argvr0Zusage_exit_codeZaction_usage�messagerrr�_usage_exit�s�zDaemonRunner._usage_exitNcCsP|dkrtj}d}t|�|kr(|�|�t|d�|_|j|jkrL|�|�dS)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.

            Nr.r)r9r;�lenr=r
�actionr5)rr;Zmin_argsrrrr#�s
zDaemonRunner.parse_argscCs|t|j�r|j��z|j��Wn,tjk
rNtdj|jd��}|�YnXt	�
�}|jj|d�}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_lockr%r*�lockfileZ
AlreadyLockedrr7r1�getpid�
start_messager8r$�run)r�errorr@r<rrr�_start�s

��
zDaemonRunner._startc
CsZ|j��}zt�|tj�Wn8tk
rT}ztdj||d��}|�W5d}~XYnXdS)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_pidr1�kill�signal�SIGTERM�OSErrorr!r7)rr@rIrGrrr�_terminate_daemon_process�s
��z&DaemonRunner._terminate_daemon_processcCsB|j��s tdj|jd��}|�t|j�r6|j��n|��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)rZ	is_lockedr!r7rArBrO)rrGrrr�_stop�s
��
zDaemonRunner._stopcCs|��|��dS)z Stop, then start.
            N)rPrHrrrr�_restart�szDaemonRunner._restart)�start�stopZrestartcCs@z|j|j}Wn*tk
r:tdj|jd��}|�YnX|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})r?)r5r?�KeyErrorrr7)r�funcrGrrr�_get_action_func�s��
zDaemonRunner._get_action_funccCs|��}||�dS)z� Perform the requested action.

            :return: ``None``.

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

            N)rV)rrUrrr�	do_actions	zDaemonRunner.do_action)N)rrrrrErr&r=r#rHrOrPrQr5rVrWrrrrr"Ks 
"
�r"cCs,|dkrtj}|�dj|d��|��dS)z@ Emit a message to the specified stream (default `sys.stderr`). Nz
{message}
)r<)r9r-�writer7�flush)r<�streamrrrr8sr8cCsNt|t�stdj|d��}|�tj�|�s>tdj|d��}|�t�||�}|S)z= Make a PIDLockFile instance with the given filesystem path. zNot a filesystem path: {path!r})r2zNot an absolute path: {path!r})	�
isinstancer	�
ValueErrorr7r1r2�isabsrZTimeoutPIDLockFile)r2Zacquire_timeoutrGrCrrrr'&s
��r'c
Cstd}|��}|dk	rpzt�|tj�WnHtk
r>d}Yn2tk
rn}z|jtjkr^d}W5d}~XYnX|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)	rJr1rKrL�SIG_DFL�ProcessLookupErrorrN�errnoZESRCH)r�resultZpidfile_pidrIrrrrA5s	rA)N)#rZ
__future__rrr`r1rLr9�warningsrC�rZdaemonrrr	r
r_�	NameError�NotImplemented�typeZ
__metaclass__�warn�DeprecationWarning�	Exceptionrr\r�RuntimeErrorrr!r"r8r'rArrrr�<module>
s6
�T


Filemanager

Name Type Size Permission Actions
__init__.cpython-38.opt-1.pyc File 1.13 KB 0644
__init__.cpython-38.pyc File 1.13 KB 0644
_metadata.cpython-38.opt-1.pyc File 3.64 KB 0644
_metadata.cpython-38.pyc File 3.64 KB 0644
daemon.cpython-38.opt-1.pyc File 33.11 KB 0644
daemon.cpython-38.pyc File 33.11 KB 0644
pidfile.cpython-38.opt-1.pyc File 1.91 KB 0644
pidfile.cpython-38.pyc File 1.91 KB 0644
runner.cpython-38.opt-1.pyc File 9.89 KB 0644
runner.cpython-38.pyc File 9.89 KB 0644