U
    ˆj  ã                   @   sd   d dl Z d dlZd dlmZ d dlmZmZmZ d dlm	Z	 G dd„ dej
ƒZ
G dd„ dejƒZdS )	é    N)Ú	copyright)ÚappÚinternetÚservice)Úlogc                   @   s$   e Zd ZdZdddggZdd„ ZdS )ÚServerOptionszUsage: twistd [options]ZnodaemonÚnz(for backwards compatibility).c                 C   s2   t dtj› �| jd� t tj| jd� t ¡  dS )z5
        Print version information and exit.
        z$twistd (the Twisted Windows runner) )ÚfileN)Úprintr   ÚversionÚstdoutÚsysÚexit©Úself© r   ú;/tmp/pip-unpacked-wheel-j5h_c8_q/twisted/scripts/_twistw.pyÚopt_version   s    
þzServerOptions.opt_versionN)Ú__name__Ú
__module__Ú__qualname__ZsynopsisZoptFlagsr   r   r   r   r   r      s   ÿr   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚWindowsApplicationRunnerzn
    An ApplicationRunner which avoids unix-specific things. No
    forking, no PID files, no privileges.
    c                 C   s$   t j| _t j| _t | jd ¡ dS )z4
        Do pre-application-creation setup.
        ZrundirN)r   r   Ú	oldstdoutÚstderrÚ	oldstderrÚosÚchdirÚconfigr   r   r   r   ÚpreApplication'   s    z'WindowsApplicationRunner.preApplicationc                 C   s^   t  | j¡ ¡  t | j| jd  ¡ t t ddd„ ¡d¡ |  	d| j
| j¡ t d¡ dS )z<
        Start the application and run the reactor.
        Zno_savegš™™™™™¹?c                   S   s   d S )Nr   r   r   r   r   Ú<lambda>5   ó    z:WindowsApplicationRunner.postApplication.<locals>.<lambda>r   NzServer Shut Down.)r   ZIServiceZapplicationZprivilegedStartServicer   ZstartApplicationr   r   ZTimerServiceZstartReactorr   r   r   Úmsgr   r   r   r   ÚpostApplication/   s
    z(WindowsApplicationRunner.postApplicationN)r   r   r   Ú__doc__r   r"   r   r   r   r   r   !   s   r   )r   r   Ztwistedr   Ztwisted.applicationr   r   r   Ztwisted.pythonr   r   ZApplicationRunnerr   r   r   r   r   Ú<module>   s   