U
    
W[                     @   sp   d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
Z
d dlZG dd dejZG dd	 d	ejZdS )
    )print_function)log)appserviceinternet)	copyrightNc                   @   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)printformatr   versionstdoutsysexitself r   9/usr/lib/python3/dist-packages/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>4       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   )Z
__future__r   Ztwisted.pythonr   Ztwisted.applicationr   r   r   Ztwistedr   r   r   r   ZApplicationRunnerr   r   r   r   r   <module>   s   