mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
target: Add is_running()
Add the "is_running" function that can be used to check if a given process is running on the target device. It will return True if a process matching the name is found and Falsa otherwise. Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
This commit is contained in:
parent
b5aa065f7b
commit
86fcc11ae1
@ -54,7 +54,8 @@ from devlib.platform import Platform
|
||||
from devlib.exception import (DevlibTransientError, TargetStableError,
|
||||
TargetNotRespondingError, TimeoutError,
|
||||
TargetTransientError, KernelConfigKeyError,
|
||||
TargetError, HostError, TargetCalledProcessError) # pylint: disable=redefined-builtin
|
||||
TargetError, HostError, TargetCalledProcessError,
|
||||
TargetStableCalledProcessError) # pylint: disable=redefined-builtin
|
||||
from devlib.utils.ssh import SshConnection
|
||||
from devlib.utils.android import AdbConnection, AndroidProperties, LogcatMonitor, adb_command, adb_disconnect, INTENT_FLAGS
|
||||
from devlib.utils.misc import memoized, isiterable, convert_new_lines, groupby_value
|
||||
@ -279,6 +280,12 @@ class Target(object):
|
||||
self._setup_shutils()
|
||||
return self._shutils
|
||||
|
||||
def is_running(self, comm):
|
||||
cmd_ps = f'''{self.busybox} ps -A -T -o stat,comm'''
|
||||
cmd_awk = f'''{self.busybox} awk 'BEGIN{{found=0}} {{state=$1; $1=""; if ($state != "Z" && $0 == " {comm}") {{found=1}}}} END {{print found}}' '''
|
||||
result = self.execute(f"{cmd_ps} | {cmd_awk}")
|
||||
return bool(int(result))
|
||||
|
||||
@tls_property
|
||||
def _conn(self):
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user