diff options
Diffstat (limited to 'tools/systeminfo.py')
-rw-r--r-- | tools/systeminfo.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/systeminfo.py b/tools/systeminfo.py index 19c5d16e..287a74d2 100644 --- a/tools/systeminfo.py +++ b/tools/systeminfo.py @@ -137,3 +137,25 @@ def get_memory_bytes(): return int(mem) +def get_pids(proc_names_list): + """ Get pid(s) of process(es) with given name(s) + + :returns: list with pid(s) of given processes or None if processes + with given names are not running + """ + + try: + pids = subprocess.check_output(['pidof'] + proc_names_list) + except: + # such process isn't running + return None + + return list(map(str, map(int, pids.split()))) + +def get_pid(proc_name_str): + """ Get pid(s) of process with given name + + :returns: list with pid(s) of given process or None if process + with given name is not running + """ + return get_pids([proc_name_str]) |