From 8aa1bdc63d218fd9cbd2e9b7d463210f6f53eeb6 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Mon, 17 Oct 2016 10:54:10 +0100 Subject: [PATCH] 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. --- wlauto/common/android/device.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wlauto/common/android/device.py b/wlauto/common/android/device.py index 47158b73..f4257268 100644 --- a/wlauto/common/android/device.py +++ b/wlauto/common/android/device.py @@ -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: