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
|
import sys
|
||||||
|
|
||||||
from voussoirkit import betterhelp
|
from voussoirkit import betterhelp
|
||||||
|
from voussoirkit import subproctools
|
||||||
from voussoirkit import vlogging
|
from voussoirkit import vlogging
|
||||||
|
|
||||||
log = vlogging.getLogger(__name__, 'getpid')
|
log = vlogging.getLogger(__name__, 'getpid')
|
||||||
|
|
||||||
def getpid_argparse(args):
|
def getpid_argparse(args):
|
||||||
status = 1
|
pids = subproctools.getpid(args.process_name)
|
||||||
target = args.process_name.lower()
|
status = 0 if len(pids) > 0 else 1
|
||||||
for process in psutil.process_iter():
|
for pid in pids:
|
||||||
if process.name().lower() == target:
|
print(pid)
|
||||||
print(process.pid)
|
|
||||||
status = 0
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
@vlogging.main_decorator
|
@vlogging.main_decorator
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue