Use voussoirkit.subproctools.
This commit is contained in:
parent
a1311b686b
commit
b8a550a0bc
1 changed files with 5 additions and 6 deletions
11
getpid.py
11
getpid.py
|
|
@ -3,17 +3,16 @@ import psutil
|
|||
import sys
|
||||
|
||||
from voussoirkit import betterhelp
|
||||
from voussoirkit import subproctools
|
||||
from voussoirkit import vlogging
|
||||
|
||||
log = vlogging.getLogger(__name__, 'getpid')
|
||||
|
||||
def getpid_argparse(args):
|
||||
status = 1
|
||||
target = args.process_name.lower()
|
||||
for process in psutil.process_iter():
|
||||
if process.name().lower() == target:
|
||||
print(process.pid)
|
||||
status = 0
|
||||
pids = subproctools.getpid(args.process_name)
|
||||
status = 0 if len(pids) > 0 else 1
|
||||
for pid in pids:
|
||||
print(pid)
|
||||
return status
|
||||
|
||||
@vlogging.main_decorator
|
||||
|
|
|
|||
Loading…
Reference in a new issue