Ë
    ojpZ  ã                   óÎ  — d dl Z d dlZd dlZd dlZd dlZ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mZ d dlmZmZ d dlmZ d dlmZ d dlmZ d d	lmZmZmZmZmZmZ d d
l m!Z!m"Z"m#Z#  G d„ d«      Z$ G d„ de$«      Z% G d„ de$«      Z& G d„ d«      Z' G d„ d«      Z(d„ Z)d%d„Z*d„ Z+d„ Z, G d„ d«      Z-d„ Z.d„ Z/ G d„ d«      Z0 G d„ d ejb                  e0«      Z2d!„ Z3d"„ Z4d#„ Z5d$„ Z6y)&é    N)Ú
attrgetter)Ú	copyrightÚloggerÚplugin)ÚreactorsÚservice)ÚNoSuchReactorÚinstallReactor)Údefer)Ú_ISupportsExitSignalCapturing)Úsob)ÚfailureÚlogÚlogfileÚruntimeÚusageÚutil)ÚnamedAnyÚnamedModuleÚqualc                   ó   — e Zd ZdZd„ Zd„ Zy)Ú_BasicProfilerzõ
    @ivar saveStats: if C{True}, save the stats information instead of the
        human readable format
    @type saveStats: C{bool}

    @ivar profileOutput: the name of the file use to print profile data.
    @type profileOutput: C{str}
    c                 ó    — || _         || _        y ©N)ÚprofileOutputÚ	saveStats)Úselfr   r   s      ú9/usr/lib/python3/dist-packages/twisted/application/app.pyÚ__init__z_BasicProfiler.__init__%   s   € Ø*ˆÔØ"ˆ�ó    c                 ó2   — d|› d|› �}|dz  }t        |«      ‚)zÏ
        Helper method to report an import error with a profile module. This
        has to be explicit because some of these modules are removed by
        distributions due to them being non-free.
        zFailed to import module ú: zê
This is most likely caused by your operating system not including
the module due to it being non-free. Either do not use the option
--profile, or install the module; your operating system vendor
may provide it in a separate package.
)Ú
SystemExit)r   ÚmoduleÚeÚss       r   Ú_reportImportErrorz!_BasicProfiler._reportImportError)   s1   € ð ' v h¨b°°Ð4ˆØ	ð ñ 	ˆô ˜‹mÐr    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   © r    r   r   r      s   „ ñò#ór    r   c                   ó   — e Zd ZdZd„ Zy)ÚProfileRunnerz1
    Runner for the standard profile module.
    c                 ó@  — 	 ddl }j                  «       }|j	                  |j
                  «       | j                  r|j                  | j                  «       yt        j                  t        | j                  d«      c}t        _
        	 |j                  «        |t        j                  ct        _
        }|j                  «        y# t        $ r}| j                  d|«       Y d}~Œád}~ww xY w# |t        j                  ct        _
        }|j                  «        w xY w)z:
        Run reactor under the standard profiler.
        r   NÚprofileÚa)r0   ÚImportErrorr'   ÚProfileÚruncallÚrunr   Ú
dump_statsr   ÚsysÚstdoutÚopenÚprint_statsÚclose)r   Úreactorr0   r%   ÚpÚtmps         r   r5   zProfileRunner.run>   sÉ   € ð	2Ûð �O‰OÓˆØ	�	‰	�'—+‘+ÔØ�>Š>Ø�L‰L˜×+Ñ+Õ,ä!Ÿj™j¬$¨t×/AÑ/AÀ3Ó*GˆOˆC””ðØ—‘”à"%¤s§z¡z�””
˜CØ—	‘	•øô ò 	2Ø×#Ñ# I¨q×1Ñ1ûð	2ûð #&¤s§z¡z�””
˜CØ—	‘	•ús#   ‚C Â
C/ Ã	C,ÃC'Ã'C,Ã/.DN©r(   r)   r*   r+   r5   r,   r    r   r.   r.   9   s   „ ñór    r.   c                   ó   — e Zd ZdZd„ Zy)ÚCProfileRunnerz)
    Runner for the cProfile module.
    c                 óê  — 	 ddl }ddl}j	                  «       }|j                  |j                  «       | j                  r|j                  | j                  «       yt        | j                  d«      5 }j                  ||¬«      }|j                  «        |j                  d«       |j                  «        ddd«       y# t        $ r}| j                  d|«       Y d}~Œ×d}~ww xY w# 1 sw Y   yxY w)z:
        Run reactor under the cProfile profiler.
        r   NÚcProfileÚw)Ústreaméÿÿÿÿ)rC   Úpstatsr2   r'   r3   r4   r5   r   r6   r   r9   ÚStatsÚ
strip_dirsÚ
sort_statsr:   )r   r<   rC   rG   r%   r=   rE   r&   s           r   r5   zCProfileRunner.runY   sÇ   € ð	3ÛÛð ×ÑÓˆØ	�	‰	�'—+‘+ÔØ�>Š>Ø�L‰L˜×+Ñ+Õ,ä�d×(Ñ(¨#Ó.ð  °&Ø—L‘L ¨6�LÓ2�Ø—‘”Ø—‘˜RÔ Ø—‘”÷	 ð  øô ò 	3Ø×#Ñ# J°×2Ñ2ûð	3ú÷ ð  ús$   ‚C Á3AC)Ã	C&Ã
C!Ã!C&Ã)C2Nr?   r,   r    r   rA   rA   T   s   „ ñó r    rA   c                   ó    — e Zd ZdZeedœZd„ Zy)ÚAppProfilerz®
    Class which selects a specific profile runner based on configuration
    options.

    @ivar profiler: the name of the selected profiler.
    @type profiler: C{str}
    )r0   Úcprofilec                 óX  — |j                  dd«      }|j                  dd «      }|j                  dd«      j                  «       | _        | j                  | j                  v r2 | j                  | j                     ||«      }|j                  | _        y t        d| j                  › �«      ‚)NÚ	savestatsFr0   ÚprofilerrM   zUnsupported profiler name: )ÚgetÚlowerrP   Ú	profilersr5   r#   )r   Úoptionsr   r   rP   s        r   r   zAppProfiler.__init__z   sŠ   € Ø—K‘K ¨UÓ3ˆ	ØŸ™ I¨tÓ4ˆØŸ™ J°
Ó;×AÑAÓCˆŒØ�=‰=˜DŸN™NÑ*Ø4�t—~‘~ d§m¡mÑ4°]ÀIÓNˆHØ—|‘|ˆD�HäÐ:¸4¿=¹=¸/ÐJÓKÐKr    N)r(   r)   r*   r+   r.   rA   rS   r   r,   r    r   rL   rL   o   s   „ ñð *°~ÑF€IóLr    rL   c                   ó2   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ Zd„ Z	y)Ú	AppLoggera]  
    An L{AppLogger} attaches the configured log observer specified on the
    commandline to a L{ServerOptions} object, a custom L{logger.ILogObserver},
    or a legacy custom {log.ILogObserver}.

    @ivar _logfilename: The name of the file to which to log, if other than the
        default.
    @type _logfilename: C{str}

    @ivar _observerFactory: Callable object that will create a log observer, or
        None.

    @ivar _observer: log observer added at C{start} and removed at C{stop}.
    @type _observer: a callable that implements L{logger.ILogObserver} or
        L{log.ILogObserver}.
    Nc                 óf   — |j                  dd«      | _        |j                  d«      xs d| _        y)zE
        Initialize an L{AppLogger} with a L{ServerOptions}.
        r   Ú r   N)rQ   Ú_logfilenameÚ_observerFactory©r   rT   s     r   r   zAppLogger.__init__™   s-   € ð $ŸK™K¨	°2Ó6ˆÔØ '§¡¨HÓ 5Ò =¸ˆÕr    c                 óÌ  — | j                   �| j                  «       }nB|j                  t        j                  d«      }|€ |j                  t        j                  d«      }|€| j                  «       }|| _        t        j                  j                  | j                  «      r| j                  g}n†t        j                  j                  | j                  «      r!t        j                  | j                  «      g}n<t        j                  dt        d¬«       t        j                  | j                  «      g}t        j                  j                  |«       | j                  «        y)a›  
        Initialize the global logging system for the given application.

        If a custom logger was specified on the command line it will be used.
        If not, and an L{logger.ILogObserver} or legacy L{log.ILogObserver}
        component has been set on C{application}, then it will be used as the
        log observer. Otherwise a log observer will be created based on the
        command line options for built-in loggers (e.g. C{--logfile}).

        @param application: The application on which to check for an
            L{logger.ILogObserver} or legacy L{log.ILogObserver}.
        @type application: L{twisted.python.components.Componentized}
        NaZ  Passing a logger factory which makes log observers which do not implement twisted.logger.ILogObserver or twisted.python.log.ILogObserver to twisted.application.app.AppLogger was deprecated in Twisted 16.2. Please use a factory that produces twisted.logger.ILogObserver (or the legacy twisted.python.log.ILogObserver) implementing objects instead.é   )Ú
stacklevel)rZ   ÚgetComponentr   ÚILogObserverr   Ú_getLogObserverÚ	_observerÚ
providedByÚLegacyLogObserverWrapperÚwarningsÚwarnÚDeprecationWarningÚglobalLogBeginnerÚbeginLoggingToÚ_initialLog)r   ÚapplicationÚobserverÚ	observerss       r   ÚstartzAppLogger.start    s  € ð × Ñ Ð,Ø×,Ñ,Ó.‰Hà"×/Ñ/´×0CÑ0CÀTÓJˆHØÐà&×3Ñ3´C×4DÑ4DÀdÓK�àÐØ×+Ñ+Ó-ˆHØ!ˆŒä×Ñ×)Ñ)¨$¯.©.Ô9ØŸ™Ð(‰IÜ×Ñ×(Ñ(¨¯©Ô8Ü×8Ñ8¸¿¹ÓHÐI‰Iä�M‰Mðô #Øõô  ×8Ñ8¸¿¹ÓHÐIˆIä× Ñ ×/Ñ/°	Ô:Ø×ÑÕr    c                 ó.  — ddl m} t        j                  | «      j	                  dt
        j                  t        j                  t        j                  «       ¬«       t        j                  | «      j	                  dt        |j                  «      ¬«       y)z1
        Print twistd start log message.
        r   ©r<   z1twistd {version} ({exe} {pyVersion}) starting up.)ÚversionÚexeÚ	pyVersionzreactor class: {reactor}.N)Útwisted.internetr<   r   Ú
_loggerForÚinfor   rq   r7   Ú
executabler   ÚshortPythonVersionr   Ú	__class__)r   r<   s     r   rj   zAppLogger._initialLogÒ   st   € õ 	-ä×Ñ˜$Ó×$Ñ$Ø?Ü×%Ñ%Ü—‘Ü×0Ñ0Ó2ð	 	%ô 	
ô 	×Ñ˜$Ó×$Ñ$Ø'´°g×6GÑ6GÓ1Hð 	%õ 	
r    c                 óÖ   — | j                   dk(  s| j                   st        j                  }n)t        j                  j                  | j                   «      }t        j                  |«      S )zr
        Create a log observer to be added to the logging system before running
        this application.
        ú-)rY   r7   r8   r   ÚLogFileÚfromFullPathr   ÚtextFileLogObserver)r   ÚlogFiles     r   ra   zAppLogger._getLogObserverâ   sN   € ð
 ×Ñ Ò#¨4×+<Ò+<Ü—j‘j‰Gä—o‘o×2Ñ2°4×3DÑ3DÓEˆGÜ×)Ñ)¨'Ó2Ð2r    c                 óÆ   — t        j                  | «      j                  d«       | j                  �1t         j                  j                  | j                  «       d| _        yy)zS
        Remove all log observers previously set up by L{AppLogger.start}.
        zServer Shut Down.N)r   ru   rv   rb   ÚglobalLogPublisherÚremoveObserver©r   s    r   ÚstopzAppLogger.stopí   sL   € ô 	×Ñ˜$Ó×$Ñ$Ð%8Ô9Ø�>‰>Ð%Ü×%Ñ%×4Ñ4°T·^±^ÔDØ!ˆD�Nð &r    )
r(   r)   r*   r+   rb   r   rn   rj   ra   r„   r,   r    r   rV   rV   …   s(   „ ñð" €Iò>ò0òd
ò 	3ó"r    rV   c                  ó”   — d„ } d„ }d„ }|t         j                  _        | t         j                  _        |t         j                  _        y )Nc                 óˆ   — | j                  «        | j                  «        ddlm} |j	                  d|j
                  «       y)Nr   rp   é   )Úclear_all_breaksÚset_continuert   r<   Ú	callLaterr„   )r   Úargr<   s      r   Údo_stopzfixPdb.<locals>.do_stopø   s4   € Ø×ÑÔØ×ÑÔÝ,à×Ñ˜!˜WŸ\™\Ô*Ør    c                 ó   — t        d«       y )NzEstop - Continue execution, then cleanly shutdown the twisted reactor.)Úprintrƒ   s    r   Ú	help_stopzfixPdb.<locals>.help_stop   s   € ÜØVõ	
r    c                 ó.   — t        j                  d«       y )Nr   )ÚosÚ_exitrƒ   s    r   Úset_quitzfixPdb.<locals>.set_quit  s   € Ü
�‰��r    )ÚpdbÚPdbr“   rŒ   r�   )rŒ   r�   r“   s      r   ÚfixPdbr–   ÷   s6   € òò
ò
ð  „C‡G�GÔØ„C‡G�G„OØ!„C‡G�GÕr    c                 ó¢  — |€ddl m} 	 | d   r|�Å|j                  |«       y| d   r�|t        _        |t        _        t        j                  dk(  rJt        j                  t        j                  d„ «       t        j                  t        j                  d„ «       t        «        t        j                  |j                  «       y|j                  «        yy# t        $ rn d	}| d
   r|}nt        dd«      }d}	 t!        j"                  |¬«       |j%                  «        |r*|j'                  «        Y y# |r|j'                  «        w w xY wY yw xY w)aN  
    Start the reactor, using profiling if specified by the configuration, and
    log any error happening in the process.

    @param config: configuration of the twistd application.
    @type config: L{ServerOptions}

    @param oldstdout: initial value of C{sys.stdout}.
    @type oldstdout: C{file}

    @param oldstderr: initial value of C{sys.stderr}.
    @type oldstderr: C{file}

    @param profiler: object used to run the reactor with profiling.
    @type profiler: L{AppProfiler}

    @param reactor: The reactor to use.  If L{None}, the global reactor will
        be used.
    Nr   rp   r0   ÚdebugÚposixc                  ó*   — t        j                  «       S r   ©r”   Ú	set_trace©Úargss    r   ú<lambda>z'runReactorWithLogging.<locals>.<lambda>+  s   € ¼C¿M¹M»O€ r    c                  ó*   — t        j                  «       S r   r›   r�   s    r   rŸ   z'runReactorWithLogging.<locals>.<lambda>,  s   € ¼3¿=¹=»?€ r    FÚnodaemonzTWISTD-CRASH.logr1   T©Úfile)rt   r<   r5   r7   r8   Ústderrr   ÚplatformTypeÚsignalÚSIGUSR2ÚSIGINTr–   r”   r4   ÚBaseExceptionr9   Ú	tracebackÚ	print_excÚflushr;   )ÚconfigÚ	oldstdoutÚ	oldstderrrP   r<   r;   r£   s          r   ÚrunReactorWithLoggingr°     s  € ð( €Ý,ðØ�)ÒØÐ#Ø—‘˜WÕ%Ø�GŠ_Ø"ŒCŒJØ"ŒCŒJÜ×#Ñ# wÒ.Ü—‘œfŸn™nÑ.KÔLÜ—‘œfŸm™mÑ-JÔKÜŒHÜ�K‰K˜Ÿ™Õ$à�K‰K�Mð $øô ò ØˆØ�*ÒØ‰DäÐ*¨CÓ0ˆDØˆEð	Ü×Ñ TÕ*Ø�J‰JŒLáØ—
‘
–øñ Ø—
‘
•ð ú‰uðús5   ŠC £B!C ÃC Ã!EÃ9&D3ÄEÄ3EÅEÅEc                 ó2   — | rt        j                   d«      S y )NzPassphrase: )Úgetpass©Úneededs    r   ÚgetPassphraserµ   @  s   € ÙÜ�‰˜~Ó.Ð.àr    c                 ó2   — | rt        j                  d«      S y )NzEncryption passphrase: )r   ÚgetPasswordr³   s    r   ÚgetSavePassphraser¸   G  s   € ÙÜ×ÑÐ 9Ó:Ð:àr    c                   ó<   — e Zd ZdZeZeZd„ Zd„ Z	d„ Z
d„ Zd„ Zd„ Zy)	ÚApplicationRunnera  
    An object which helps running an application based on a config object.

    Subclass me and implement preApplication and postApplication
    methods. postApplication generally will want to run the reactor
    after starting the application.

    @ivar config: The config object, which provides a dict-like interface.

    @ivar application: Available in postApplication, but not
       preApplication. This is the application object.

    @ivar profilerFactory: Factory for creating a profiler object, able to
        profile the application if options are set accordingly.

    @ivar profiler: Instance provided by C{profilerFactory}.

    @ivar loggerFactory: Factory for creating object responsible for logging.

    @ivar logger: Instance provided by C{loggerFactory}.
    c                 ój   — || _         | j                  |«      | _        | j                  |«      | _        y r   )r­   ÚprofilerFactoryrP   ÚloggerFactoryr   )r   r­   s     r   r   zApplicationRunner.__init__h  s-   € ØˆŒØ×,Ñ,¨VÓ4ˆŒØ×(Ñ(¨Ó0ˆ�r    c                 óì   — | j                  «        | j                  «       | _        | j                  j	                  | j                  «       | j                  «        | j                  j                  «        y)z&
        Run the application.
        N)ÚpreApplicationÚcreateOrGetApplicationrk   r   rn   ÚpostApplicationr„   rƒ   s    r   r5   zApplicationRunner.runm  sU   € ð 	×ÑÔØ×6Ñ6Ó8ˆÔà�‰×Ñ˜$×*Ñ*Ô+à×ÑÔØ�‰×ÑÕr    c                 ó¶   — |€ddl m} t        | j                  ||| j                  |«       t        j                  |«      r|j                  | _        yd| _        y)z®
        Run the reactor with the given configuration.  Subclasses should
        probably call this from C{postApplication}.

        @see: L{runReactorWithLogging}
        Nr   rp   )rt   r<   r°   r­   rP   r   rc   Ú_exitSignal)r   r<   r®   r¯   s       r   ÚstartReactorzApplicationRunner.startReactory  sI   € ð ˆ?Ý0Ü˜dŸk™k¨9°iÀÇÁÐPWÔXä(×3Ñ3°GÔ<Ø&×2Ñ2ˆDÕà#ˆDÕr    c                 ó   — t        «       ‚)z‹
        Override in subclass.

        This should set up any state necessary before loading and
        running the Application.
        ©ÚNotImplementedErrorrƒ   s    r   r¿   z ApplicationRunner.preApplication‰  s   € ô "Ó#Ð#r    c                 ó   — t        «       ‚)zê
        Override in subclass.

        This will be called after the application has been loaded (so
        the C{application} attribute will be set). Generally this
        should start the application and run the reactor.
        rÆ   rƒ   s    r   rÁ   z!ApplicationRunner.postApplication’  s   € ô "Ó#Ð#r    c                 ó–  — | j                   j                  r„| j                   j                  | j                   j                     }|j                  | j                   j                  «      }t        j                  |j                  «      }|j                  |«       |S t        | j                   d   «      }t        | j                   |«      }|S )a�  
        Create or load an Application based on the parameters found in the
        given L{ServerOptions} instance.

        If a subcommand was used, the L{service.IServiceMaker} that it
        represents will be used to construct a service to be added to
        a newly-created Application.

        Otherwise, an application will be loaded based on parameters in
        the config.
        Ú	encrypted)r­   Ú
subCommandÚloadedPluginsÚmakeServiceÚ
subOptionsr   ÚApplicationÚtapnameÚsetServiceParentrµ   ÚgetApplication)r   ÚplgÚserrk   Ú
passphrases        r   rÀ   z(ApplicationRunner.createOrGetApplicationœ  sž   € ð �;‰;×!Ò!ð —+‘+×+Ñ+¨D¯K©K×,BÑ,BÑCˆCØ—/‘/ $§+¡+×"8Ñ"8Ó9ˆCÜ!×-Ñ-¨c¯k©kÓ:ˆKØ× Ñ  Ô-ð Ðô ' t§{¡{°;Ñ'?Ó@ˆJÜ(¨¯©°jÓAˆKØÐr    N)r(   r)   r*   r+   rL   r¼   rV   r½   r   r5   rÄ   r¿   rÁ   rÀ   r,   r    r   rº   rº   N  s1   „ ñð, "€OØ€Mò1ò

ò$ò $ò$ór    rº   c                 ój  — dD �cg c]  }| |   sŒ	| |   |f‘Œ c}d   }|d   ddij                  |d   |d   «      }}	 t        j                  d|z  «       t        j                  |||«      }t        j                  d«       |S c c}w # t
        $ rŸ}d|z  }t        |t        «      r|j                  d   d	k(  r|d
z  }t        j                  t        j                  ¬«       t        j                  |«       t        j                  «        t        j                  d|z   dz   «       Y d }~S d }~ww xY w)N)ÚpythonÚsourcer£   r   r£   Úpickler‡   zLoading %s...zLoaded.zFailed to load application: %srk   aN  
Could not find 'application' in the file. To use 'twistd -y', your .tac
file must create a suitable object (e.g., by calling service.Application())
and store it in a variable named 'application'. twistd loads your .tac file
and scans the global variables for one of this name.

Please read the 'Using Application' HOWTO for details.
r¢   ú
)rQ   r   Úmsgr   ÚloadApplicationÚ	ExceptionÚ
isinstanceÚKeyErrorrž   rª   r«   r   Údeferrr7   Úexit)r­   rÕ   Útr&   ÚfilenameÚstylerk   r%   s           r   rÒ   rÒ   ¹  s  € Ø!=ÖK˜AÀÈÃˆ&�‰)�QŠÒKÈAÑN€AØ˜‘d˜V XÐ.×2Ñ2°1°Q±4¸¸1¹Ó>ˆe€Hð"Ü�‰� (Ñ*Ô+Ü×-Ñ-¨h¸¸zÓJˆÜ�‰�	Ôð  Ðùò+ 	Løô ò "Ø,¨qÑ0ˆÜ�aœÔ" q§v¡v¨a¡y°MÒ'AØð ñ ˆAô 	×Ñ¤§¡Õ-Ü�‰�Œ
Ü�
‰
ŒÜ�‰�˜‘˜D‘×!Ð!ØÐûð"ús#   …
B�	B¿AB
 Â
	D2ÂBD-Ä-D2c                  óŠ   — t        j                  t        j                  «       D � cg c]  } | j                  ‘Œ c} «      S c c} w r   )r   ÚCompleteListr   ÚgetReactorTypesÚ	shortName)Úrs    r   Ú_reactorActionrê   Ò  s.   € Ü×Ñ´H×4LÑ4LÓ4NÖO¨q˜qŸ{›{ÒOÓPÐPùÒOs   ¦A c                   ó†   — e Zd ZdZ ej
                  dei¬«      Zej                  Z
 eej                  «      Zd„ Zd„ ZeZy)ÚReactorSelectionMixinz½
    Provides options for selecting a reactor to install.

    If a reactor is installed, the short name which was used to locate it is
    saved as the value for the C{"reactor"} key.
    r<   )Ú
optActionsc           	      óL  — t        | j                  «       t        d«      ¬«      }d}|D ]O  }	 t        |j                  «       | j
                  j                  d|j                  d›d|j                  › d�«       ŒQ |rQ| j
                  j                  d«       | j
                  j                  d«       | j
                  j                  |«       t        d	«      ‚# t        $ rA}|dj                  |j                  |j                  |j                  d	   «      z  }Y d
}~Œõd
}~ww xY w)zE
        Display a list of possibly available reactor names.
        rè   ©ÚkeyrX   z    z<4ú	rÚ   z    !{:<4}	{} ({})
r   Nz.    reactors not available on this platform:

)ÚsortedÚ_getReactorTypesr   r   Ú
moduleNameÚmessageOutputÚwriterè   Údescriptionr2   Úformatrž   r#   )r   ÚrctsÚnotWorkingReactorsré   r%   s        r   Úopt_help_reactorsz'ReactorSelectionMixin.opt_help_reactorsã  s  € ô �d×+Ñ+Ó-´:¸kÓ3JÔKˆØÐØò 		ˆAðÜ˜AŸL™LÔ)Ø×"Ñ"×(Ñ(¨4°·±¸BÐ/?¸rÀ!Ç-Á-ÀÐPRÐ)SÕTð		ñ Ø×Ñ×$Ñ$ TÔ*Ø×Ñ×$Ñ$ØEôð ×Ñ×$Ñ$Ð%7Ô8Ü˜‹mÐøô ò Ø"Ð&=×&DÑ&DØ—K‘KØ—M‘MØ—F‘F˜1‘Ió'ñ Õ"ûðús   ­ACÃ	D#Ã"7DÄD#c                 óÄ   — 	 t        |«       || d<   y# t        $ r d|›d�}t        j                  |«      ‚t        $ r }d|›d�}t        j                  |«      ‚d}~ww xY w)zX
        Which reactor to use (see --help-reactors for a list of possibilities)
        r<   z'The specified reactor does not exist: 'z:'.
See the list of available reactors with --help-reactorsz9The specified reactor cannot be used, failed with error: z9.
See the list of available reactors with --help-reactorsN)r
   r	   r   Ú
UsageErrorrÝ   )r   rè   rÛ   r%   s       r   Úopt_reactorz!ReactorSelectionMixin.opt_reactorü  sx   € ð	(Ü˜9Ô%ð  (ˆD�ŠOøô ó 	(ò &/ð1ð ô
 ×"Ñ" 3Ó'Ð'Üó 	(ò &'ð)ð ô
 ×"Ñ" 3Ó'Ð'ûð	(ús   ‚ “,A¿AÁAN)r(   r)   r*   r+   r   ÚCompletionsrê   ÚcompDatar7   r8   rõ   Ústaticmethodr   rç   ró   rû   rþ   Úopt_rr,   r    r   rì   rì   Ö  sK   „ ñð !ˆu× Ñ ¨Y¸Ð,GÔH€Hà—J‘J€MÙ# H×$<Ñ$<Ó=Ðòò2(ð8 �Er    rì   c            
       ó   — e Zd ZdZg d¢g d¢g d¢gZg d¢g d¢g d¢dd	d
ddj                  ej                  «      z  gg d¢g d¢g d¢g d¢gZ e	j                  dg e	j                  d«       e	j                  d«       e	j                  d«       e	j                  «       dœ¬«      Z eej                   «      Zd„ Zd„ ZeZd„ Zdd„Zd„ Zed„ «       Zy	)ÚServerOptionszQtwistd reads a twisted.application.service.Application out of a file and runs it.)rO   NzBsave the Stats object rather than the text output of the profiler.)Úno_saveÚozdo not save state on shutdown)rÊ   r%   z(The specified tap/aos file is encrypted.)r   ÚlNz%log to a specified file, - for stdout)r   NNz•A fully-qualified name to a log observer factory to use for the initial log observer.  Takes precedence over --logfile and --syslog (when available).)r0   r=   Nz7Run in profile mode, dumping results to specified file.rP   NrM   z!Name of the profiler to use (%s).z, )r£   Úfz
twistd.tapzread the given .tap file)r×   ÚyNz:read an application from within a Python file (implies -o))rØ   r&   Nz2Read an application from a .tas file (AOT format).)ÚrundirÚdú.z-Change to a supplied directory before running)r£   r×   rØ   z*.tapz
*.(tac|py)z*.tas)r£   r×   rØ   r
  )ÚmutuallyExclusiverí   c                 ó”   — d| d<   d|v r|d   | _         nt        j                   | _         t        j                  j	                  | «       y )NFr˜   r8   )r8   r7   r   ÚOptionsr   )r   r1   Úkws      r   r   zServerOptions.__init__X  s:   € ØˆˆW‰Ø�r‰>Ø˜X™,ˆD�KäŸ*™*ˆDŒKÜ�‰×Ñ˜tÕ$r    c                 ó`   — t        j                  d«       t        j                  «        d| d<   y)z€
        Run the application in the Python Debugger (implies nodaemon),
        sending SIGUSR2 will drop into debugger
        Tr˜   N)r   ÚsetDebuggingr   ÚstartDebugModerƒ   s    r   Ú	opt_debugzServerOptions.opt_debug`  s'   € ô
 	×Ñ˜4Ô Ü×ÑÔ ØˆˆWŠr    c                 ó°   — t        j                  t        j                  «       	 ddl}|j                  t        j                  «       y# t
        $ r Y yw xY w)z‹
        Print an insanely verbose log of everything that happens.
        Useful when debugging freezes or locks in complex code.
        r   N)r7   Úsettracer   ÚspewerÚ	threadingr2   )r   r  s     r   Úopt_spewzServerOptions.opt_spewk  sD   € ô
 	�‰”T—[‘[Ô!ð	Ûð 	×Ñœ4Ÿ;™;Õ'øô ò 	Ùð	ús   ¥A	 Á		AÁAc                 óx   — |€t         j                  dd  xs dg}t        j                  j	                  | |«       y )Nr‡   z--help)r7   Úargvr   r  ÚparseOptionsr[   s     r   r  zServerOptions.parseOptionsw  s1   € Øˆ?Ü—h‘h˜q˜r�lÒ0 x jˆGÜ�‰×"Ñ" 4¨Õ1r    c                 óÒ   — | j                   s| d   rd| d<   | d   �	 t        | d   «      | d<   y y # t        $ r-}t        j                  dj                  | d   |«      «      ‚d }~ww xY w)Nr×   Tr  r   z%Logger '{}' could not be imported: {})rË   r   rÝ   r   rý   rø   )r   r%   s     r   ÚpostOptionszServerOptions.postOptions|  sx   € Ø�?Š?˜d 8šnØ"ˆD�‰OØ�‰>Ð%ðÜ!)¨$¨x©.Ó!9��X’ð &øô ò Ü×&Ñ&Ø;×BÑBÀ4ÈÁ>ÐSTÓUóð ûðús   �0 °	A&¹(A!Á!A&c              #   óþ   K  — | j                  t        j                  «      }i | _        t	        |t        d«      ¬«      D ]:  }|| j                  |j                  <   |j                  d |fd„|j                  f–— Œ< y ­w)NrÐ   rï   c                 ó"   — | j                  «       S r   )rT   )Úplugs    r   rŸ   z+ServerOptions.subCommands.<locals>.<lambda>“  s   €  $§,¡,£.€ r    )Ú_getPluginsr   ÚIServiceMakerrÌ   rò   r   rÐ   r÷   )r   Úpluginsr!  s      r   ÚsubCommandszServerOptions.subCommands‡  sx   è ø€ à×"Ñ"¤7×#8Ñ#8Ó9ˆØˆÔÜ˜7¬
°9Ó(=Ô>ò 
	ˆDØ/3ˆD×Ñ˜tŸ|™|Ñ,à—‘Øð !Ò0Ø× Ñ ðó ñ
	ùs   ‚A;A=r   )r(   r)   r*   ÚlongdescÚoptFlagsÚjoinrL   rS   ÚoptParametersr   rÿ   ÚCompleteFilesÚCompleteDirsr   r  r   Ú
getPluginsr"  r   r  Úopt_br  r  r  Úpropertyr%  r,   r    r   r  r    s  „ ð	!ð ò	
ò
 	:ÚFð€Hò 	Hò	
ò	
ð ØØØ/°$·)±)¸K×<QÑ<QÓ2RÑRð		
ò 	@ò	
ò 	TÚMð=€MðB !ˆu× Ñ Ø7Ð8à'�E×'Ñ'¨Ó0Ø)�e×)Ñ)¨,Ó7Ø)�e×)Ñ)¨'Ó2Ø(�e×(Ñ(Ó*ñ	
ô€Hñ ˜v×0Ñ0Ó1€Kò%òð €Eò
(ó2ò
	ð ñó ñr    r  c                 óþ   —  |«       }	 |j                  «         | |«       y # t        j                  $ rG}dj                  t        j
                  dd «      }t        |«       t        |› d|› �«       Y d }~y d }~ww xY w)Nú r   r]   r"   )r  r   Úerrorr(  r7   r  rŽ   )ÚrunAppr  r­   ÚueÚcommstrs        r   r5   r5   ˜  sn   € Ù‹_€FðØ×ÑÔñ 	ˆv�øô �;‰;ò "Ø—(‘(œ3Ÿ8™8 A a˜=Ó)ˆÜˆfŒÜ��	˜˜B˜4Ð ×!Ñ!ûð"ús   ‰" ¢A<µ=A7Á7A<c                 óä   — t        j                  | ||«      }t        j                  |«      j	                  |«       t        |«      }|rd }t        j                  |«      j                  ||¬«       y )N)rã   rÕ   )r   rÜ   r   ÚIPersistableÚsetStyler¸   Úsave)ÚfileinÚtypeinrÕ   ÚfileoutÚtypeoutÚencryptrk   s          r   ÚconvertStyler>  ¤  s_   € Ü×)Ñ)¨&°&¸*ÓE€KÜ×Ñ�[Ó!×*Ñ*¨7Ô3Ü" 7Ó+€JÙØˆÜ×Ñ�[Ó!×&Ñ&°ÀJÐ&ÕOr    c                 ó   — ddl m} t        j                  | «      j	                  «        |r3t        j                  | «      }|j                  dd|j                  d«       |j                  ddt        j                  | «      j                  «       y )Nr   rp   ÚafterÚshutdownÚbefore)
rt   r<   r   ÚIServiceÚstartServicer   r6  ÚaddSystemEventTriggerr8  ÚstopService)rk   r8  r<   r=   s       r   ÚstartApplicationrG  ­  sm   € Ý(ä×Ñ�[Ó!×.Ñ.Ô0ÙÜ×Ñ˜[Ó)ˆØ×%Ñ% g¨z¸1¿6¹6À:ÔNØ×!Ñ!Ø�*œg×.Ñ.¨{Ó;×GÑGõr    c                 óœ   — t        j                   | t         j                  «       t        j                  t        j                  «       | «       y)a  
    Force the application to terminate with the specified signal by replacing
    the signal handler with the default and sending the signal to ourselves.

    @param sig:  Signal to use to terminate the process with C{os.kill}.
    @type sig:  C{int}
    N)r¦   ÚSIG_DFLr‘   ÚkillÚgetpid)Úsigs    r   Ú_exitWithSignalrM  ¹  s*   € ô ‡M�M�#”v—~‘~Ô&Ü‡G�GŒB�I‰I‹K˜Õr    )NN)7r²   r‘   r”   r¦   r7   rª   re   Úoperatorr   Útwistedr   r   r   Útwisted.applicationr   r   Útwisted.application.reactorsr	   r
   rt   r   Útwisted.internet.interfacesr   Útwisted.persistedr   Útwisted.pythonr   r   r   r   r   r   Útwisted.python.reflectr   r   r   r   r.   rA   rL   rV   r–   r°   rµ   r¸   rº   rÒ   rê   rì   r  r  r5   r>  rG  rM  r,   r    r   ú<module>rV     sã   ðó Û 	Û 
Û Û 
Û Û Ý ç -Ñ -ß 1÷ GÝ "Ý EÝ !ß F× Fß >Ñ >÷ñ ô<�Nô ô6 �^ô  ÷6Lñ L÷,o"ñ o"òd"ó,0òfò÷hñ hòVò2Q÷Bñ BôJz�E—M‘MÐ#8ô zòz	òPò	ó	r    