Hallo noisefloor,
mein Skript sieht jetzt so aus:
import os
import psutil
def find_procs_by_name(name):
"Return a list of processes matching 'name'."
ls = []
for p in psutil.process_iter(attrs=["name", "exe", "cmdline"]):
if name == p.info['name'] or \
p.info['exe'] and os.path.basename(p.info['exe']) == name or \
p.info['/usr/bin/python3', name] and p.info['cmdline'][1] == name:
ls.append(p)
return ls
print(find_procs_by_name("kamera.py"))
Display More
Das Ergebnis ist folgendermaßen:
Traceback (most recent call last):
File "test_prozess.py", line 17, in <module>
print(find_procs_by_name("kamera.py"))
File "test_prozess.py", line 12, in find_procs_by_name
p.info['/usr/bin/python3', name] and p.info['cmdline'][1] == name:
KeyError: ('/usr/bin/python3', 'kamera.py')
Was mache ich falsch?
Vielen Dank und viele Grüße
whitechristmas
------------------
(program exited with code: 1)
Press return to continue