finding pid and killing process abilities were extended

This commit is contained in:
Volkan Şahin 2016-06-09 12:12:30 +03:00
parent 3b9c5fa097
commit 46047ac43b

View file

@ -91,6 +91,8 @@ class System:
def pids():
return psutil.pids()
@staticmethod
def find_pid_by_name(p_name):
for id in psutil.pids():
@ -99,10 +101,29 @@ class System:
return None
"""
@staticmethod
def find_pids_by_name(p_name):
arr = []
for pid in psutil.get_pid_list():
if psutil.Process(pid).name==p_name:
arr.append(pid)
return arr
@staticmethod
def is_running(pid):
return psutil.pid_exists(pid)
@staticmethod
def kill_by_pid(pid):
return psutil.Process(pid).kill()
@staticmethod
def kill_by_pids(pids):
for pid in pids:
psutil.Process(pid).kill()
@staticmethod
def find_name_by_pid(pid):
return psutil.Process(pid).name()
@ -134,6 +155,7 @@ class System:
return psutil.Process(pid).create_time()
"""
@staticmethod
def cpu_times(pid):
@ -434,4 +456,4 @@ class System:
def model():
return cpuinfo.get_cpu_info()['model']
"""
"""