AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

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

�b( �@s�dZddlZddlZddlZddlZddlZddlZz
ddlZddl	Z
Wn
ey1dZ	dZYnwe
Z	eZddlm
Z
ddlmZddlmZddlmZddlmZmZmZddlmZmZmZdd	lmZdd
lmZddl m!Z!ddl"m#Z#m$Z$dd
l%m&Z&ddl'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m(Z2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAe5d�ZBeBr�ddlCmDZDmEZEmFZFe5d�ZGe5d�ZHe5d�ZIe5d�ZJd d!�ZKGd"d#�d#�ZLGd$d%�d%ejM�ZNGd&d'�d'e;jO�ZPGd(d)�d)eA�ZQeeBd*�Gd+d,�d,eA��ZRGd-d.�d.eA�ZSGd/d0�d0�ZTGd1d2�d2ejU�ZVGd3d4�d4eA�ZWeeBd*�Gd5d6�d6eA��ZXeeBd*�Gd7d8�d8eA��ZYeeBd*�Gd9d:�d:eA��ZZGd;d<�d<�Z[ee#�Gd=d>�d>e[��Z\Gd?d@�d@�Z]GdAdB�dBeA�Z^dCdD�Z_dEdF�Z`GdGdH�dHeA�ZaeeBd*�GdIdJ�dJeA��ZbeeBdK�GdLdM�dMeA��Zcee$�GdNdO�dOe=��ZdGdPdQ�dQe;jO�ZedRdS�ZfGdTdU�dUeA�ZgdS)VzE
Tests for L{twisted.application.app} and L{twisted.scripts.twistd}.
�N)�StringIO)�skipIf)�implementer)�verifyObject)�internet�logger�plugin)�app�reactors�service)�
IServiceMaker)�ReactorBase)�Deferred)�IReactorDaemonize�_ISupportsExitSignalCapturing)�AlternateReactor)�ILogObserver�globalLogBeginner�globalLogPublisher)�util)�
Componentized)�UserDatabase)r�textFromEventDict)�
requireModule)�platformType)�
UsageError)�twistd)�
MemoryReactor)�MockOS)�TestCaseztwistd.scripts._twistd_unix)�UnixApplicationRunner�
UnixAppLogger�checkPIDztwistd.python.syslog�profile�pstats�cProfilec	s|t�t���}t�t����t�}|�||j	|�|j
|j|j����fdd�}|td|j
�|td|�|td|j�dS)au
    Patch L{pwd.getpwnam} so that it behaves as though only one user exists
    and patch L{grp.getgrnam} so that it behaves as though only one group
    exists.

    @param patch: A function like L{TestCase.patch} which will be used to
        install the fake implementations.

    @type user: C{str}
    @param user: The name of the single user which will exist.

    @type uid: C{int}
    @param uid: The UID of the single user which will exist.

    @type group: C{str}
    @param group: The name of the single user which will exist.

    @type gid: C{int}
    @param gid: The GID of the single group which will exist.
    cs<t��}�||��j�<�||��j�<t|�}�|i|S�N)�list�index�gr_name�gr_gid�tuple)�name�result��gid�grent�group��:/usr/lib/python3/dist-packages/twisted/test/test_twistd.py�getgrnamds
z#patchUserDatabase.<locals>.getgrnam�getpwnamr4�getpwuidN)�pwdr6�os�getuid�grp�getgrgid�getgidr�addUser�	pw_passwd�pw_gecos�pw_dir�pw_shellr5)�patch�user�uidr1r/�pwent�databaser4r2r.r3�patchUserDatabaseCs�rGc@�eZdZdZdZdd�ZdS)�MockServiceMakerzO
    A non-implementation of L{twisted.application.service.IServiceMaker}.
    �ueoacCs||_t��|_|jS)ze
        Take a L{usage.Options} instance and return a
        L{service.IService} provider.
        )�optionsr�Service��selfrKr2r2r3�makeServicews
zMockServiceMaker.makeServiceN)�__name__�
__module__�__qualname__�__doc__�tapnamerOr2r2r2r3rIpsrIc@seZdZdZdd�ZdS)�CrippledAppLoggerz*
    @see: CrippledApplicationRunner.
    cC�dSr&r2�rN�applicationr2r2r3�start��zCrippledAppLogger.startN)rPrQrRrSrYr2r2r2r3rU�srUc@s$eZdZdZeZdd�Zdd�ZdS)�CrippledApplicationRunnerz�
    An application runner that cripples the platform-specific runner and
    nasty side-effect-having code so that we can use it without actually
    running any environment-affecting code.
    cCrVr&r2�rNr2r2r3�preApplication�rZz(CrippledApplicationRunner.preApplicationcCrVr&r2r\r2r2r3�postApplication�rZz)CrippledApplicationRunner.postApplicationN)rPrQrRrSrU�
loggerFactoryr]r^r2r2r2r3r[�s
r[c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	e
d�d
d��Ze	e
d�dd��Ze	e
d�dd��Z
dd�Zdd�Zdd�Zdd�ZdS)�ServerOptionsTestszT
    Non-platform-specific tests for the platform-specific ServerOptions class.
    cs�Gdd�d�}|d��|d��|d��|d�������fdd�}t��}��|jtj�||_|j}����g}t||�D]&\}}|\}}	}
}��||j���	|	���|
�|j
�f��||j�q>d	S)
zh
        subCommands is built from IServiceMaker plugins, and is sorted
        alphabetically.
        c@seZdZdd�Zdd�ZdS)z7ServerOptionsTests.test_subCommands.<locals>.FakePlugincSs||_d||_d||_dS)Nzoptions for �description of )rT�_options�description�rNr,r2r2r3�__init__�s
z@ServerOptionsTests.test_subCommands.<locals>.FakePlugin.__init__cS�|jSr&)rbr\r2r2r3rK�sz?ServerOptionsTests.test_subCommands.<locals>.FakePlugin.optionsN)rPrQrRrerKr2r2r2r3�
FakePlugin�srg�apple�banana�coconut�donutc3s*���|t��V�V�V�VdSr&)�assertEqualr)�	interface�rhrirjrkrNr2r3�
getPlugins�s�
z7ServerOptionsTests.test_subCommands.<locals>.getPluginsN)r�
ServerOptionsrl�_getPluginsrro�subCommands�ziprT�assertIsNonerbrc)rNrgro�configrr�
expectedOrder�
subCommand�expectedCommandr,�shortcut�parserClass�
documentationr2rnr3�test_subCommands�s$	
�z#ServerOptionsTests.test_subCommandscs�Gdd�d�}|d��|d��|d��|d������fdd�}t��}��|jtj�||_t�|_��t	|j
d	g�|j���g�����fD]}���fd
d�}||j�||j
�qI���t��d����d
S)zP
        Reactor names are listed alphabetically by I{--help-reactors}.
        c@�eZdZdd�ZdS)zGServerOptionsTests.test_sortedReactorHelp.<locals>.FakeReactorInstallercSsd||_d||_d|_dS)Nzname of raztwisted.internet.default)�	shortNamerc�
moduleNamerdr2r2r3re�s


zPServerOptionsTests.test_sortedReactorHelp.<locals>.FakeReactorInstaller.__init__N)rPrQrRrer2r2r2r3�FakeReactorInstaller��r�rhrirjrkc3s��V�V�V�VdSr&r2r2)rhrirjrkr2r3�getReactorTypes�s
�
zBServerOptionsTests.test_sortedReactorHelp.<locals>.getReactorTypesz--help-reactorscs ��|������|��dSr&)�assertIn�appendr()�s)�
helpOutput�indexesrNr2r3�getIndex�sz;ServerOptionsTests.test_sortedReactorHelp.<locals>.getIndexz9reactor descriptions were not in alphabetical order: {!r}N)rrprl�_getReactorTypesr
r�r�
messageOutput�assertRaises�
SystemExit�parseOptions�getvaluer~rc�sorted�format)rNr�r�ru�reactorr�r2)rhrirjrkr�r�rNr3�test_sortedReactorHelp�s0

��z)ServerOptionsTests.test_sortedReactorHelpcCs(t��}d|_|��|�|d�dS)zS
        postOptions should set no_save to True when a subcommand is used.
        rJ�no_saveN)rrprw�postOptions�
assertTrue�rNrur2r2r3�&test_postOptionsSubCommandCausesNoSave�sz9ServerOptionsTests.test_postOptionsSubCommandCausesNoSavecCs"t��}|��|�|d�dS)zR
        If no sub command is used, postOptions should not touch no_save.
        r�N)rrpr��assertFalser�r2r2r3�(test_postOptionsNoSubCommandSavesAsUsualsz;ServerOptionsTests.test_postOptionsNoSubCommandSavesAsUsualcCs.t��}t|�}tjjD]}|�||�qdS)zq
        All the profilers that can be used in L{app.AppProfiler} are listed in
        the help output.
        N)rrp�strr	�AppProfiler�	profilersr�)rNrur��profilerr2r2r3�test_listAllProfilers
s
�z(ServerOptionsTests.test_listAllProfilers�twistd unix not availablecCst��}|�|d�dS)zG
        The default value for the C{umask} option is L{None}.
        �umaskN)rrprtr�r2r2r3�test_defaultUmasksz$ServerOptionsTests.test_defaultUmaskcCsHt��}|�ddg�|�|dd�|�ddg�|�|dd�dS)zh
        The value given for the C{umask} option is parsed as an octal integer
        literal.
        �--umask�123r��S�0123N)rrpr�rlr�r2r2r3�
test_umasks
zServerOptionsTests.test_umaskcCs t��}|�t|jddg�dS)z�
        If a value is given for the C{umask} option which cannot be parsed as
        an integer, L{UsageError} is raised by L{ServerOptions.parseOptions}.
        r��abcdefN)rrpr�rr�r�r2r2r3�test_invalidUmask(sz$ServerOptionsTests.test_invalidUmaskcC�Ht��}|�t|jddg�}|�|jd�d��|�d|jd�dS)zQ
        C{--logger} with an unimportable module raises a L{UsageError}.
        �--loggerzno.such.module.I.hoperzeLogger 'no.such.module.I.hope' could not be imported: 'no.such.module.I.hope' does not name an object�
N�	rrpr�rr�r��args�
startswith�assertNotIn�rNru�er2r2r3�&test_unimportableConfiguredLogObserver1s�
��z9ServerOptionsTests.test_unimportableConfiguredLogObservercCr�)zP
        C{--logger} with a non-existent object raises a L{UsageError}.
        r�ztwisted.test.test_twistd.FOOBARrz{Logger 'twisted.test.test_twistd.FOOBAR' could not be imported: module 'twisted.test.test_twistd' has no attribute 'FOOBAR'r�Nr�r�r2r2r3�*test_badAttributeWithConfiguredLogObserverAs�
��z=ServerOptionsTests.test_badAttributeWithConfiguredLogObservercCsvddlm}tdkr
d}nd}d�||j|j�}t�}tj|d�}|�t	|j
dg�}|�|jd	�|�
|��|�d	S)
z2
        C{--version} prints the version.
        r)�	copyright�win32z(the Twisted Windows runner)z(the Twisted daemon)ztwistd {} {}
{}
��stdoutz	--versionN)�twistedr�rr��versionrrrpr�r�r��assertIs�coderlr�)rNr�r,�expectedOutputr�rur�r2r2r3�test_versionTs
�zServerOptionsTests.test_versioncCs(t�}tj|d�}|�t|jdg�dS)zI
        Command is printed when an invalid option is requested.
        r�z	web --fooN)rrrpr�rr�)rNr�rur2r2r3�!test_printSubCommandForUsageErrorhsz4ServerOptionsTests.test_printSubCommandForUsageErrorN)rPrQrRrSr|r�r�r�r�r�_twistd_unixr�r�r�r�r�r�r�r2r2r2r3r`�s"+/	






r`r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
CheckPIDTestsz 
    Tests for L{checkPID}.
    cCs |�tjddd��td�dS)z7
        Nonexistent PID file is not an error.
        �existscS�dS�NFr2)�_r2r2r3�<lambda>|�z.CheckPIDTests.test_notExists.<locals>.<lambda>znon-existent PID fileN)rBr8�pathr"r\r2r2r3�test_notExistsxszCheckPIDTests.test_notExistscCs\|��}t|d��
}|�d�Wd�n1swY|�tt|�}|�d|j�dS)zI
        Non-numeric content in a PID file causes a system exit.
        �wznon-numericNznon-numeric value)�mktemp�open�writer�r�r"r�r�)rN�pidfile�fr�r2r2r3�test_nonNumerics�zCheckPIDTests.test_nonNumericcCsr|��}t|d��
}|�d�Wd�n1swYdd�}|�td|�|�tt|�}|�d|j	�dS)zE
        Another running twistd server causes a system exit.
        r��42NcSrVr&r2��pid�sigr2r2r3�kill�rZz/CheckPIDTests.test_anotherRunning.<locals>.killr�zAnother twistd server)
r�r�r�rBr8r�r�r"r�r��rNr�r�r�r�r2r2r3�test_anotherRunning�s�z!CheckPIDTests.test_anotherRunningcCs||��}t|d��}|�tt��d��Wd�n1swYdd�}|�td|�t|�|�tj	�
|��dS)zJ
        Stale PID file is removed without causing a system exit.
        r��NcS�ttjd���N�fake)�OSError�errno�ESRCHr�r2r2r3r���z&CheckPIDTests.test_stale.<locals>.killr�)r�r�r�r�r8�getpidrBr"r�r�r�)rNr�r�r�r2r2r3�
test_stale�s�zCheckPIDTests.test_stalecCs�|��}t|d��
}|�d�Wd�n1swYdd�}|�td|�|�tt|�}|�|j	d�|�
|jd�d��dS)	z�
        An unexpected L{OSError} when checking the validity of a
        PID in a C{pidfile} terminates the process via L{SystemExit}.
        r��3581NcSr�r��r�r��EBADFr�r2r2r3r��r�z2CheckPIDTests.test_unexpectedOSError.<locals>.killr�rzCan't check status of PID)
r�r�r�rBr8r�r�r"�assertIsNotr�r�r�r�r�r2r2r3�test_unexpectedOSError�s�z$CheckPIDTests.test_unexpectedOSErrorN)	rPrQrRrSr�r�r�r�r�r2r2r2r3r�rs
r�c@� eZdZdZdd�Zdd�ZdS)�TapFileTestszM
    Test twistd-related functionality that requires a tap file on disk.
    cCsN|��|_t|jd��}t�t�d�|�Wd�dS1s wYdS)zP
        Create a trivial Application and put it in a tap file on disk.
        �wb�Hi!N)r��tapfiler��pickle�dumpr�Application)rNr�r2r2r3�setUp�s
"�zTapFileTests.setUpcCs<t��}|�d|jg�t|���}|�t�|�j	d�dS)z�
        Ensure that the createOrGetApplication call that 'twistd -f foo.tap'
        makes will load the Application out of foo.tap.
        z-fr�N)
rrpr�r�r[�createOrGetApplicationrlr�IServicer,)rNrurXr2r2r3�&test_createOrGetApplicationWithTapFile�sz3TapFileTests.test_createOrGetApplicationWithTapFileN)rPrQrRrSr�r�r2r2r2r3r��sr�c@�(eZdZdZdd�Zdd�Zdd�ZdS)	�TestLoggerFactoryz8
    A logger factory for L{TestApplicationRunner}.
    cC�
||_dSr&)�runner)rNr�r2r2r3re��
zTestLoggerFactory.__init__cCs"|jj�d�t|jd�|j_dS)zC
        Save the logging start on the C{runner} instance.
        �logrXN)r��orderr��hasattr�hadApplicationLogObserverrWr2r2r3rY�szTestLoggerFactory.startcCr�)z%
        Don't log anything.
        Nr2r\r2r2r3�stop�r�zTestLoggerFactory.stopN)rPrQrRrSrerYr�r2r2r2r3r��s
r�c@r�)	�TestApplicationRunnerz`
    An ApplicationRunner which tracks the environment in which its methods are
    called.
    cCs"tj�||�g|_t|�|_dSr&)r	�ApplicationRunnerrer�r�rrMr2r2r3re�szTestApplicationRunner.__init__cC�|j�d�t|d�|_dS)N�prerX)r�r�r��hadApplicationPreApplicationr\r2r2r3r]��z$TestApplicationRunner.preApplicationcCr�)N�postrX)r�r�r��hadApplicationPostApplicationr\r2r2r3r^�rz%TestApplicationRunner.postApplicationN)rPrQrRrSrer]r^r2r2r2r3r��s
r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zee	e
d
d�d�d
d��Zee	e
d
d�d�dd��Zdd�Z
dd�Zdd�Zdd�ZdS)�ApplicationRunnerTestszR
    Non-platform-specific tests for the platform-specific ApplicationRunner.
    cCs4t��}t�|_d|ji|_t�|_d|_||_dS)N�test_command)	rrprI�serviceMaker�
loadedPlugins�object�
subOptionsrwrur�r2r2r3r��s
zApplicationRunnerTests.setUpcCsLt|j�}|��|�|jj|jjd�|�|jjt�|j	�j
dd�dS)z�
        Ensure that a twistd plugin gets used in appropriate ways: it
        is passed its Options instance, and the service it returns is
        added to the application.
        zKServiceMaker.makeService needs to be passed the correct sub Command object.rzPServiceMaker.makeService's result needs to be set as a child of the Application.N)r[ru�runr�rrKr	rr�rX�services)rN�arunnerr2r2r3�,test_applicationRunnerGetsCorrectApplications
��zCApplicationRunnerTests.test_applicationRunnerGetsCorrectApplicationcCsLt|j�}|��|�|j�|�|j�|�|j�|�|j	gd��dS)z�
        Test thet preApplication and postApplication methods are
        called by ApplicationRunner.run() when appropriate.
        )r�r�rN)
r�rur
r�rr�rr�rlr�)rNr�r2r2r3�test_preAndPostApplications
z1ApplicationRunnerTests.test_preAndPostApplicationc	s�|j�|�g�G�fdd�dtj�}ttjtj�G�fdd�d��}|�}ttj|�ttj|�||j�}|�	�||_
|��|��dddd||fd	d
g�dS)a.
        Assert that given a particular command line, an application is started
        as a particular UID/GID.

        @param argv: A list of strings giving the options to parse.
        @param uid: An integer giving the expected UID.
        @param gid: An integer giving the expected GID.
        cs8eZdZ�fdd�Z�fdd�Z�fdd�Zdd�Zd	S)
z\ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunnerc���d�dS)N�environment�r��rN�chroot�rundir�nodaemonr�r���eventsr2r3�setupEnvironment8�zmApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.setupEnvironmentcs��d|||f�dS)N�
privilegesr)rN�euidrDr/rr2r3�shedPrivileges;szkApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.shedPrivilegescr)Nr�r)rNr��	oldstdout�	oldstderrrr2r3�startReactor>rziApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.startReactorcSrVr&r2)rNr�r2r2r3�	removePIDArZzfApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.removePIDN)rPrQrRrrrr r2rr2r3�FakeUnixApplicationRunner7s
r!cs\eZdZdZdZdZdZdZdZdd�Z	dd�Z
dd�Z�fdd	�Z�fd
d�Z
dd
�ZdS)zNApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeServiceNcSrVr&r2rdr2r2r3�setNameNrZzVApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.setNamecSrVr&r2)rN�parentr2r2r3�setServiceParentQrZz_ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.setServiceParentcSrVr&r2r\r2r2r3�disownServiceParentTrZzbApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.disownServiceParentcr)N�privilegedStartServicerr\rr2r3r&WrzeApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.privilegedStartServicecr)N�startServicerr\rr2r3r'Zrz[ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.startServicecSrVr&r2r\r2r2r3�stopService]rZzZApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.stopService)rPrQrRr#�runningr,�processNamerDr/r"r$r%r&r'r(r2rr2r3�FakeServiceDsr+rr&rFr'r�N)
rur�r�_SomeApplicationRunnerrrr��IProcessrr]rXr^rl)rN�argvrDr/r!r+rXr�r2rr3�"_applicationStartsWithConfiguredID*s*	


��z9ApplicationRunnerTests._applicationStartsWithConfiguredID�setuidNz5Platform does not support --uid/--gid twistd options.cCs*d}d}|�dt|�dt|�g||�dS)a
        L{postApplication} should change the UID and GID to the values
        specified as numeric strings by the configuration after running
        L{service.IService.privilegedStartService} and before running
        L{service.IService.startService}.
        �����--uid�--gidN)r/r�)rNrDr/r2r2r3�.test_applicationStartsWithConfiguredNumericIDsts
�zEApplicationRunnerTests.test_applicationStartsWithConfiguredNumericIDscCs<d}d}d}d}t|j||||�|�d|d|g||�dS)a

        L{postApplication} should change the UID and GID to the values
        specified as user and group names by the configuration after running
        L{service.IService.privilegedStartService} and before running
        L{service.IService.startService}.
        �foor1�barr2r3r4N)rGrBr/)rNrCrDr1r/r2r2r3�+test_applicationStartsWithConfiguredNameIDs�s�zBApplicationRunnerTests.test_applicationStartsWithConfiguredNameIDscCs8t�}t�dddd��}|�|dd�|�|jd�dS)z7
        L{startReactor} calls L{reactor.run}.
        Fr#�r#r��debugNz'startReactor did not call reactor.run())�DummyReactorr	r�rr��called�rNr�r�r2r2r3�test_startReactorRunsTheReactor�s
�z6ApplicationRunnerTests.test_startReactorRunsTheReactorcCsDt�}|�td|�t�dddd��}|�ddd�|�|j�dS)zN
        L{ApplicationRunner} chooses a reactor if none is specified.
        r�Fr#r9N)r;rBrr	r�rr�r<r=r2r2r3�*test_applicationRunnerChoosesReactorIfNone�s
�zAApplicationRunnerTests.test_applicationRunnerChoosesReactorIfNonecCsHGdd�dt�}|�}t�dddd��}|�|dd�|�d|j�dS)zg
        If the reactor exits with a signal, the application runner caches
        the signal.
        c@r�)z[ApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignal��
            A dummy reactor, providing a C{run} method, and setting the
            _exitSignal attribute to a nonzero value.
            cSr��z=
                Dummy method, does nothing.
                Nr2r\r2r2r3�installWaker�r�zhApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignal.installWakercS�
d|_dS)zZ
                A fake run method setting _exitSignal to a nonzero value
                �N��_exitSignalr\r2r2r3r
�s
z_ApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignal.runN�rPrQrRrSrBr
r2r2r2r3�DummyReactorWithSignal��rHFr#r9NrD)r
r	r�r�assertEqualsrF)rNrHr�r�r2r2r3�$test_applicationRunnerCapturesSignal�s
�z;ApplicationRunnerTests.test_applicationRunnerCapturesSignalcCsFGdd�d�}|�}t�dddd��}|�|dd�|�d|j�dS)z�
        The runner sets its _exitSignal instance attribute to None if
        the reactor does not implement L{_ISupportsExitSignalCapturing}.
        c@r�)ziApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttributer@cSr�rAr2r\r2r2r3rB�r�zvApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttribute.installWakercSrC)z�
                A fake run method setting _exitSignal to a nonzero value
                that should be ignored.
                rDNrEr\r2r2r3r
�s
zmApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttribute.runNrGr2r2r2r3�#DummyReactorWithExitSignalAttribute�rIrLFr#r9N)r	r�rrJrF)rNrLr�r�r2r2r3�%test_applicationRunnerIgnoresNoSignal�s
�z<ApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal)rPrQrRrSr�r
rr/r�getattrr8r5r8r>r?rKrMr2r2r2r3r�s(	J�

�
rc@sveZdZdZe�Zdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�*UnixApplicationRunnerSetupEnvironmentTestsa�
    Tests for L{UnixApplicationRunner.setupEnvironment}.

    @ivar root: The root of the filesystem, or C{unset} if none has been
        specified with a call to L{os.chroot} (patched for this TestCase with
        L{UnixApplicationRunnerSetupEnvironmentTests.chroot}).

    @ivar cwd: The current working directory of the process, or C{unset} if
        none has been specified with a call to L{os.chdir} (patched for this
        TestCase with L{UnixApplicationRunnerSetupEnvironmentTests.chdir}).

    @ivar mask: The current file creation mask of the process, or C{unset} if
        none has been specified with a call to L{os.umask} (patched for this
        TestCase with L{UnixApplicationRunnerSetupEnvironmentTests.umask}).

    @ivar daemon: A boolean indicating whether daemonization has been performed
        by a call to L{_twistd_unix.daemonize} (patched for this TestCase with
        L{UnixApplicationRunnerSetupEnvironmentTests}.
    cs��j�_�j�_�j�_d�_t���_��td�fdd����td�fdd����td�fdd��t	t
����_�j
�j_
dS)	NFrc�t�d|�S)N�root��setattr�r�r\r2r3r��zBUnixApplicationRunnerSetupEnvironmentTests.setUp.<locals>.<lambda>�chdircrP)N�cwdrRrTr\r2r3r�
rUr�crP)N�maskrR)rXr\r2r3r�rU)�unsetrQrWrX�daemonr8r�r�rBr rrpr��	daemonizer\r2r\r3r�s
z0UnixApplicationRunnerSetupEnvironmentTests.setUpcs d�_��td�fdd��dS)z�
        Indicate that daemonization has happened and change the PID so that the
        value written to the pidfile can be tested in the daemonization case.
        Tr�cs
�jdS�Nr�)r�r2r\r2r3r�s
zFUnixApplicationRunnerSetupEnvironmentTests.daemonize.<locals>.<lambda>N)rZrBr8�rNr�r2r\r3r[sz4UnixApplicationRunnerSetupEnvironmentTests.daemonizecCs&|j�ddddd�|�|jd�dS)z�
        L{UnixApplicationRunner.setupEnvironment} changes the root of the
        filesystem if passed a non-L{None} value for the C{chroot} parameter.
        �/foo/bar�.TN)r�rrlrQr\r2r2r3�test_chroot�z6UnixApplicationRunnerSetupEnvironmentTests.test_chrootcC�(|j�ddddd�|�|j|j�dS)z�
        L{UnixApplicationRunner.setupEnvironment} does not change the root of
        the filesystem if passed L{None} for the C{chroot} parameter.
        Nr_T)r�rr�rQrYr\r2r2r3�
test_noChroot"sz8UnixApplicationRunnerSetupEnvironmentTests.test_noChrootcCs&|j�ddddd�|�|jd�dS)z�
        L{UnixApplicationRunner.setupEnvironment} changes the working directory
        of the process to the path given for the C{rundir} parameter.
        Nr^T)r�rrlrWr\r2r2r3�test_changeWorkingDirectory*razFUnixApplicationRunnerSetupEnvironmentTests.test_changeWorkingDirectorycCsNtt���|j�ddddd�Wd�n1swY|�|j�dS)z�
        L{UnixApplicationRunner.setupEnvironment} daemonizes the process if
        C{False} is passed for the C{nodaemon} parameter.
        Nr_F)r�FakeDaemonizingReactorr�rr�rZr\r2r2r3�test_daemonize2s�z9UnixApplicationRunnerSetupEnvironmentTests.test_daemonizecCs$|j�ddddd�|�|j�dS)z�
        L{UnixApplicationRunner.setupEnvironment} does not daemonize the
        process if C{True} is passed for the C{nodaemon} parameter.
        Nr_T)r�rr�rZr\r2r2r3�test_noDaemonize;sz;UnixApplicationRunnerSetupEnvironmentTests.test_noDaemonizecCsd|��}|j�dddd|�t|d��}t|���}Wd�n1s$wY|�||j�dS)z�
        L{UnixApplicationRunner.setupEnvironment} writes the process's PID to
        the file specified by the C{pidfile} parameter.
        Nr_T�rb)r�r�rr��int�readrlr��rNr�r�r�r2r2r3�test_nonDaemonPIDFileCs�z@UnixApplicationRunnerSetupEnvironmentTests.test_nonDaemonPIDFilecCs�|��}tt���|j�dddd|�Wd�n1swYt|d��}t|���}Wd�n1s9wY|�||j	d�dS)z�
        L{UnixApplicationRunner.setupEnvironment} writes the daemonized
        process's PID to the file specified by the C{pidfile} parameter if
        C{nodaemon} is C{False}.
        Nr_Frhr�)
r�rrer�rr�rirjrlr�rkr2r2r3�test_daemonPIDFileNs��z=UnixApplicationRunnerSetupEnvironmentTests.test_daemonPIDFilecCsPtt���|j�ddddd�Wd�n1swY|�|jd�dS)z�
        L{UnixApplicationRunner.setupEnvironment} changes the process umask to
        the value specified by the C{umask} parameter.
        Nr_F�{�rrer�rrlrXr\r2r2r3r�[s�z5UnixApplicationRunnerSetupEnvironmentTests.test_umaskcCrb)z�
        L{UnixApplicationRunner.setupEnvironment} doesn't change the process
        umask if L{None} is passed for the C{umask} parameter and C{True} is
        passed for the C{nodaemon} parameter.
        Nr_T)r�rr�rXrYr\r2r2r3�test_noDaemonizeNoUmaskdszBUnixApplicationRunnerSetupEnvironmentTests.test_noDaemonizeNoUmaskcCsPtt���|j�ddddd�Wd�n1swY|�|jd�dS)z�
        L{UnixApplicationRunner.setupEnvironment} changes the process umask to
        C{0077} if L{None} is passed for the C{umask} parameter and C{False} is
        passed for the C{nodaemon} parameter.
        Nr_F�?ror\r2r2r3�test_daemonizedNoUmaskms�zAUnixApplicationRunnerSetupEnvironmentTests.test_daemonizedNoUmaskN)rPrQrRrSrrYr�r[r`rcrdrfrgrlrmr�rprrr2r2r2r3rO�s	
		rOc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�*UnixApplicationRunnerStartApplicationTestsz>
    Tests for L{UnixApplicationRunner.startApplication}.
    cs�t��}|�gd��t�d�}t|�|_g��fdd�}t�|jj	�j
}t�|�j
}|��}|�d�|�
||�|�td|�|�tddd	��|�td
dd	��|j�|�|�
�gd��d
S)z�
        L{UnixApplicationRunner.startApplication} calls
        L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
        nodaemon, umask, and pidfile parameters from the configuration it is
        constructed with.
        )	�
--nodaemonr��0070z--chroot�/foo/chrootz--rundir�/foo/rundirz	--pidfile�/foo/pidfile�test_setupEnvironmentcs��|||||f�dSr&)�extendr�r�r2r3�fakeSetupEnvironment�sz^UnixApplicationRunnerStartApplicationTests.test_setupEnvironment.<locals>.fakeSetupEnvironmentrNrrc_rVr&r2��a�kwr2r2r3r��r�zRUnixApplicationRunnerStartApplicationTests.test_setupEnvironment.<locals>.<lambda>�startApplicationc_rVr&r2r}r2r2r3r��r�)rvrwT�8rxN)rrpr�rr�r r��inspect�	signaturer�
parameters�copy�poprlrBr	r�)rNrKrXr|�setupEnvironmentParameters�fakeSetupEnvironmentParametersr2r{r3ry~s4�

����
z@UnixApplicationRunnerStartApplicationTests.test_setupEnvironmentcs4�fdd�}��td|�ti�}|�ddd�dS)zf
        L{UnixApplicationRunner.shedPrivileges} switches the user ID
        of the process.
        cs(��|d���|d���|d�dS)N���6�#�rl�rDr/rr\r2r3�
switchUIDPass�szUUnixApplicationRunnerStartApplicationTests.test_shedPrivileges.<locals>.switchUIDPass�	switchUIDr�r�r�N)rBr�r r)rNr�r�r2r\r3�test_shedPrivileges�sz>UnixApplicationRunnerStartApplicationTests.test_shedPrivilegescCsDdd�}ti�}|�td|�|�t|jddd�}|�|jd�dS)z�
        An unexpected L{OSError} when calling
        L{twisted.scripts._twistd_unix.shedPrivileges}
        terminates the process via L{SystemExit}.
        cSr�r�r�r�r2r2r3�
switchUIDFail�r�zZUnixApplicationRunnerStartApplicationTests.test_shedPrivilegesError.<locals>.switchUIDFailr�r�r�Nr�)r rBr�r�r�rrlr�)rNr�r��excr2r2r3�test_shedPrivilegesError�s
zCUnixApplicationRunnerStartApplicationTests.test_shedPrivilegesErrorcs�t�j|�|�����fdd�}��fdd�}��fdd�}��td|���td|���td	|�t��}|�d
dt��g�t�	d�}	t
|��_t
|�}
|
�|	�d
S)zj
        Common code for tests which try to pass the the UID to
        L{UnixApplicationRunner}.
        cs��|����|��dSr&r�)rDr/�rN�	wantedGid�	wantedUidr2r3�
initgroups�rzFUnixApplicationRunnerStartApplicationTests._setUID.<locals>.initgroupsc���|��dSr&r�)rD)rNr�r2r3r0��zBUnixApplicationRunnerStartApplicationTests._setUID.<locals>.setuidcr�r&r�)r/)rNr�r2r3�setgid�r�zBUnixApplicationRunnerStartApplicationTests._setUID.<locals>.setgidr�r0r�rtr3ryN)
rGrBrr8rrpr�r�rr�r r�r�)rN�
wantedUserr��wantedGroupr�r�r0r�rKrXr�r2r�r3�_setUID�s

z2UnixApplicationRunnerStartApplicationTests._setUIDcCs|�dddd�dS)z�
        Starting an application with L{UnixApplicationRunner} configured
        with a UID and no GUID will result in the GUID being
        set to the default GUID for that UID.
        r6ir7i�N)r�r\r2r2r3�test_setUidWithoutGid�sz@UnixApplicationRunnerStartApplicationTests.test_setUidWithoutGidcCsTt��}|�d|dd�|��}|�dt|��d�||�}|�||dd�dS)	zz
        If the specified UID is the same as the current UID of the process,
        then a warning is displayed.
        �morefoo�morebari�r�z\tried to drop privileges and setuid {} but uid is already {}; should we be root? Continuing.r�messageN)r8r9r��
flushWarningsrl�lenr�)rN�
currentUid�
warningsShown�expectedWarningr2r2r3�test_setUidSameAsCurrentUid�s�zFUnixApplicationRunnerStartApplicationTests.test_setUidSameAsCurrentUidN)
rPrQrRrSryr�r�r�r�r�r2r2r2r3rsxs4rsc@r�)�#UnixApplicationRunnerRemovePIDTestsz7
    Tests for L{UnixApplicationRunner.removePID}.
    cCsVti�}|��}t�|�tj�|d�}t|d���|�|�|�	tj�
|��dS)zp
        L{UnixApplicationRunner.removePID} deletes the file the name of
        which is passed to it.
        zfoo.pidr�N)r r�r8�makedirsr��joinr��closer r�r�)rNr�r�r�r2r2r3�test_removePIDs

z2UnixApplicationRunnerRemovePIDTests.test_removePIDcCsFti�}|�d�|�t�}|�t|�d�|�|djjtj�dS)zr
        Calling L{UnixApplicationRunner.removePID} with a non-existent filename
        logs an OSError.
        �fakepidr�rN)	r r �flushLoggedErrorsr�rlr��valuer��ENOENT)rNr��errorsr2r2r3�test_removePIDErrorss


z8UnixApplicationRunnerRemovePIDTests.test_removePIDErrorsN)rPrQrRrSr�r�r2r2r2r3r�s
r�c@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�FakeNonDaemonizingReactora�
    A dummy reactor, providing C{beforeDaemonize} and C{afterDaemonize}
    methods, but not announcing this, and logging whether the methods have been
    called.

    @ivar _beforeDaemonizeCalled: if C{beforeDaemonize} has been called or not.
    @type _beforeDaemonizeCalled: C{bool}
    @ivar _afterDaemonizeCalled: if C{afterDaemonize} has been called or not.
    @type _afterDaemonizeCalled: C{bool}
    cCsd|_d|_dSr�)�_beforeDaemonizeCalled�_afterDaemonizeCalledr\r2r2r3re0s
z"FakeNonDaemonizingReactor.__init__cC�
d|_dS�NT)r�r\r2r2r3�beforeDaemonize4r�z)FakeNonDaemonizingReactor.beforeDaemonizecCr�r�)r�r\r2r2r3�afterDaemonize7r�z(FakeNonDaemonizingReactor.afterDaemonizecOr�)z*
        Skip event registration.
        Nr2)rNr�rr2r2r3�addSystemEventTrigger:r�z/FakeNonDaemonizingReactor.addSystemEventTriggerN)rPrQrRrSrer�r�r�r2r2r2r3r�$sr�c@seZdZdZdS)rez�
    A dummy reactor, providing C{beforeDaemonize} and C{afterDaemonize}
    methods, announcing this, and logging whether the methods have been called.
    N)rPrQrRrSr2r2r2r3re@srec@rH)r;z�
    A dummy reactor, only providing a C{run} method and checking that it
    has been called.

    @ivar called: if C{run} has been called or not.
    @type called: C{bool}
    FcCs|jrtd��d|_dS)zV
        A fake run method, checking that it's been called one and only time.
        zAlready calledTN)r<�RuntimeErrorr\r2r2r3r
Ss
�DummyReactor.runN)rPrQrRrSr<r
r2r2r2r3r;Hsr;c@s�eZdZdZeed�dd��Zdd�Zeed�dd��Zd	d
�Z	eed�dd��Z
eed
�dd��Zeed
�dd��Z
dd�Zdd�Zdd�Zdd�ZdS)�AppProfilingTestsz'
    Tests for L{app.AppProfiler}.
    zprofile module not availablecCs�t��}|��|d<d|d<t�|�}t�}|�|�|�|j�t	|d��}|�
�}Wd�n1s6wY|�d|�|�d|�dS)z�
        L{app.ProfileRunner.run} should call the C{run} method of the reactor
        and save profile data in the specified file.
        r#r�Nr��function calls�rrpr�r	r�r;r
r�r<r�rjr��rNrur�r�r��datar2r2r3�test_profilea�


�zAppProfilingTests.test_profilecCsPt�}|�td|�}||�}|��|��|��}|�d|�|�d|�dS)Nr�r�z(run))rrB�sys�print_stats�restorer�r�)rN�
statsClassr#�outr��statsr�r2r2r3�
_testStatsuszAppProfilingTests._testStatscCs`t��}|��|d<d|d<d|d<t�|�}t�}|�|�|�|j�|�	t
j|d�dS)z�
        With the C{savestats} option specified, L{app.ProfileRunner.run}
        should save the raw stats object instead of a summary output.
        r#r�T�	savestatsN�rrpr�r	r�r;r
r�r<r�r$�Stats�rNrur�r�r2r2r3�test_profileSaveStats�s

z'AppProfilingTests.test_profileSaveStatsc	Csttj��}t��}d|d<t�|�}dtjd<z|�t|j	d�Wtj�
�tj�|�dStj�
�tj�|�w)z�
        When the C{profile} module is not present, L{app.ProfilerRunner.run}
        should raise a C{SystemExit} exception.
        r#r�N�r��modulesr�rrpr	r�r�r�r
�clear�update�rN�savedModulesrur�r2r2r3�test_withoutProfile�s




�z%AppProfilingTests.test_withoutProfilecCstGdd�dtj�}|�td|�t��}|��|d<d|d<t�|�}t�}t	j
}|�t|j
|�|�t	j
|�dS)z�
        When an error happens during the print of the stats, C{sys.stdout}
        should be restored to its initial value.
        c@r})zGAppProfilingTests.test_profilePrintStatsError.<locals>.ErroneousProfilecSstd��)N�Boom�r�r\r2r2r3r���zSAppProfilingTests.test_profilePrintStatsError.<locals>.ErroneousProfile.print_statsN)rPrQrRr�r2r2r2r3�ErroneousProfile�r�r��Profiler#r�N)r#r�rBrrpr�r	r�r;r�r�r�r�r
r�)rNr�rur�r��	oldStdoutr2r2r3�test_profilePrintStatsError�s
z-AppProfilingTests.test_profilePrintStatsErrorzcProfile module not availablecCs�t��}|��|d<d|d<t�|�}t�}|�|�|�|j�t	|d��}|�
�}Wd�n1s6wY|�d|�|�d|�dS)z�
        L{app.CProfileRunner.run} should call the C{run} method of the
        reactor and save profile data in the specified file.
        r#r%r�Nr
r�r�r�r2r2r3�
test_cProfile�r�zAppProfilingTests.test_cProfilecCs`t��}|��|d<d|d<d|d<t�|�}t�}|�|�|�|j�|�	t
j|d�dS)z�
        With the C{savestats} option specified,
        L{app.CProfileRunner.run} should save the raw stats object
        instead of a summary output.
        r#r%r�Tr�Nr�r�r2r2r3�test_cProfileSaveStats�s

z(AppProfilingTests.test_cProfileSaveStatsc	Csttj��}dtjd<t��}d|d<t�|�}z|�t|j	d�Wtj�
�tj�|�dStj�
�tj�|�w)z�
        When the C{cProfile} module is not present,
        L{app.CProfileRunner.run} should raise a C{SystemExit}
        exception and log the C{ImportError}.
        Nr%r�r�r�r2r2r3�test_withoutCProfile�s




�z&AppProfilingTests.test_withoutCProfilecCs@t��}|��|d<d|d<|�ttj|�}|�t|�d�dS)zq
        Check that L{app.AppProfiler} raises L{SystemExit} when given an
        unknown profiler name.
        r#�foobarr�z!Unsupported profiler name: foobarN)	rrpr�r�r�r	r�rlr�)rNru�errorr2r2r3�test_unknownProfiler�s
z&AppProfilingTests.test_unknownProfilercCst�i�}|�|jd�dS)zU
        L{app.Profiler} defaults to the cprofile profiler if not specified.
        �cprofileN�r	r�rlr��rNr�r2r2r3�test_defaultProfilers
z&AppProfilingTests.test_defaultProfilercCs t�ddi�}|�|jd�dS)ze
        The case of the profiler name passed to L{app.AppProfiler} is not
        relevant.
        r��CprOfiler�Nr�r�r2r2r3�test_profilerNameCaseInsentive
sz0AppProfilingTests.test_profilerNameCaseInsentiveN)rPrQrRrSrr#r�r�r�r�r�r%r�r�r�r�r�r�r2r2r2r3r�\s$









r�cs(g�tj���fdd�}|td|��S)a
    Patch L{logger.textFileLogObserver} to record every call and keep a
    reference to the passed log file for tests.

    @param patch: a callback for patching (usually L{TestCase.patch}).

    @return: the list that keeps track of the log files.
    @rtype: C{list}
    cs ��|��|g|�Ri|��Sr&r)�logFiler��kwargs��logFiles�oldFileLogObserverr2r3�observer#s
z+_patchTextFileLogObserver.<locals>.observer�textFileLogObserver)rr�)rBr�r2r�r3�_patchTextFileLogObservers

r�cs(g�G�fdd�d�}|�td|��S)zu
    Make fake syslog, and return list to which prefix and then log
    messages will be appended if it is used.
    cs$eZdZ�fdd�Z�fdd�ZdS)z(_setupSyslog.<locals>.fakesyslogobserverc���|�dSr&r)rN�prefix��logMessagesr2r3re3rz1_setupSyslog.<locals>.fakesyslogobserver.__init__cr�r&r)rN�	eventDictr�r2r3�emit6rz-_setupSyslog.<locals>.fakesyslogobserver.emitN)rPrQrRrer�r2r�r2r3�fakesyslogobserver2sr��SyslogObserver)rB�syslog)�testCaser�r2r�r3�_setupSyslog+sr�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ie
jfdd�Zdd�Z
dd�Zdd�Zdd�Zeed�eed�dd���Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(S))�AppLoggerTestsz�
    Tests for L{app.AppLogger}.

    @ivar observers: list of observers installed during the tests.
    @type observers: C{list}
    c�$g�_�fdd�}��td|�dS)z�
        Override L{globaLogBeginner.beginLoggingTo} so that we can trace the
        observers installed in C{self.observers}.
        cs$|D]
}�j�|�t�|�qdSr&)�	observersr�r�addObserver)rr�r\r2r3�beginLoggingToLs�z,AppLoggerTests.setUp.<locals>.beginLoggingTorN)rrBr)rNrr2r\r3r�EszAppLoggerTests.setUpcCs|jD]}t�|�qdS)z1
        Remove all installed observers.
        N)rr�removeObserver�rNr�r2r2r3�tearDownSs
�zAppLoggerTests.tearDowncCstt�Gdd�d��}|�S)z�
        Make a new observer which captures all logs sent to it.

        @return: An observer that stores all logs sent to it.
        @rtype: Callable that implements L{ILogObserver}.
        c@seZdZgZdd�ZdS)z2AppLoggerTests._makeObserver.<locals>.TestObservercSs|j�|�dSr&)�_logsr�)rN�eventr2r2r3�__call__fr�z;AppLoggerTests._makeObserver.<locals>.TestObserver.__call__N)rPrQrRrrr2r2r2r3�TestObserverbsr	)rr)rNr	r2r2r3�
_makeObserverZszAppLoggerTests._makeObservercCs@|�|j|g�|�d|jdd�|�d|jdd�dS)z�
        Ensure that initial C{twistd} logs are written to logs.

        @param observer: The observer made by L{self._makeObserver).
        �starting upr�
log_formatz
reactor classr�N)rlrr�rrr2r2r3�_checkObserverkszAppLoggerTests._checkObservercs:t�i�}|����fdd�|_|�t��|���dS)z�
        L{app.AppLogger.start} calls L{globalLogBeginner.addObserver}, and then
        writes some messages about twistd and the reactor.
        c��Sr&r2r2�r�r2r3r�|r�z+AppLoggerTests.test_start.<locals>.<lambda>N)r	�	AppLoggerr
�_getLogObserverrYrr
)rNrr2rr3�
test_startus

zAppLoggerTests.test_startcCs<t�}|��}|�t|�t�i�}|�|�|�|�dS)z�
        When the L{ILogObserver} component is available on the application,
        that object will be used as the log observer instead of constructing a
        new one.
        N)rr
�setComponentrr	rrYr
)rNrXr�rr2r2r3�$test_startUsesApplicationLogObserver�s

z3AppLoggerTests.test_startUsesApplicationLogObservercs8|���d�fdd�i}|�|�||�}|�|��S)a
        Set up an AppLogger which exercises the C{logger} configuration option.

        @type application: L{Componentized}
        @param application: The L{Application} object to pass to
            L{app.AppLogger.start}.
        @type extraLogArgs: C{dict}
        @param extraLogArgs: extra values to pass to AppLogger.
        @type appLogger: L{AppLogger} class, or a subclass
        @param appLogger: factory for L{AppLogger} instances.

        @rtype: C{list}
        @return: The logs accumulated by the log observer.
        rcrr&r2r2rr2r3r��r�z7AppLoggerTests._setupConfiguredLogger.<locals>.<lambda>)r
r�rY)rNrX�extraLogArgs�	appLogger�logArgsrr2rr3�_setupConfiguredLogger�s

z%AppLoggerTests._setupConfiguredLoggercCst�}|�|�|��dS)a
        When the C{logger} key is specified in the configuration dictionary
        (i.e., when C{--logger} is passed to twistd), the initial log observer
        will be the log observer returned from the callable which the value
        refers to in FQPN form.
        N)rr
rrWr2r2r3�#test_startUsesConfiguredLogObserver�sz2AppLoggerTests.test_startUsesConfiguredLogObservercCs<|��}t�}|�t|�|�|�|��|�|jg�dS)zk
        C{--logger} takes precedence over a L{ILogObserver} component set on
        Application.
        N)r
rrrr
rrlr)rNr�rXr2r2r3�(test_configuredLogObserverBeatsComponent�s
z7AppLoggerTests.test_configuredLogObserverBeatsComponentcCs8g}t�}|�t|j�|�|�|��|�|g�dS)zq
        C{--logger} takes precedence over a L{LegacyILogObserver} component
        set on Application.
        N)rr�LegacyILogObserverr�r
rrl)rN�nonlogsrXr2r2r3�.test_configuredLogObserverBeatsLegacyComponent�s
z=AppLoggerTests.test_configuredLogObserverBeatsLegacyComponentcCsZg}|��}t�}|�t|�|�t|j�t�i�}|�|�|�	|�|�
|g�dS)zw
        A L{ILogObserver} takes precedence over a L{LegacyILogObserver}
        component set on Application.
        N)r
rrrrr�r	rrYr
rl)rNrr�rXrr2r2r3�.test_loggerComponentBeatsLegacyLoggerComponent�s


z=AppLoggerTests.test_loggerComponentBeatsLegacyLoggerComponentr�zsyslog not availablecCs6t|�}t�}|�|�|ddit��|�|g�dS)z`
        C{--logger} takes precedence over a C{--syslog} command line
        argument.
        r�TN)r�rr
rr!rl)rN�logsrXr2r2r3�%test_configuredLogObserverBeatsSyslog�s�z4AppLoggerTests.test_configuredLogObserverBeatsSyslogcCs:t�}|��}|�|�|ddi��|�tj�|��dS)za
        C{--logger} takes precedence over a C{--logfile} command line
        argument.
        �logfiler�N)rr�r
rr�r8r�r�)rNrXr�r2r2r3�&test_configuredLogObserverBeatsLogfile�s�z5AppLoggerTests.test_configuredLogObserverBeatsLogfilecCs~t�ddi�}t|j�}|��|�t|�d�|�|dtj	�t�ddi�}|��|�t|�d�|�|dtj	�dS)z�
        When logfile is empty or set to C{-}, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at C{sys.stdout}.
        r!�-r�r�rDN)
r	rr�rBrrlr�r�r�r�)rNrr�r2r2r3�test_getLogObserverStdout�s
z(AppLoggerTests.test_getLogObserverStdoutcCsdt|j�}|��}t�d|i�}|��}|�|jj�|�	t
|�d�|�	|djtj�
|��dS)z�
        When passing the C{logfile} option, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at the specified path.
        r!r�rN)r�rBr�r	rr�
addCleanup�_outFiler�rlr�r�r8�abspath)rNr��filename�sutr�r2r2r3�test_getLogObserverFiles
z&AppLoggerTests.test_getLogObserverFilecspg�t�}�fdd�}|�td|�t�i�}||_|��|��|g�|��|��|g�|�|j�dS)z�
        L{app.AppLogger.stop} removes the observer created in C{start}, and
        reinitialize its C{_observer} so that if C{stop} is called several
        times it doesn't break.
        cs��|�dSr&rr��removedr2r3�removerz(AppLoggerTests.test_stop.<locals>.removerN)	rrBrr	r�	_observerr�rlrt)rNr�r.rr2r,r3�	test_stops
zAppLoggerTests.test_stopcszg�t�i�}tt�G�fdd�d����fdd�|_|�t��|�dt�d��|�	|j
g�}|�t|�d|�dS)zt
        L{app.AppLogger} using a legacy logger observer still works, wrapping
        it in a compat shim.
        cseZdZdZ�fdd�ZdS)z;AppLoggerTests.test_legacyObservers.<locals>.LoggerObserverzX
            An observer which implements the legacy L{LegacyILogObserver}.
            cs��|�dS)z<
                Add C{x} to the logs list.
                Nr)rN�x�rr2r3r5szDAppLoggerTests.test_legacyObservers.<locals>.LoggerObserver.__call__N)rPrQrRrSrr2r2r2r3�LoggerObserver/sr3cs��Sr&r2r2)r3r2r3r�;�z5AppLoggerTests.test_legacyObservers.<locals>.<lambda>rrN)
r	rrr�_observerFactoryrYrr�rr��test_legacyObserversrlr��rNr�warningsr2)r3rr3r6's
z#AppLoggerTests.test_legacyObserverscstg�t�i�}�fdd�|_|�t��|�dt�d��|�|jg�}|�	t
|�d|�|�	|ddd�dS)	z�
        L{app.AppLogger} using a logger observer which does not implement
        L{ILogObserver} or L{LegacyILogObserver} will be wrapped in a compat
        shim and raise a L{DeprecationWarning}.
        cs�jSr&rr2r2r2r3r�Jr4zAAppLoggerTests.test_unmarkedObserversDeprecated.<locals>.<lambda>rrr�r�aZPassing 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.N)r	rrrYrr�rr�� test_unmarkedObserversDeprecatedrlr�r7r2r2r3r9Bs

�z/AppLoggerTests.test_unmarkedObserversDeprecatedN)rPrQrRrSr�rr
r
rrr	rrrrrrrr�r�r r"r%r+r0r6r9r2r2r2r3r�=s.

�


r�c@sTeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
ed�dd��ZdS)�UnixAppLoggerTestszw
    Tests for L{UnixAppLogger}.

    @ivar signals: list of signal handlers installed.
    @type signals: C{list}
    cr�)zs
        Fake C{signal.signal} for not installing the handlers but saving them
        in C{self.signals}.
        cs�j�||f�dSr&)�signalsr�)r�r�r\r2r3�
fakeSignalpsz,UnixAppLoggerTests.setUp.<locals>.fakeSignal�signalN)r;rBr=)rNr<r2r\r3r�iszUnixAppLoggerTests.setUpcCs~t|j�}tddd��}|��|�t|�d�|�|dtj�tddd��}|��|�t|�d�|�|dtj�dS)	z�
        When non-daemonized and C{logfile} is empty or set to C{-},
        L{UnixAppLogger._getLogObserver} returns a log observer pointing at
        C{sys.stdout}.
        r#T�r!rr�rr$rDN)	r�rBr!rrlr�r�r�r��rNr�rr2r2r3r%us
z,UnixAppLoggerTests.test_getLogObserverStdoutcCs0tddd��}|�t|j�}|�t|�d�dS)z
        When daemonized and C{logfile} is set to C{-},
        L{UnixAppLogger._getLogObserver} raises C{SystemExit}.
        r#Fr>z&Daemons cannot log to stdout, exiting!N)r!r�r�rrlr�)rNrr�r2r2r3�test_getLogObserverStdoutDaemon�sz2UnixAppLoggerTests.test_getLogObserverStdoutDaemoncs�t|j�}|��}td|i�}|��}|�|jj�|�t	|�d�|�|dj
tj
�|��|�t	|j
�d�|�|j
ddtj�t���fdd�}||d_|j
dd}|dd��S)z�
        When C{logfile} contains a file name, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at the specified path, and a signal
        handler rotating the log is installed.
        r!r�rcs��d�dSr&)�callbackr2��dr2r3�rotate�rz:UnixAppLoggerTests.test_getLogObserverFile.<locals>.rotateN)r�rBr�r!rr&r'r�rlr�r�r8r(r;r=�SIGUSR1rrD)rNr�r)r*r�rD�	rotateLogr2rBr3r+�s


z*UnixAppLoggerTests.test_getLogObserverFilecsV�fdd�}��td|����}td|i�}|��}��|jj����j	g�dS)zy
        If a signal handler is already installed,
        L{UnixAppLogger._getLogObserver} doesn't override it.
        cs��|tj�t�Sr&)rlr=rEr)r�r\r2r3�
fakeGetSignal�szVUnixAppLoggerTests.test_getLogObserverDontOverrideSignalHandler.<locals>.fakeGetSignal�	getsignalr!N)
rBr=r�r!rr&r'r�rlr;)rNrGr)r*r�r2r\r3�,test_getLogObserverDontOverrideSignalHandler�sz?UnixAppLoggerTests.test_getLogObserverDontOverrideSignalHandlercCsNt|j�}tddd��}|��|�t|�d�|�|djtj�d��dS)z�
        When daemonized and C{logfile} is empty, the observer returned by
        L{UnixAppLogger._getLogObserver} points at C{twistd.log} in the current
        directory.
        r$Fr>r�rz
twistd.logN)	r�rBr!rrlr�r�r8r(r?r2r2r3�test_getLogObserverDefaultFile�s

z1UnixAppLoggerTests.test_getLogObserverDefaultFiler�cCsPt|�}tddd��}|��}|�|dg�|ddi�|�|dddig�dS)z�
        If C{syslog} is set to C{True}, L{UnixAppLogger._getLogObserver} starts
        a L{syslog.SyslogObserver} with given C{prefix}.
        Tztest-prefix)r�r�r~�bN)r�r!rrl)rNrrr�r2r2r3�test_getLogObserverSyslog�sz,UnixAppLoggerTests.test_getLogObserverSyslogN)
rPrQrRrSr�r%r@r+rIrJrr�rLr2r2r2r3r:`s	

r:z!twistd unix support not availablec@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)#�DaemonizeTestszH
    Tests for L{_twistd_unix.UnixApplicationRunner} daemonization.
    cCsbt�|_t��|_|�td|j�t�|j�|_t	�
d�|j_tj
|j_tj|j_dd�|j_dS)Nr8r�cWrVr&r2r{r2r2r3r��r�z&DaemonizeTests.setUp.<locals>.<lambda>)r�mockosrrprurBr�r r�rr�rXr�r�r�stderrrrr\r2r2r3r��s


zDaemonizeTests.setUpcCs`tt���
|j��Wd�n1swY|�|jjgd��|�|jjddg�dS)zw
        When double fork succeeded in C{daemonize}, the child process writes
        B{0} to the status pipe.
        N)�rVr_�r�rq��forkT�setsidrR)r�����0��unlinkz
twistd.pid���rU)rrer�r^rlrN�actions�closedr\r2r2r3�test_success�s��zDaemonizeTests.test_successcCstd|j_d|j_tt���|�t|jj�Wd�n1s wY|�	|jj
gd��|�	|jjdg�dS)z�
        The parent process initiating the C{daemonize} call reads data from the
        status pipe and then exit the process.
        FrVN)rPrQrR�rj����d��exitrrWr^)rN�child�readDatarrer��SystemErrorr�r^rlrZr[r\r2r2r3�test_successInParents��z#DaemonizeTests.test_successInParentcs�g��fdd�}||j_tt���
|j��Wd�n1s!wY|�|jjgd��|�|jjddg�|�ddg��dS)z�
        If the C{os.write} call to the status pipe raises an B{EINTR} error,
        the process child retries to write.
        cs(��||f�t��dkrttj��dSr\�r�r�r�r��EINTR)�fdr���writtenr2r3�raisingWrites
�z6DaemonizeTests.test_successEINTR.<locals>.raisingWriteN)rPrQrRrTrRrWrYrU)rUrV)	rNr�rrer�r^rlrZr[)rNrkr2rir3�test_successEINTRs��z DaemonizeTests.test_successEINTRcs�g��fdd�}||j_d|j_tt���|�t|jj�Wd�n1s(wY|�	|jj
gd��|�	|jjdg�|�	ddg��dS)z
        If the C{os.read} call on the status pipe raises an B{EINTR} error, the
        parent child retries to read.
        cs(��||f�t��dkrttj��dS)Nr�rVrf)rh�size�rjr2r3�raisingRead;s
z=DaemonizeTests.test_successInParentEINTR.<locals>.raisingReadFN)rPrQrRr`rWr^)r^r_)rNrjrbrrer�rdr�r^rlrZr[)rNror2rnr3�test_successInParentEINTR4s��
z(DaemonizeTests.test_successInParentEINTRcs�G�fdd�dtj�}|�}|�|jj�tt���|�t|jj	�Wd�n1s-wY|�
|jjddddddd	|fd
g�|�
|jj
dd	g�dS)z�
        Assert L{UnixApplicationRunner.postApplication} writes
        C{reported} to its status pipe if the service raises an
        exception whose message is C{raised}.
        cseZdZ�fdd�ZdS)z6DaemonizeTests.assertErrorWritten.<locals>.FakeServicecst���r&r�r\��raisedr2r3r'Zr�zCDaemonizeTests.assertErrorWritten.<locals>.FakeService.startServiceN)rPrQrRr'r2rqr2r3r+Ysr+NrPrQrRrTr�rUrWrY)rrLr$r�rXrrer�r�r^rlrNrZr[)rNrr�reportedr+�errorServicer2rqr3�assertErrorWrittenRs$���z!DaemonizeTests.assertErrorWrittencC�|jddd�dS)z�
        If an error happens during daemonization, the child process writes the
        exception error to the status pipe.
        zSomething is wrongs"1 RuntimeError: Something is wrong�rrrsN�rur\r2r2r3�
test_errorp�
�zDaemonizeTests.test_errorcCrv)z�
        If an error happens during daemonization, and that error's
        message is Unicode, the child encodes the message as ascii
        with backslash Unicode code points.
        u•s1 RuntimeError: \u2022rwNrxr\r2r2r3�test_unicodeErrorysz DaemonizeTests.test_unicodeErrorcCs�d|j_||j_t�}|�td|�tt���|�t	|j
j�Wd�n1s*wY|�|�
�|�|�|jj|�|�|jjdg�dS)a
        Make L{os.read} appear to return C{readData}, and assert that
        L{UnixApplicationRunner.postApplication} writes
        C{errorMessage} to standard error and executes the calls
        against L{os} functions specified in C{mockOSActions}.
        F�
__stderr__Nr^)rNrbrcrrBr�rrer�rdr�r^rlr�rZr[)rNrc�errorMessage�
mockOSActions�errorIOr2r2r3�assertErrorInParentBehavior�s�z*DaemonizeTests.assertErrorInParentBehaviorcC�|jddgd�d�dS)z�
        When the child writes an error message to the status pipe
        during daemonization, the parent writes the repr of the
        message to C{stderr} and exits with non-zero status code.
        s 1 Exception: An identified errorzgAn error has occurred: b'Exception: An identified error'
Please look at log file for more information.
�rPrQrRr])rar�rW�rcr}r~N�r�r\r2r2r3�test_errorInParent��

�z!DaemonizeTests.test_errorInParentcCr�)z�
        When the child writes a non-ASCII error message to the status
        pipe during daemonization, the parent writes the repr of the
        message to C{stderr} and exits with a non-zero status code.
        s1 Exception: �zXAn error has occurred: b'Exception: \xff'
Please look at log file for more information.
r�r�Nr�r\r2r2r3�test_nonASCIIErrorInParent�r�z)DaemonizeTests.test_nonASCIIErrorInParentcCs,d}d�d�}|j|d�|�gd�d�dS)a

        When the child writes a non-ASCII error message to the status
        pipe during daemonization, and that message is too longer, the
        parent writes the repr of the truncated message to C{stderr}
        and exits with a non-zero status code.
        �d1 RuntimeError: \u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022zb'RuntimeError: {}'zb\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022zHAn error has occurred: {}
Please look at log file for more information.
r�r�N)r�r�)rN�truncatedMessage�reportedMessager2r2r3�&test_errorInParentWithTruncatedUnicode�s
�
�z5DaemonizeTests.test_errorInParentWithTruncatedUnicodecCrv)z{
        If an error occurs during daemonization and its message is too
        long, it's truncated by the child.
        ��xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsd1 RuntimeError: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrwNrxr\r2r2r3�test_errorMessageTruncated�rzz)DaemonizeTests.test_errorMessageTruncatedcCrv)z�
        If an error occurs during daemonization and its message is
        unicode and too long, it's truncated by the child, even if
        this splits a unicode escape sequence.
        uZ••••••••••••••••••••••••••••••r�rwNrxr\r2r2r3�!test_unicodeErrorMessageTruncated�s
�z0DaemonizeTests.test_unicodeErrorMessageTruncatedcC�.t�}|j�|�|�|j�|�|j�dS)z�
        C{daemonize} indeed calls L{IReactorDaemonize.beforeDaemonize} and
        L{IReactorDaemonize.afterDaemonize} if the reactor implements
        L{IReactorDaemonize}.
        N)rer�r[r�r�r�r]r2r2r3�test_hooksCalled��zDaemonizeTests.test_hooksCalledcCr�)z�
        C{daemonize} does NOT call L{IReactorDaemonize.beforeDaemonize} or
        L{IReactorDaemonize.afterDaemonize} if the reactor does NOT implement
        L{IReactorDaemonize}.
        N)r�r�r[r�r�r�r]r2r2r3�test_hooksNotCalled�r�z"DaemonizeTests.test_hooksNotCalledN)rPrQrRrSr�r\rerlrpruryr{r�r�r�r�r�r�r�r�r2r2r2r3rM�s$
		rMc@s*eZdZdZedd��Zejdd��ZdS)�SignalCapturingMemoryReactorz�
    MemoryReactor that implements the _ISupportsExitSignalCapturing interface,
    all other operations identical to MemoryReactor.
    cCrfr&��_valr\r2r2r3rF
sz(SignalCapturingMemoryReactor._exitSignalcCr�r&r�)rN�valr2r2r3rFs
N)rPrQrRrS�propertyrF�setterr2r2r2r3r�s
r�cs4eZdZdZeZ�fdd�Zdd�Zdd�Z�Z	S)�StubApplicationRunnerWithSignalz�
    An application runner that uses a SignalCapturingMemoryReactor and
    has a _signalValue attribute that it will set in the reactor.

    @ivar _signalValue: The signal value to set on the reactor's _exitSignal
        attribute.
    cst��|�d|_dSr&)�superre�_signalValuer���	__class__r2r3re!s
z(StubApplicationRunnerWithSignal.__init__cCr�)z
        Does nothing.
        Nr2r\r2r2r3r]%r�z.StubApplicationRunnerWithSignal.preApplicationcCs$t�}|j|_|�|tjtj�dS)z`
        Instantiate a SignalCapturingMemoryReactor and start it
        in the runner.
        N)r�r�rFrr�r�rOr]r2r2r3r^*sz/StubApplicationRunnerWithSignal.postApplication)
rPrQrRrSrUr_rer]r^�
__classcell__r2r2r�r3r�sr�cs�fdd�}|S)aI
    Create a factory function to instantiate a
    StubApplicationRunnerWithSignal that will report signum as the captured
    signal..

    @param signum: The integer signal number or None
    @type signum: C{int} or C{None}

    @return: A factory function to create stub runners.
    @rtype: stubApplicationRunnerFactory
    cst|�}�|_|S)a�
        Create a StubApplicationRunnerWithSignal using a reactor that
        implements _ISupportsExitSignalCapturing and whose _exitSignal
        attribute is set to signum.

        @param config: The runner configuration, platform dependent.
        @type config: L{twisted.scripts.twistd.ServerOptions}

        @return: A runner to use for the test.
        @rtype: twisted.test.test_twistd.StubApplicationRunnerWithSignal
        )r�r�)rur���signumr2r3�stubApplicationRunnerFactoryAszIstubApplicationRunnerFactoryCreator.<locals>.stubApplicationRunnerFactoryr2)r�r�r2r�r3�#stubApplicationRunnerFactoryCreator4s
r�c@r�)�ExitWithSignalTestsz?
    Tests for L{twisted.application.app._exitWithSignal}.
    csRt���_dt�i�j_t��j_d�j_ddg�_�fdd�}��	t
d|�dS)zM
        Set up the server options and a fake for use by test cases.
        rNcs|�jd<|�jd<dS)z�
            Fake method to capture arguments passed to os.kill.

            @param pid: The pid of the process being killed.

            @param sig: The signal sent to the process.
            rr�N)�fakeKillArgsr�r\r2r3�fakeKillds
z+ExitWithSignalTests.setUp.<locals>.fakeKillr�)rrprurIrrr	rwr�rBr8)rNr�r2r\r3r�Zs


zExitWithSignalTests.setUpcs�ddg��fdd�}|�td|�t�tj�|��dtj�|��dtj�|�|jdt�	��|�|jdtj�dS)z�
        exitWithSignal replaces the existing signal handler with the default
        handler and sends the replaced signal to the current process.
        Ncs|�d<|�d<dS)Nrr�r2)r��handler��fakeSignalArgsr2r3�fake_signalysz<ExitWithSignalTests.test_exitWithSignal.<locals>.fake_signalr=rr�)
rBr=r	�_exitWithSignal�SIGINTrJ�SIG_DFLr�r8r�)rNr�r2r�r3�test_exitWithSignalqsz'ExitWithSignalTests.test_exitWithSignalcCsB|�tdtd��t�|j�|�|jd�|�|jd�dS)zb
        _exitWithSignal is not called if the runner does not exit with a
        signal.
        r,Nrr�)rBrr��runApprurtr�r\r2r2r3�test_normalExit�s
�z#ExitWithSignalTests.test_normalExitcCsN|�tdttj��t�|j�|�|jdt	�
��|�|jdtj�dS)zP
        _exitWithSignal is called when the runner exits with a signal.
        r,rr�N)rBrr�r=r�r�rurJr�r8r�r\r2r2r3�test_runnerExitsWithSignal�s�z.ExitWithSignalTests.test_runnerExitsWithSignalN)rPrQrRrSr�r�r�r�r2r2r2r3r�Tsr�)hrSr�r�r8r�r=r�r:�_grpr7�_pwd�ImportError�ior�unittestr�zope.interfacer�zope.interface.verifyrr�rrr�twisted.applicationr	r
r�twisted.application.servicer�twisted.internet.baser
�twisted.internet.deferr�twisted.internet.interfacesrr�#twisted.internet.test.modulehelpersr�twisted.loggerrrr�twisted.pythonr�twisted.python.componentsr�twisted.python.fakepwdr�twisted.python.logrr�twisted.python.reflectr�twisted.python.runtimer�twisted.python.usager�twisted.scriptsr�twisted.test.proto_helpersr�twisted.test.test_processr�twisted.trial.unittestrr��twisted.scripts._twistd_unixr r!r"r�r#r$r%rGrIrrUr,r[r`r�r�r�r�r�rrOrsr�r�rer;r�r�r�r�r:rMr�r�r�r�r2r2r2r3�<module>s��-	
YF
u



;
%
{+ 

Anon7 - 2022
AnonSec Team