o
    Óó·iz	  ã                   @   s†   d 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 ddl	m
Z
mZ ddlmZ G dd„ dƒZejfd	d
„ZedkrAeƒ  dS dS )zj
Implementation of C{AMP} worker commands, and main executable entry point for
the workers.

@since: 12.3
é    N)ÚFileWrapper)ÚstartLoggingWithObserverÚtextFromEventDict)Ú_WORKER_AMP_STDINÚ_WORKER_AMP_STDOUT)ÚWorkerOptionsc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚWorkerLogObserverzF
    A log observer that forward its output to a C{AMP} protocol.
    c                 C   s
   || _ dS )zg
        @param protocol: a connected C{AMP} protocol instance.
        @type protocol: C{AMP}
        N)Úprotocol)Úselfr	   © r   úeC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\twisted/trial/_dist/workertrial.pyÚ__init__   s   
zWorkerLogObserver.__init__c                 C   s6   ddl m} t|ƒ}|du rdS | jj|j|d� dS )z'
        Produce a log output.
        r   )ÚmanagercommandsN)Úout)Útwisted.trial._distr   r   r	   Z
callRemoteZ	TestWrite)r
   Z	eventDictr   Útextr   r   r   Úemit#   s
   zWorkerLogObserver.emitN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s    r   c           
   
   C   s  t ƒ }| ¡  ddlm} ||d ƒ}| tdƒ}| tdƒ}| t|ƒ¡ t|ƒ}t	|j
dƒ 	 z| d¡}W n tyQ } z|jd tjkrLW Y d	}~q.‚ d	}~ww |d
krWqk| |¡ | ¡  tj ¡  tj ¡  q/|jr…t d	¡ |j ¡ }	|	jdd| ¡ jd� d	S d	S )z¬
    Main function to be run if __name__ == "__main__".

    @param _fdopen: If specified, the function to use in place of C{os.fdopen}.
    @type _fdopen: C{callable}
    r   )ÚWorkerProtocolzforce-gcÚrbÚwbFTé   Nó    )Zshow_missingÚsummaryÚcoverdir)r   ZparseOptionsZtwisted.trial._dist.workerr   r   r   ZmakeConnectionr   r   r   r   ÚreadÚOSErrorÚargsÚerrnoZEINTRZdataReceivedÚflushÚsysÚstdoutÚstderrZtracerÚsettraceÚresultsZwrite_resultsr   Úpath)
Z_fdopenÚconfigr   ZworkerProtocolZ
protocolInZprotocolOutZobserverÚrÚer'   r   r   r   Úmain/   s@   

€ü


ò


ÿýr,   Ú__main__)r   r!   Úosr#   Ztwisted.internet.protocolr   Ztwisted.python.logr   r   r   r   r   Ztwisted.trial._dist.optionsr   r   Úfdopenr,   r   r   r   r   r   Ú<module>   s   -
ÿ