def get_our_pids(this_base):
''' Runs ps ax, returns the list of PIDs whose comand starts with "/res_binaries/ '''
# Get the id of the running box; Vagrant should accept the name but doesn't; https://github.com/mitchellh/vagrant/issues/8691
id_of_base = ""
for this_line in (subprocess.getoutput("vagrant global-status")).splitlines():
if this_base in this_line:
(id_of_base, _) = this_line.split(" ", 1)
break
if not id_of_base:
die("No id could be found for {}.".format(this_base))
this_command = "vagrant ssh --command \"ps ax o pid,args --no-headers\" {}".format(id_of_base)
this_ps = subprocess.getoutput(this_command)
pids_to_return = []
for this_line in this_ps.splitlines():
(this_pid, this_cmd) = (this_line.strip()).split(" ", 1)
if this_cmd.startswith("/res_binaries/"):
pids_to_return.append((this_pid, this_cmd))
return pids_to_return
评论列表
文章目录