def find_test_instance(iss, tag):
match = {"-i": iss, "-t": tag}
for proc in psutil.process_iter():
try:
cmd = proc.cmdline()
except psutil.AccessDenied:
continue
if len(cmd) < 5:
continue
flag = 0
for first, second in match.items():
try:
i = cmd.index(first)
except ValueError:
break
if cmd[i + 1] != second:
break
else:
flag += 1
if flag == len(match):
return proc
return None
评论列表
文章目录