mirror of
https://github.com/ARM-software/devlib.git
synced 2025-03-04 09:17:51 +00:00
Merge pull request #133 from valschneider/fix-activity-error
utils/android: Fix error detection in adb_shell()
This commit is contained in:
commit
7145b366ab
@ -34,7 +34,7 @@ from devlib.utils.misc import escape_single_quotes, escape_double_quotes
|
|||||||
logger = logging.getLogger('android')
|
logger = logging.getLogger('android')
|
||||||
|
|
||||||
MAX_ATTEMPTS = 5
|
MAX_ATTEMPTS = 5
|
||||||
AM_START_ERROR = re.compile(r"Error: Activity class {[\w|.|/]*} does not exist")
|
AM_START_ERROR = re.compile(r"Error: Activity.*")
|
||||||
|
|
||||||
# See:
|
# See:
|
||||||
# http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
|
# http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
|
||||||
@ -366,19 +366,19 @@ def adb_shell(device, command, timeout=None, check_exit_code=False,
|
|||||||
|
|
||||||
if check_exit_code:
|
if check_exit_code:
|
||||||
exit_code = exit_code.strip()
|
exit_code = exit_code.strip()
|
||||||
|
re_search = AM_START_ERROR.findall('{}\n{}'.format(output, error))
|
||||||
if exit_code.isdigit():
|
if exit_code.isdigit():
|
||||||
if int(exit_code):
|
if int(exit_code):
|
||||||
message = ('Got exit code {}\nfrom target command: {}\n'
|
message = ('Got exit code {}\nfrom target command: {}\n'
|
||||||
'STDOUT: {}\nSTDERR: {}')
|
'STDOUT: {}\nSTDERR: {}')
|
||||||
raise TargetError(message.format(exit_code, command, output, error))
|
raise TargetError(message.format(exit_code, command, output, error))
|
||||||
elif AM_START_ERROR.findall(output):
|
elif re_search:
|
||||||
message = 'Could not start activity; got the following:'
|
|
||||||
message += '\n{}'.format(AM_START_ERROR.findall(output)[0])
|
|
||||||
raise TargetError(message)
|
|
||||||
else: # not all digits
|
|
||||||
if AM_START_ERROR.findall(output):
|
|
||||||
message = 'Could not start activity; got the following:\n{}'
|
message = 'Could not start activity; got the following:\n{}'
|
||||||
raise TargetError(message.format(AM_START_ERROR.findall(output)[0]))
|
raise TargetError(message.format(re_search[0]))
|
||||||
|
else: # not all digits
|
||||||
|
if re_search:
|
||||||
|
message = 'Could not start activity; got the following:\n{}'
|
||||||
|
raise TargetError(message.format(re_search[0]))
|
||||||
else:
|
else:
|
||||||
message = 'adb has returned early; did not get an exit code. '\
|
message = 'adb has returned early; did not get an exit code. '\
|
||||||
'Was kill-server invoked?'
|
'Was kill-server invoked?'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user