<s> """<STR_LIT>""" <EOL> import py <EOL> from py . __ . test . dist . mypickle import PickleChannel <EOL> class TXNode ( object ) : <EOL> """<STR_LIT>""" <EOL> ENDMARK = - <NUM_LIT:1> <EOL> def __init__ ( self , gateway , config , putevent , slaveready = None ) : <EOL> self . config = config <EOL> self . putevent = putevent <EOL> self . gateway = gateway <EOL> self . channel = install_slave ( gateway , config ) <EOL> self . _sendslaveready = slaveready <EOL> self . channel . setcallback ( self . callback , endmarker = self . ENDMARK ) <EOL> self . _down = False <EOL> def __repr__ ( self ) : <EOL> id = self . gateway . id <EOL> status = self . _down and '<STR_LIT:true>' or '<STR_LIT:false>' <EOL> return "<STR_LIT>" % ( id , status ) <EOL> def notify ( self , eventname , * args , ** kwargs ) : <EOL> assert not args <EOL> self . putevent ( ( eventname , args , kwargs ) ) <EOL> def callback ( self , eventcall ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> if eventcall == self . ENDMARK : <EOL> err = self . channel . _getremoteerror ( ) <EOL> if not self . _down : <EOL> if not err : <EOL> err = "<STR_LIT>" <EOL> self . notify ( "<STR_LIT>" , node = self , error = err ) <EOL> self . _down = True <EOL> return <EOL> eventname , args , kwargs = eventcall <EOL> if eventname == "<STR_LIT>" : <EOL> if self . _sendslaveready : <EOL> self . _sendslaveready ( self ) <EOL> self . notify ( "<STR_LIT>" , node = self ) <EOL> elif eventname == "<STR_LIT>" : <EOL> self . _down = True <EOL> self . notify ( "<STR_LIT>" , error = None , node = self ) <EOL> elif eventname == "<STR_LIT>" : <EOL> rep = kwargs [ '<STR_LIT>' ] <EOL> rep . node = self <EOL> self . notify ( "<STR_LIT>" , report = rep ) <EOL> else : <EOL> self . notify ( eventname , * args , ** kwargs ) <EOL> except KeyboardInterrupt : <EOL> raise <EOL> except : <EOL> excinfo = py . code . ExceptionInfo ( ) <EOL> print "<STR_LIT:!>" * <NUM_LIT:20> , excinfo <EOL> self . config . pluginmanager . notify_exception ( excinfo ) <EOL> def send ( self , item ) : <EOL> assert item is not None <EOL> self . channel . send ( item ) <EOL> def sendlist ( self , itemlist ) : <EOL> self . channel . send ( itemlist ) <EOL> def shutdown ( self ) : <EOL> self . channel . send ( None ) <EOL> def install_slave ( gateway , config ) : <EOL> channel = gateway . remote_exec ( source = """<STR_LIT>""" ) <EOL> channel = PickleChannel ( channel ) <EOL> basetemp = None <EOL> if gateway . spec . popen : <EOL> popenbase = config . ensuretemp ( "<STR_LIT>" ) <EOL> basetemp = py . path . local . make_numbered_dir ( prefix = "<STR_LIT>" , <EOL> keep = <NUM_LIT:0> , rootdir = popenbase ) <EOL> basetemp = str ( basetemp ) <EOL> channel . send ( ( config , basetemp ) ) <EOL> return channel <EOL> class SlaveNode ( object ) : <EOL> def __init__ ( self , channel ) : <EOL> self . channel = channel <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self . channel ) <EOL> def sendevent ( self , eventname , * args , ** kwargs ) : <EOL> self . channel . send ( ( eventname , args , kwargs ) ) <EOL> def pytest_runtest_logreport ( self , report ) : <EOL> self . sendevent ( "<STR_LIT>" , report = report ) <EOL> def run ( self ) : <EOL> channel = self . channel <EOL> self . config , basetemp = channel . receive ( ) <EOL> if basetemp : <EOL> self . config . basetemp = py . path . local ( basetemp ) <EOL> self . config . pluginmanager . do_configure ( self . config ) <EOL> self . config . pluginmanager . register ( self ) <EOL> self . runner = self . config . pluginmanager . getplugin ( "<STR_LIT>" ) <EOL> self . sendevent ( "<STR_LIT>" ) <EOL> try : <EOL> while <NUM_LIT:1> : <EOL> task = channel . receive ( ) <EOL> if task is None : <EOL> self . sendevent ( "<STR_LIT>" ) <EOL> break <EOL> if isinstance ( task , list ) : <EOL> for item in task : <EOL> self . run_single ( item = item ) <EOL> else : <EOL> self . run_single ( item = task ) <EOL> except KeyboardInterrupt : <EOL> raise <EOL> except : <EOL> er = py . code . ExceptionInfo ( ) . getrepr ( funcargs = True , showlocals = True ) <EOL> self . sendevent ( "<STR_LIT>" , excrepr = er ) <EOL> raise <EOL> def run_single ( self , item ) : <EOL> call = self . runner . CallInfo ( item . _checkcollectable , when = '<STR_LIT>' ) <EOL> if call . excinfo : <EOL> rep = self . runner . pytest_runtest_makereport ( item = item , call = call ) <EOL> self . pytest_runtest_logreport ( rep ) <EOL> return <EOL> item . config . hook . pytest_runtest_protocol ( item = item ) </s>
