mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 10:11:17 +00:00
AndroidDevice: correctly handle None output on get_pids_of
It is possible that the command executed by get_pids_of() will return None (in cases where there are no running processes with the specified name and the grep call didn't find anything). If that happens, then the subsequent call to split() failed (as that is not a method of None). To avoid this, substitute an empty string instead.
This commit is contained in:
parent
8355fcf886
commit
8aa1bdc63d
@ -475,8 +475,8 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
|
||||
|
||||
def get_pids_of(self, process_name):
|
||||
"""Returns a list of PIDs of all processes with the specified name."""
|
||||
result = self.execute('ps | {} grep {}'.format(self.busybox, process_name),
|
||||
check_exit_code=False).strip()
|
||||
result = (self.execute('ps | {} grep {}'.format(self.busybox, process_name),
|
||||
check_exit_code=False) or '').strip()
|
||||
if result and 'not found' not in result:
|
||||
return [int(x.split()[1]) for x in result.split('\n')]
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user