@@ -89,21 +89,25 @@ def get_start_time(device_id, app_id):
8989 :return: Start time.
9090 """
9191 output = Adb .run (command = 'logcat -d | grep \' Displayed {0}\' ' .format (app_id ), device_id = device_id )
92- print "Start time: {0}." .format (output )
93-
94- start_time = output .rsplit ("+" )[1 ]
95- print "Start time: {0}." .format (start_time )
96-
97- numbers = map (int , re .findall ('\d+' , start_time ))
98- num_len = len (str (numbers [1 ]))
99- if num_len == 1 :
100- numbers [1 ] = '00' + str (numbers [1 ])
101- elif num_len == 2 :
102- numbers [1 ] = '0' + str (numbers [1 ])
92+ if len (output ) > 0 :
93+ print "Start time: {0}." .format (output )
94+
95+ start_time = output .rsplit ("+" )[1 ]
96+ print "Start time: {0}." .format (start_time )
97+
98+ numbers = map (int , re .findall ('\d+' , start_time ))
99+ num_len = len (str (numbers [1 ]))
100+ if num_len == 1 :
101+ numbers [1 ] = '00' + str (numbers [1 ])
102+ elif num_len == 2 :
103+ numbers [1 ] = '0' + str (numbers [1 ])
104+
105+ result = str (numbers [0 ]) + str (numbers [1 ])
106+ print "Start time: {0}." .format (result )
107+ return result
108+ else :
109+ raise IOError ('{0} has not displayed its activity - the app crashed!' .format (app_id ))
103110
104- result = str (numbers [0 ]) + str (numbers [1 ])
105- print "Start time: {0}." .format (result )
106- return result
107111
108112 @staticmethod
109113 def run (command , device_id , timeout = 60 , log_level = CommandLogLevel .COMMAND_ONLY ):
0 commit comments