@@ -237,15 +237,17 @@ def _cmd(self):
237237 def _dbg (self ):
238238 return "cd {} && {} --args ./{}" .format (self .root , DBG , " " .join (self .cmd ))
239239
240- def wait_for_stdout_line (self , line , timeout ):
240+ def _connect_new (self ):
241241 client = paramiko .SSHClient ()
242242 client .set_missing_host_key_policy (paramiko .AutoAddPolicy ())
243243 client .connect (self .hostname )
244+ return client
245+
246+ def wait_for_stdout_line (self , line , timeout ):
247+ client = self ._connect_new ()
244248 try :
245249 for _ in range (timeout ):
246- _ , stdout , _ = self .client .exec_command (
247- "grep -F '{}' {}/out" .format (line , self .root )
248- )
250+ _ , stdout , _ = client .exec_command (f"grep -F '{ line } ' { self .root } /out" )
249251 if stdout .channel .recv_exit_status () == 0 :
250252 return
251253 time .sleep (1 )
@@ -255,6 +257,19 @@ def wait_for_stdout_line(self, line, timeout):
255257 finally :
256258 client .close ()
257259
260+ def print_result (self , lines ):
261+ client = self ._connect_new ()
262+ LOG .error ("print_result remote" )
263+ try :
264+ _ , stdout , _ = client .exec_command (f"tail -{ lines } { self .root } /out" )
265+ if stdout .channel .recv_exit_status () == 0 :
266+ LOG .success (f"Result for { self .name } :" )
267+ for line in stdout .read ().splitlines ():
268+ LOG .debug (line .decode ())
269+ return
270+ finally :
271+ client .close ()
272+
258273
259274@contextmanager
260275def ssh_remote (name , hostname , files , cmd ):
@@ -286,6 +301,7 @@ def __init__(
286301 self .stdout = None
287302 self .stderr = None
288303 self .env = env
304+ self .name = name
289305
290306 def _rc (self , cmd ):
291307 LOG .info ("[{}] {}" .format (self .hostname , cmd ))
@@ -392,6 +408,14 @@ def wait_for_stdout_line(self, line, timeout):
392408 "{} not found in stdout after {} seconds" .format (line , timeout )
393409 )
394410
411+ def print_result (self , line ):
412+ with open (os .path .join (self .root , "out" ), "rb" ) as out :
413+ lines = out .read ().splitlines ()
414+ result = lines [- line :]
415+ LOG .success (f"Result for { self .name } :" )
416+ for line in result :
417+ LOG .debug (line .decode ())
418+
395419
396420CCF_TO_OE_LOG_LEVEL = {
397421 "trace" : "VERBOSE" ,
@@ -582,6 +606,9 @@ def stop(self):
582606 def wait_for_stdout_line (self , line , timeout = 5 ):
583607 return self .remote .wait_for_stdout_line (line , timeout )
584608
609+ def print_result (self , lines ):
610+ self .remote .print_result (lines )
611+
585612 def set_recovery (self ):
586613 self .remote .set_recovery ()
587614
0 commit comments