<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> import errno <EOL> def _setupPath ( environ ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in environ : <EOL> sys . path [ : ] = environ [ '<STR_LIT>' ] . split ( os . pathsep ) <EOL> _setupPath ( os . environ ) <EOL> from twisted . internet . protocol import FileWrapper <EOL> from twisted . python . log import startLoggingWithObserver , textFromEventDict <EOL> from twisted . trial . _dist . options import WorkerOptions <EOL> from twisted . trial . _dist import _WORKER_AMP_STDIN , _WORKER_AMP_STDOUT <EOL> class WorkerLogObserver ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , protocol ) : <EOL> """<STR_LIT>""" <EOL> self . protocol = protocol <EOL> def emit ( self , eventDict ) : <EOL> """<STR_LIT>""" <EOL> from twisted . trial . _dist import managercommands <EOL> text = textFromEventDict ( eventDict ) <EOL> if text is None : <EOL> return <EOL> self . protocol . callRemote ( managercommands . TestWrite , out = text ) <EOL> def main ( _fdopen = os . fdopen ) : <EOL> """<STR_LIT>""" <EOL> config = WorkerOptions ( ) <EOL> config . parseOptions ( ) <EOL> from twisted . trial . _dist . worker import WorkerProtocol <EOL> workerProtocol = WorkerProtocol ( config [ '<STR_LIT>' ] ) <EOL> protocolIn = _fdopen ( _WORKER_AMP_STDIN ) <EOL> protocolOut = _fdopen ( _WORKER_AMP_STDOUT , '<STR_LIT:w>' ) <EOL> workerProtocol . makeConnection ( FileWrapper ( protocolOut ) ) <EOL> observer = WorkerLogObserver ( workerProtocol ) <EOL> startLoggingWithObserver ( observer . emit , False ) <EOL> while True : <EOL> try : <EOL> r = protocolIn . read ( <NUM_LIT:1> ) <EOL> except IOError , e : <EOL> if e . args [ <NUM_LIT:0> ] == errno . EINTR : <EOL> sys . exc_clear ( ) <EOL> continue <EOL> else : <EOL> raise <EOL> if r == '<STR_LIT>' : <EOL> break <EOL> else : <EOL> workerProtocol . dataReceived ( r ) <EOL> protocolOut . flush ( ) <EOL> sys . stdout . flush ( ) <EOL> sys . stderr . flush ( ) <EOL> if config . tracer : <EOL> sys . settrace ( None ) <EOL> results = config . tracer . results ( ) <EOL> results . write_results ( show_missing = True , summary = False , <EOL> coverdir = config . coverdir ( ) . path ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
