[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.219.227.70: ~ $


^�V�&�
@s`dZddlmZmZddlZddlZddlZddlZyeWne	k
rne
ZYnXddlZddlm
Z
ddlmZmZddlmZddlmZGd	d
�d
e�ZGdd�dee�ZGd
d�dee�ZGdd�dee�ZGdd�d�Zddd�Zdd�Zdd�ZdS)z Daemon runner library.
    �)�absolute_import�unicode_literalsN�)�pidfile)�
basestring�unicode)�
DaemonContext)�0_chain_exception_from_existing_exception_contextcs4eZdZdZ�fdd�Zdd�Z�S)�DaemonRunnerErrorz3 Abstract base class for errors from DaemonRunner. cs'|j�tt|�j||�dS)N)�_chain_from_context�superr
�__init__)�self�args�kwargs)�	__class__��
/runner.pyr
,s
zDaemonRunnerError.__init__cCst|dd�dS)N�as_causeT)r	)rrrrr1sz%DaemonRunnerError._chain_from_context)�__name__�
__module__�__qualname__�__doc__r
rrr)rrr
)sr
c@s"eZdZdZdd�ZdS)�DaemonRunnerInvalidActionErrorz; Raised when specified action for DaemonRunner is invalid. cCst|dd�dS)NrF)r	)rrrrr8sz2DaemonRunnerInvalidActionError._chain_from_contextN)rrrrrrrrrr5src@seZdZdZdS)�DaemonRunnerStartFailureErrorz, Raised when failure starting DaemonRunner. N)rrrrrrrrr=src@seZdZdZdS)�DaemonRunnerStopFailureErrorz, Raised when failure stopping DaemonRunner. N)rrrrrrrrrAsrc@s�eZdZdZeZdZdd�Zdd�Zddd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
de
dede
iZdd�Zdd�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}cCs�|j�||_t�|_t|jd�|j_t|jd�|j_t|j	ddd�|j_
d|_|jdk	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.

            Zrtzw+t�	bufferingrN)�
parse_args�appr�daemon_context�openZ
stdin_path�stdinZstdout_path�stdoutZstderr_path�stderrrZpidfile_path�make_pidlockfileZpidfile_timeout)rrrrrr
Ts
		zDaemonRunner.__init__cCsgtjj|d�}d}dj|jj��}djd|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�argvr(Zusage_exit_codeZaction_usage�messagerrr�_usage_exitys	
zDaemonRunner._usage_exitNcCsp|dkrtj}d}t|�|kr:|j|�t|d�|_|j|jkrl|j|�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)r2r4�lenr6r�actionr.)rr4Zmin_argsrrrr�s	
zDaemonRunner.parse_argscCs�t|j�r|jj�y|jj�Wn6tjk
retdjd|j��}|�YnXt	j
�}|jjd|�}t|�|j
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
AlreadyLockedrr0r*�getpid�
start_messager1r�run)r�errorr9r5rrr�_start�s
	
zDaemonRunner._startcCsv|jj�}ytj|tj�WnItk
rq}z)tdjd|d|��}|�WYdd}~XnXdS)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}r9�excN)	r�read_pidr*�kill�signal�SIGTERM�OSErrorrr0)rr9rBr@rrr�_terminate_daemon_process�s	z&DaemonRunner._terminate_daemon_processcCs]|jj�s0tdjd|j��}|�t|j�rO|jj�n
|j�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_lockedrr0r:r;rH)rr@rrr�_stop�s	zDaemonRunner._stopcCs|j�|j�dS)z Stop, then start.
            N)rIrA)rrrr�_restart�s
zDaemonRunner._restart�start�stopZrestartcCsNy|j|j}Wn3tk
rItdjd|j��}|�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}r8)r.r8�KeyErrorrr0)r�funcr@rrr�_get_action_func�s
	zDaemonRunner._get_action_funccCs|j�}||�dS)z� Perform the requested action.

            :return: ``None``.

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

            N)rO)rrNrrr�	do_actions	zDaemonRunner.do_action)rrrr�typeZ
__metaclass__r>r
r6rrArHrIrJr.rOrPrrrrrEs	%rcCs<|dkrtj}|jdjd|��|j�dS)z@ Emit a message to the specified stream (default `sys.stderr`). Nz
{message}
r5)r2r$�writer0�flush)r5�streamrrrr1s	r1cCsst|t�s-tdjd|��}|�tjj|�s]tdjd|��}|�tj||�}|S)z= Make a PIDLockFile instance with the given filesystem path. zNot a filesystem path: {path!r}r+zNot an absolute path: {path!r})	�
isinstancer�
ValueErrorr0r*r+�isabsrZTimeoutPIDLockFile)r+Zacquire_timeoutr@r<rrrr%sr%cCs�d}|j�}|dk	r�ytj|tj�WnTtk
rOd}Yn=tk
r�}z|jtjkryd}WYdd}~XnX|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)	rCr*rDrE�SIG_DFL�ProcessLookupErrorrG�errnoZESRCH)r�resultZpidfile_pidrBrrrr:%s	

r:)rZ
__future__rrr2r*rErZrY�	NameError�NotImplementedr<�r�daemonrrrr	�	Exceptionr
rVr�RuntimeErrorrrrr1r%r:rrrr�<module>s,
�

Filemanager

Name Type Size Permission Actions
__init__.cpython-35.opt-1.pyc File 1.07 KB 0644
__init__.cpython-35.pyc File 1.07 KB 0644
_metadata.cpython-35.opt-1.pyc File 3.89 KB 0644
_metadata.cpython-35.pyc File 3.89 KB 0644
daemon.cpython-35.opt-1.pyc File 30.05 KB 0644
daemon.cpython-35.pyc File 30.05 KB 0644
pidfile.cpython-35.opt-1.pyc File 1.89 KB 0644
pidfile.cpython-35.pyc File 1.89 KB 0644
runner.cpython-35.opt-1.pyc File 9.57 KB 0644
runner.cpython-35.pyc File 9.57 KB 0644