Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/application/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/application/__pycache__/app.cpython-310.pyc
o

�bqZ�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZmZddlmZmZddlmZddlmZddlmZdd	lmZmZmZmZmZmZdd
l m!Z!m"Z"m#Z#Gdd�d�Z$Gd
d�de$�Z%Gdd�de$�Z&Gdd�d�Z'Gdd�d�Z(dd�Z)d/dd�Z*dd�Z+dd�Z,Gdd�d�Z-dd �Z.d!d"�Z/Gd#d$�d$�Z0Gd%d&�d&ej1e0�Z2d'd(�Z3d)d*�Z4d+d,�Z5d-d.�Z6dS)0�N)�
attrgetter)�	copyright�logger�plugin)�reactors�service)�
NoSuchReactor�installReactor)�defer)�_ISupportsExitSignalCapturing)�sob)�failure�log�logfile�runtime�usage�util)�namedAny�namedModule�qualc@s eZdZdZdd�Zdd�ZdS)�_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}
    cCs||_||_dS�N)�
profileOutput�	saveStats)�selfrr�r�9/usr/lib/python3/dist-packages/twisted/application/app.py�__init__%s
z_BasicProfiler.__init__cCs d|�d|��}|d7}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.
        zFailed 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�srrr�_reportImportError)sz!_BasicProfiler._reportImportErrorN)�__name__�
__module__�__qualname__�__doc__rr#rrrrrs	rc@�eZdZdZdd�ZdS)�
ProfileRunnerz1
    Runner for the standard profile module.
    c
Cs�zddl}Wnty}z|�d|�WYd}~nd}~ww|��}|�|j�|jr4|�|j�dSt	j
t|jd�}t	_
z|��W|t	j
t	_
}|�
�dS|t	j
t	_
}|�
�w)z:
        Run reactor under the standard profiler.
        rN�profile�a)r*�ImportErrorr#�Profile�runcall�runr�
dump_statsr�sys�stdout�open�print_stats�close)r�reactorr*r!�p�tmprrrr/>s"��
�
zProfileRunner.runN�r$r%r&r'r/rrrrr)9�r)c@r()�CProfileRunnerz)
    Runner for the cProfile module.
    c
Cs�z
ddl}ddl}Wnty"}z|�d|�WYd}~nd}~ww|��}|�|j�|jr8|�|j	�dSt
|j	d��}|j||d�}|��|�
d�|��Wd�dS1s^wYdS)z:
        Run reactor under the cProfile profiler.
        rN�cProfile�w)�stream���)r<�pstatsr,r#r-r.r/rr0rr3�Stats�
strip_dirs�
sort_statsr4)rr6r<r@r!r7r>r"rrrr/Ys"��

"�zCProfileRunner.runNr9rrrrr;Tr:r;c@s"eZdZdZeed�Zdd�ZdS)�AppProfilerz�
    Class which selects a specific profile runner based on configuration
    options.

    @ivar profiler: the name of the selected profiler.
    @type profiler: C{str}
    )r*�cprofilecCsd|�dd�}|�dd�}|�dd���|_|j|jvr*|j|j||�}|j|_dStd|j����)N�	savestatsFr*�profilerrEzUnsupported profiler name: )�get�lowerrG�	profilersr/r)r�optionsrrrGrrrrzszAppProfiler.__init__N)r$r%r&r'r)r;rJrrrrrrDos
rDc@s<eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	dS)
�	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}.
    NcCs"|�dd�|_|�d�p
d|_dS)zE
        Initialize an L{AppLogger} with a L{ServerOptions}.
        r�rN)rH�_logfilename�_observerFactory�rrKrrrr�szAppLogger.__init__cCs�|jdur
|��}n|�tjd�}|dur|�tjd�}|dur$|��}||_tj�|j�r3|jg}ntj�|j�rBt�|j�g}nt	j
dtdd�t�|j�g}tj�
|�|��dS)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}
        NaZPassing 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)rO�getComponentr�ILogObserverr�_getLogObserver�	_observer�
providedBy�LegacyLogObserverWrapper�warnings�warn�DeprecationWarning�globalLogBeginner�beginLoggingTo�_initialLog)r�application�observer�	observersrrr�start�s(


	�zAppLogger.startcCsJddlm}t�|�jdtjtjt	�
�d�t�|�jdt|j�d�dS)z1
        Print twistd start log message.
        r�r6z1twistd {version} ({exe} {pyVersion}) starting up.)�version�exe�	pyVersionzreactor class: {reactor}.N)
�twisted.internetr6r�
_loggerFor�inforrdr1�
executabler�shortPythonVersionr�	__class__)rr6rrrr^�s
�


�zAppLogger._initialLogcCs0|jdks|jstj}ntj�|j�}t�|�S)zr
        Create a log observer to be added to the logging system before running
        this application.
        �-)rNr1r2r�LogFile�fromFullPathr�textFileLogObserver)r�logFilerrrrU�s
zAppLogger._getLogObservercCs6t�|��d�|jdurtj�|j�d|_dSdS)zS
        Remove all log observers previously set up by L{AppLogger.start}.
        zServer Shut Down.N)rrhrirV�globalLogPublisher�removeObserver�rrrr�stop�s


�zAppLogger.stop)
r$r%r&r'rVrrbr^rUrurrrrrL�s2rLcCs4dd�}dd�}dd�}|tj_|tj_|tj_dS)NcSs.|��|��ddlm}|�d|j�dS)Nrrc�)�clear_all_breaks�set_continuergr6�	callLaterru)r�argr6rrr�do_stop�s
zfixPdb.<locals>.do_stopcSstd�dS)NzEstop - Continue execution, then cleanly shutdown the twisted reactor.)�printrtrrr�	help_stops�zfixPdb.<locals>.help_stopcSst�d�dS)Nr)�os�_exitrtrrr�set_quitszfixPdb.<locals>.set_quit)�pdb�Pdbr�r{r})r{r}r�rrr�fixPdb�sr�cCs|dur
ddlm}zG|dr|dur|�|�WdSWdS|drK|t_|t_tjdkr?t�tj	dd��t�tj
d	d��t�t�
|j�WdS|��WdSty�d
}|dra|}ntdd
�}d}ztj|d�|��W|r}|��YdSYdS|r�|��www)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.
    Nrrcr*�debug�posixcW�t��Sr�r��	set_trace��argsrrr�<lambda>+�z'runReactorWithLogging.<locals>.<lambda>cWr�rr�r�rrrr�,r�F�nodaemonzTWISTD-CRASH.logr+T��file)rgr6r/r1r2�stderrr�platformType�signal�SIGUSR2�SIGINTr�r�r.�
BaseExceptionr3�	traceback�	print_exc�flushr5)�config�	oldstdout�	oldstderrrGr6r5r�rrr�runReactorWithLogging
s>�



�
��r�cCs|rt�d�SdS)NzPassphrase: )�getpass��neededrrr�
getPassphrase@�
r�cCs|rt�d�SdS)NzEncryption passphrase: )r�getPasswordr�rrr�getSavePassphraseGr�r�c@sHeZdZdZeZeZdd�Zdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dS)�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}.
    cCs"||_|�|�|_|�|�|_dSr)r��profilerFactoryrG�
loggerFactoryr)rr�rrrrhszApplicationRunner.__init__cCs6|��|��|_|j�|j�|��|j��dS)z&
        Run the application.
        N)�preApplication�createOrGetApplicationr_rrb�postApplicationrurtrrrr/ms

zApplicationRunner.runcCsH|dur
ddlm}t|j|||j|�t�|�r|j|_dSd|_dS)z�
        Run the reactor with the given configuration.  Subclasses should
        probably call this from C{postApplication}.

        @see: L{runReactorWithLogging}
        Nrrc)rgr6r�r�rGrrW�_exitSignal)rr6r�r�rrr�startReactorys

zApplicationRunner.startReactorcC�t��)z�
        Override in subclass.

        This should set up any state necessary before loading and
        running the Application.
        ��NotImplementedErrorrtrrrr��sz ApplicationRunner.preApplicationcCr�)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�rtrrrr��sz!ApplicationRunner.postApplicationcCs^|jjr |jj|jj}|�|jj�}t�|j�}|�|�|St	|jd�}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�serr_�
passphraserrrr��s
�z(ApplicationRunner.createOrGetApplicationN)r$r%r&r'rDr�rLr�rr/r�r�r�r�rrrrr�Ns	
r�c
s��fdd�dD�d}|dddi�|d|d�}}zt�d|�t�|||�}t�d	�W|Styr}z4d
|}t|t�rN|jddkrN|d7}t	j
tjd
�t�|�t��t
�d|d�WYd}~|Sd}~ww)Ncs g|]}�|r�||f�qSrr)�.0�t�r�rr�
<listcomp>�s z"getApplication.<locals>.<listcomp>)�python�sourcer�rr��picklervz
Loading %s...zLoaded.zFailed to load application: %sr_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��
)rHr�msgr�loadApplication�	Exception�
isinstance�KeyErrorr�r�r�r�deferrr1�exit)r�r�r"�filename�styler_r!rr�rr��s$"�
��r�cCst�dd�t��D��S)NcSsg|]}|j�qSr)�	shortName)r��rrrrr��sz"_reactorAction.<locals>.<listcomp>)r�CompleteListr�getReactorTypesrrrr�_reactorAction�sr�c@sDeZdZdZejdeid�Zej	Z
eej
�Zdd�Zdd�ZeZdS)	�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.
    r6)�
optActionscCs�t|��td�d�}d}|D]9}zt|j�|j�d|jd�d|j�d��Wqt	yG}z|d�
|j|j|jd	�7}WYd
}~qd
}~ww|r\|j�d�|j�d�|j�|�td	��)zE
        Display a list of possibly available reactor names.
        r���keyrMz    z<4�	r�z    !{:<4}	{} ({})
rNz.    reactors not available on this platform:

)
�sorted�_getReactorTypesrr�
moduleName�
messageOutput�writer��descriptionr,�formatr�r)r�rcts�notWorkingReactorsr�r!rrr�opt_help_reactors�s*
$����z'ReactorSelectionMixin.opt_help_reactorsc
Csfzt|�Wn&tyd|f}t�|��ty,}z
d|f}t�|��d}~ww||d<dS)zX
        Which reactor to use (see --help-reactors for a list of possibilities)
        zcThe specified reactor does not exist: '%s'.
See the list of available reactors with --help-reactorsztThe specified reactor cannot be used, failed with error: %s.
See the list of available reactors with --help-reactorsNr6)r	rr�
UsageErrorr�)rr�r�r!rrr�opt_reactor�s"	��
��
��z!ReactorSelectionMixin.opt_reactorN)r$r%r&r'r�Completionsr��compDatar1r2r��staticmethodrr�r�r�r��opt_rrrrrr��s
r�c
@s�eZdZdZgd�gd�gd�gZgd�gd�gd�dd	d
dd�ej�ggd
�gd�gd�gd�gZe	j
dge	�d�e	�d�e	�d�e	��d�d�Z
eej�Zdd�Zdd�ZeZdd�Zd#dd�Zdd �Zed!d"��Zd	S)$�
ServerOptionszQtwistd reads a twisted.application.service.Application out of a file and runs it.)rFNzBsave the Stats object rather than the text output of the profiler.)�no_save�ozdo not save state on shutdown)r�r!z(The specified tap/aos file is encrypted.)r�lNz%log to a specified file, - for stdout)rNNz�A fully-qualified name to a log observer factory to use for the initial log observer.  Takes precedence over --logfile and --syslog (when available).)r*r7Nz7Run in profile mode, dumping results to specified file.rGNrEz!Name of the profiler to use (%s).z, )r��fz
twistd.tapzread 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�cOs4d|d<d|vr|d|_ntj|_tj�|�dS)NFr�r2)r2r1r�Optionsr)rr+�kwrrrrYs
zServerOptions.__init__cCst�d�t��d|d<dS)z�
        Run the application in the Python Debugger (implies nodaemon),
        sending SIGUSR2 will drop into debugger
        Tr�N)r
�setDebuggingr
�startDebugModertrrr�	opt_debugas
zServerOptions.opt_debugcCs>t�tj�zddl}Wn
tyYdSw|�tj�dS)z�
        Print an insanely verbose log of everything that happens.
        Useful when debugging freezes or locks in complex code.
        rN)r1�settracer�spewer�	threadingr,)rr�rrr�opt_spewls�zServerOptions.opt_spewcCs.|durtjdd�p
dg}tj�||�dS)Nrvz--help)r1�argvrr��parseOptionsrPrrrr�xszServerOptions.parseOptionsc
Csl|js|drd|d<|ddur4zt|d�|d<WdSty3}zt�d�|d|���d}~wwdS)Nr�Tr�rz%Logger '{}' could not be imported: {})r�rr�rr�r�)rr!rrr�postOptions}s����zServerOptions.postOptionsccsT�|�tj�}i|_t|td�d�D]}||j|j<|jd|fdd�|jfVqdS)Nr�r�cSs|��Sr)rK)�plugrrrr��r�z+ServerOptions.subCommands.<locals>.<lambda>)�_getPluginsr�
IServiceMakerr�r�rr�r�)r�pluginsr�rrr�subCommands�s�
��zServerOptions.subCommandsr)r$r%r&�longdesc�optFlags�joinrDrJ�
optParametersrr��
CompleteFiles�CompleteDirsr�r�r�
getPluginsr�rr��opt_br�r�r��propertyrrrrrr�sJ����!��

	
r�c
Csv|�}z|��Wn+tjy4}zd�tjdd��}t|�t|�d|���WYd}~dSd}~ww||�dS)N� rrQr)r�r�errorrr1r�r|)�runAppr�r��ue�commstrrrrr/�s ��r/cCsFt�|||�}t�|��|�t|�}|rd}t�|�j||d�dS)N)r�r�)rr�r�IPersistable�setStyler��save)�filein�typeinr��fileout�typeout�encryptr_rrr�convertStyle�srcCsTddlm}t�|���|rt�|�}|�dd|jd�|�ddt�|�j	�dS)Nrrc�after�shutdown�before)
rgr6r�IService�startServicerr�addSystemEventTriggerr�stopService)r_rr6r7rrr�startApplication�s
�rcCs"t�|tj�t�t��|�dS)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)�sigrrr�_exitWithSignal�sr$)NN)7r�r~r�r�r1r�rY�operatorr�twistedrrr�twisted.applicationrr�twisted.application.reactorsrr	rgr
�twisted.internet.interfacesr�twisted.persistedr�twisted.pythonr
rrrrr�twisted.python.reflectrrrrr)r;rDrLr�r�r�r�r�r�r�r�r�r�r/rrr$rrrr�<module>sD r
3kE~	

Spamworldpro Mini