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 :  /usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


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

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

�b�4�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
mZmZddlmZdd	lmZdd
lmZdd�ZGd
d�de�Zee�Gdd�d��Ze��e���dS)z0
Tests for implementations of L{IReactorFDSet}.
�N)�skipIf)�implementer)�FileDescriptor)�
IReactorFDSet�IReadDescriptor)�EINPROGRESS�EWOULDBLOCK)�ReactorBuilder)�platform)�SkipTestc
Cs�t��}|�d�|�d�zQt��}z7|�d�z
|�d|��df�WntyB}z|jdtt	fvr8�WYd}~nd}~ww|�
�\}}WntyV|���wW|��||fS|��w)N)�	127.0.0.1r�Frr)
�socket�bind�listen�setblocking�connect�getsockname�OSError�argsrr�accept�
BaseException�close)�serverSocket�client�e�server�addr�r�B/usr/lib/python3/dist-packages/twisted/internet/test/test_fdset.py�
socketpairs0


�����
�r c@s�eZdZdZegZdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zee��d�dd��Zdd�ZdS) �ReactorFDSetTestsBuilderz>
    Builder defining tests relating to L{IReactorFDSet}.
    cCs*t�\}}|�|j�|�|j�||fS)zL
        Return the two sockets which make up a new TCP connection.
        )r �
addCleanupr)�selfrrrrr�_connectedPair8s
z'ReactorFDSetTestsBuilder._connectedPaircCs.|��}|��\}}t|�}|j|_|||fS�N)�buildReactorr$r�fileno)r#�reactorrr�fdrrr�_simpleSetupAs

z%ReactorFDSetTestsBuilder._simpleSetupcsD|��\��}��fdd�}|�_����|�d�|���dS)z�
        C{reactor.addReader()} accepts an L{IReadDescriptor} provider and calls
        its C{doRead} method when there may be data available on its C{fileno}.
        c��������dSr%)�removeReader�stopr�r)r(rr�
removeAndStopR�
z>ReactorFDSetTestsBuilder.test_addReader.<locals>.removeAndStop�xN)r*�doRead�	addReader�sendall�
runReactor�r#rr/rr.r�test_addReaderKs

z'ReactorFDSetTestsBuilder.test_addReadercs`���\}}}�fdd�}||_|�|�|�|�|�d�|�d|jd|j���|�dS)z�
        L{reactor.removeReader()} accepts an L{IReadDescriptor} provider
        previously passed to C{reactor.addReader()} and causes it to no longer
        be monitored for input events.
        c���d�dS�NzdoRead should not be called��failr�r#rrr;f�z8ReactorFDSetTestsBuilder.test_removeReader.<locals>.failr1rN)r*r2r3r,r4�	callLaterr-r5�r#r(r)rr;rr<r�test_removeReader^s


z*ReactorFDSetTestsBuilder.test_removeReadercs:|��\��}��fdd�}|�_����|���dS)z�
        C{reactor.addWriter()} accepts an L{IWriteDescriptor} provider and
        calls its C{doWrite} method when it may be possible to write to its
        C{fileno}.
        cr+r%)�removeWriterr-rr.rrr/~r0z>ReactorFDSetTestsBuilder.test_addWriter.<locals>.removeAndStopN)r*�doWrite�	addWriterr5r6rr.r�test_addWritervs

z'ReactorFDSetTestsBuilder.test_addWritercCs�|��}t|d|d�}t|d|�}t|d|�}|��\}}|�||��|�||��||�|�||��|�||��||�|�||��|�||��dS)z=
        Helper for getReaders and getWriters tests.
        �get�s�add�removeN)r&�getattrr$�assertNotIn�assertIn)r#�kindr(rErGrHrrrrr�
_getFDTest�sz#ReactorFDSetTestsBuilder._getFDTestcC�|�d�dS)z�
        L{IReactorFDSet.getReaders} reflects the additions and removals made
        with L{IReactorFDSet.addReader} and L{IReactorFDSet.removeReader}.
        �ReaderN�rMr<rrr�test_getReaders��z(ReactorFDSetTestsBuilder.test_getReaderscsV���\}}}�fdd�}||_|�|�|�|�|�d|jd|j���|�dS)z�
        L{reactor.removeWriter()} accepts an L{IWriteDescriptor} provider
        previously passed to C{reactor.addWriter()} and causes it to no longer
        be monitored for outputability.
        cr8�NzdoWrite should not be calledr:rr<rrr;�r=z8ReactorFDSetTestsBuilder.test_removeWriter.<locals>.failrN)r*rBrCrAr>r-r5r?rr<r�test_removeWriter�s

z*ReactorFDSetTestsBuilder.test_removeWritercCrN)z�
        L{IReactorFDSet.getWriters} reflects the additions and removals made
        with L{IReactorFDSet.addWriter} and L{IReactorFDSet.removeWriter}.
        �WriterNrPr<rrr�test_getWriters�rRz(ReactorFDSetTestsBuilder.test_getWriterscs����}���\}}}�fdd�|_�fdd�|_|�d�|�|�|�|�|��}|�d|jd|j	���
|���||g�dS)z�
        C{reactor.removeAll()} removes all registered L{IReadDescriptor}
        providers and all registered L{IWriteDescriptor} providers and returns
        them.
        c�
��d�Sr9r:rr<rr�<lambda>��
z9ReactorFDSetTestsBuilder.test_removeAll.<locals>.<lambda>crWrSr:rr<rrrX�rYr1rN)r&r*r2rBr4r3rC�	removeAllr>r-r5�assertEqual)r#r(r)r�removedrr<r�test_removeAll�s



z'ReactorFDSetTestsBuilder.test_removeAllcCs8|��}t|�}|�|j�|�|�|�|jg�dS)z�
        A descriptor's C{fileno} method should not be called after the
        descriptor has been removed from the reactor.
        N)r&�RemovingDescriptor�callWhenRunning�startr5r[�calls)r#r(�
descriptorrrr�test_removedFromReactor�s

z0ReactorFDSetTestsBuilder.test_removedFromReactorcsd|���|��\��G���fdd�dt�}|��}��|���d�|���|�|jd�dS)zp
        If L{FileDescriptor.fileno} returns C{-1}, the descriptor is removed
        from the reactor.
        cs:eZdZ���ZdZdd�Z��fdd�Z�fdd�ZdS)	zWReactorFDSetTestsBuilder.test_negativeOneFileDescriptor.<locals>.DisappearingDescriptor�cSs|jSr%)�_filenor<rrrr'�sz^ReactorFDSetTestsBuilder.test_negativeOneFileDescriptor.<locals>.DisappearingDescriptor.filenocs(d|_|j��d�7_��d�dS)N���r
�y)re�	_received�recv�sendr<)rrrrr2�sz^ReactorFDSetTestsBuilder.test_negativeOneFileDescriptor.<locals>.DisappearingDescriptor.doReadcs���dSr%�r-�r#�reason�r(rr�connectionLostszfReactorFDSetTestsBuilder.test_negativeOneFileDescriptor.<locals>.DisappearingDescriptor.connectionLostN)�__name__�
__module__�__qualname__r'rerhr2ror�rr(rrr�DisappearingDescriptor�srtr1N)r&r$rr3rjr5r[rh)r#rtrbrrsr�test_negativeOneFileDescriptor�s


z7ReactorFDSetTestsBuilder.test_negativeOneFileDescriptorz*Cannot duplicate socket filenos on Windowscs������jj}|dvrt|�d������\}�G��fdd�dt�}��|����fdd�}��d|�������	t
j�dS)	a
        The file descriptor underlying a FileDescriptor may be closed and
        replaced by another at some point.  Bytes which arrive on the new
        descriptor must not be delivered to the FileDescriptor which was
        originally registered with the original descriptor of the same number.

        Practically speaking, this is difficult or impossible to detect.  The
        implementation relies on C{fileno} raising an exception if the original
        descriptor has gone away.  If C{fileno} continues to return the original
        file descriptor value, the reactor may deliver events from that
        descriptor.  This is a best effort attempt to ease certain debugging
        situations.  Applications should not rely on it intentionally.
        )�EPollReactor�
KQueueReactor�	CFReactor�AsyncioSelectorReactorz$ cannot detect lost file descriptorscs0eZdZdZ�fdd�Zdd�Z�fdd�ZdS)	z@ReactorFDSetTestsBuilder.test_lostFileDescriptor.<locals>.Victima�
            This L{FileDescriptor} will have its socket closed out from under it
            and another socket will take its place.  It will raise a
            socket.error from C{fileno} after this happens (because socket
            objects remember whether they have been closed), so as long as the
            reactor calls the C{fileno} method the problem will be detected.
            cs���Sr%)r'r<)rrrr'3�zGReactorFDSetTestsBuilder.test_lostFileDescriptor.<locals>.Victim.filenocSstd��)Nz$Victim.doRead should never be called)�	Exceptionr<rrrr26rzzGReactorFDSetTestsBuilder.test_lostFileDescriptor.<locals>.Victim.doReadcs���dS)z�
                When the problem is detected, the reactor should disconnect this
                file descriptor.  When that happens, stop the reactor so the
                test ends.
                Nrkrlrnrrro9szOReactorFDSetTestsBuilder.test_lostFileDescriptor.<locals>.Victim.connectionLostN)rprqrr�__doc__r'r2ror)r(rrr�Victim*s
r}cs:���\}}���}���t�|��|�|�d�dS)Nr1)r$r'r�os�dup2rj)�newC�newSr')r#rrr�messItUpHs
zBReactorFDSetTestsBuilder.test_lostFileDescriptor.<locals>.messItUprN)r&�	__class__rprr$rr3r>r5�flushLoggedErrorsr�error)r#�namerr}r�r)r(r#rr�test_lostFileDescriptor
s

z0ReactorFDSetTestsBuilder.test_lostFileDescriptorcCs�|��}Gdd�dt�}|��\}}||�}|j|_||�}|j|_|�|�|�|�|�|j�|�|�|�	|j
�|�	|j
�dS)z�
        Any file descriptors added to the reactor have their C{connectionLost}
        called when C{reactor.stop} is called.
        c@seZdZdd�Zdd�ZdS)zSReactorFDSetTestsBuilder.test_connectionLostOnShutdown.<locals>.DoNothingDescriptorcS�dSr%rr<rrrr2_�zZReactorFDSetTestsBuilder.test_connectionLostOnShutdown.<locals>.DoNothingDescriptor.doReadcSr�r%rr<rrrrBbr�z[ReactorFDSetTestsBuilder.test_connectionLostOnShutdown.<locals>.DoNothingDescriptor.doWriteN)rprqrrr2rBrrrr�DoNothingDescriptor^sr�N)r&rr$r'r3rCr_r-r5�
assertTrue�disconnected)r#r(r�rr�fd1�fd2rrr�test_connectionLostOnShutdownWs


z6ReactorFDSetTestsBuilder.test_connectionLostOnShutdownN)rprqrrr|r�requiredInterfacesr$r*r7r@rDrMrQrTrVr]rcrurr
�	isWindowsr�r�rrrrr!1s$	

Lr!c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)r^a�
    A read descriptor which removes itself from the reactor as soon as it
    gets a chance to do a read and keeps track of when its own C{fileno}
    method is called.

    @ivar insideReactor: A flag which is true as long as the reactor has
        this descriptor as a reader.

    @ivar calls: A list of the bottom of the call stack for any call to
        C{fileno} when C{insideReactor} is false.
    cCs$||_d|_g|_t�\|_|_dS�NF)r(�
insideReactorrar �read�write)r#r(rrr�__init__�szRemovingDescriptor.__init__cCs"d|_|j�|�|j�d�dS)NT�a)r�r(r3r�rjr<rrrr`�szRemovingDescriptor.startcCsdS)N�foorr<rrr�	logPrefix�r�zRemovingDescriptor.logPrefixcCs4|j�|�d|_|j��|j��|j��dSr�)r(r,r�r-r�rr�r<rrrr2�s


zRemovingDescriptor.doReadcCs,|js|j�tjdd�dd��|j��S)N�)�limitrf)r�ra�append�	traceback�
extract_stackr�r'r<rrrr'�s
zRemovingDescriptor.filenocCr�r%rrlrrrro�sz!RemovingDescriptor.connectionLostN)
rprqrrr|r�r`r�r2r'rorrrrr^tsr^)r|r~rr��unittestr�zope.interfacer�twisted.internet.abstractr�twisted.internet.interfacesrr�twisted.internet.tcprr�#twisted.internet.test.reactormixinsr	�twisted.python.runtimer
�twisted.trial.unittestrr r!r^�globals�update�makeTestCaseClassesrrrr�<module>s&E.

Anon7 - 2022
AnonSec Team