'''
Kill process in case
'''
import psutil
#for proc in psutil.process_iter():
# if(proc.name() == 'TouchDesigner099.exe'):
# proc.kill()
# print(proc.name())
def killList(kill_list):
'''Process kill function'''
for proc in psutil.process_iter():
# check whether the process name matches
# print(proc.name())
if any(procstr in proc.name() for procstr in kill_list):
print('Killing {}'.format(proc.name()))
proc.kill()
def kill_by_process_name(name):
for proc in psutil.process_iter():
if proc.name() == name:
print("Killing process: " + name)
if(check_process_exist_by_name(name)):
print("Killing process: " + name + " sucess")
else:
print("Killing process: " + name + " failed")
return
print("Not found process: " + name)
def check_process_exist_by_name(name):
for proc in psutil.process_iter():
if proc.name() == name:
return True
return False
killList(['TouchDesigner099.exe', 'Photoshop.exe'])