
    Yf                         d Z ddlZddlmZ ddlmZ ddl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mZmZ ddlmZ  G d d          ZdS )z
Run a Twisted application.
    N)Sequence)_exitWithSignal)IReactorCore_ISupportsExitSignalCapturing)Options
UsageError   )
ExitStatusexit)Runner)ApplicationIServiceIServiceMaker   )TwistOptionsc                       e Zd ZdZedee         defd            Zede	de
defd            Zeded	edd
fd            Zededd
fd            Zeej        fdee         dd
fd            Zd
S )Twistz$
    Run a Twisted application.
    argvreturnc                     t                      }	 |                    | dd                    n7# t          $ r*}t          t          j        d| d|            Y d}~nd}~ww xY w|S )z
        Parse command line options.

        @param argv: Command line arguments.
        @return: The parsed options.
        r   NzError: z

)r   parseOptionsr   r   r
   EX_USAGE)r   optionses      R/var/www/html/env/lib/python3.11/site-packages/twisted/application/twist/_twist.pyr   zTwist.options   s     ..	B  abb**** 	B 	B 	B$&@&@&@w&@&@AAAAAAAA	B s   . 
A" AA"pluginr   c                     |                      |          }t          | j                  }|                    |           t	          |          S )a
  
        Create the application service.

        @param plugin: The name of the plugin that implements the service
            application to run.
        @param options: Options to pass to the application.
        @return: The created application service.
        )makeServicer   tapnamesetServiceParentr   )r   r   serviceapplications       r   r!   zTwist.service+   sH     $$W--!&.11  ---$$$    reactorr!   Nc                 f    |                                  |                     dd|j                   dS )z
        Start the application service.

        @param reactor: The reactor to run the service with.
        @param service: The application service to run.
        beforeshutdownN)startServiceaddSystemEventTriggerstopService)r$   r!   s     r   r(   zTwist.startService;   s9     	 	%%h
G<OPPPPPr#   twistOptionsc                     t          | d         | d         | d         | d                   }|                                 | d         }t          j        |          r|j        t          |j                   dS dS dS )z
        Run the application service.

        @param twistOptions: Command line options to convert to runner
            arguments.
        r$   logLevellogFilefileLogObserverFactory)r$   defaultLogLevelr.   r/   N)r   runr   
providedBy_exitSignalr   )r+   runnerr$   s      r   r1   z	Twist.runH   s      +(4 +#/0H#I	
 
 
 	

y)(3G<< 	5". 344444	5 	5..r#   c                     |                      |          }|d         }|j        }|J |                     |j        |         |j                  }|                     ||           |                     |           dS )z
        Executable entry point for L{Twist}.
        Processes options and run a twisted reactor with a service.

        @param argv: Command line arguments.
        @type argv: L{list}
        r$   N)r   r   )r   
subCommandr!   plugins
subOptionsr(   r1   )clsr   r   r$   r6   r!   s         r   mainz
Twist.main\   s     ++d##)$ '
%%%++?:.&  
 

 	'***r#   )__name__
__module____qualname____doc__staticmethodr   strr   r   r   r   r   r!   r   r(   r1   classmethodsysr   r:    r#   r   r   r      s+         hsm     \  % % %H % % % \% 
Ql 
QX 
Q$ 
Q 
Q 
Q \
Q 5, 54 5 5 5 \5& (+   T    [  r#   r   )r>   rB   typingr   twisted.application.appr   twisted.internet.interfacesr   r   twisted.python.usager   r   runner._exitr
   r   runner._runnerr   r!   r   r   r   _optionsr   r   rC   r#   r   <module>rK      s  
  


       3 3 3 3 3 3 S S S S S S S S 4 4 4 4 4 4 4 4 + + + + + + + + # # # # # # : : : : : : : : : : " " " " " "] ] ] ] ] ] ] ] ] ]r#   