o
    >hz	                     @   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   /var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/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	   
callRemote	TestWrite)r
   	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rWn|| |  tj  tj  q/|jrt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    )show_missingsummarycoverdir)r   parseOptionstwisted.trial._dist.workerr   r   r   makeConnectionr   r   r   r   readOSErrorargserrnoEINTRdataReceivedflushsysstdoutstderrtracersettraceresultswrite_resultsr!   path)
_fdopenconfigr   workerProtocol
protocolInprotocolOutobserverrer1   r   r   r   main/   s@   







r<   __main__)r   r(   osr,   twisted.internet.protocolr   twisted.python.logr   r   r   r   r   twisted.trial._dist.optionsr   r   fdopenr<   r   r   r   r   r   <module>   s   -
