Add function getpid to subproctools.
This commit is contained in:
parent
924e5b4bdc
commit
fa619073f8
1 changed files with 14 additions and 0 deletions
|
@ -1,4 +1,18 @@
|
||||||
import os
|
import os
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
def getpid(process_name):
|
||||||
|
pids = []
|
||||||
|
target = process_name.lower()
|
||||||
|
for process in psutil.process_iter():
|
||||||
|
# print(dir(process))
|
||||||
|
try:
|
||||||
|
print(process.cmdline())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if process.name().lower() == target:
|
||||||
|
pids.append(process.pid)
|
||||||
|
return pids
|
||||||
|
|
||||||
def quote(arg) -> str:
|
def quote(arg) -> str:
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
|
Loading…
Reference in a new issue