def find_test_instances(prog):
pid = {}
for proc in psutil.process_iter():
_name = proc.name()
if _name in ['python', 'python3', 'Python', 'Python3']:
try:
cmd = proc.cmdline()
except psutil.AccessDenied:
continue
if len(cmd) > 5:
if cmd[1].endswith(prog):
i = cmd.index('-i')
iss = cmd[i + 1]
i = cmd.index('-t')
tag = cmd[i + 1]
i = cmd.index('-p')
port = cmd[i + 1]
since = datetime.datetime.fromtimestamp(
proc.create_time()).strftime(
"%Y-%m-%d %H:%M:%S")
pid[proc.pid] = {'iss': iss, 'tag': tag, 'port': port,
'since': since}
return pid
评论列表
文章目录