Skip to content

Commit bc7c5d9

Browse files
authored
Merge pull request #199 from art-daq/eflumerf/SimplerGetPids
Change get_pids_and_labels_on_host to process only ouput lines
2 parents 44b0c3f + 10dc517 commit bc7c5d9

2 files changed

Lines changed: 7 additions & 28 deletions

File tree

rc/control/manage_processes_direct.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -817,41 +817,20 @@ def get_pids_and_labels_on_host(host, procinfos):
817817
os.environ["DAQINTERFACE_PARTITION_NUMBER"],
818818
)
819819
)
820-
sshgreptoken = (
821-
"[0-9]:[0-9][0-9]\s\+ssh.*\(%s\).*application_name.*partition_number:\s*%s"
822-
% (
823-
"\|".join(
824-
set(
825-
[bootfile_name_to_execname(procinfo.name) for procinfo in procinfos]
826-
)
827-
),
828-
os.environ["DAQINTERFACE_PARTITION_NUMBER"],
829-
)
830-
)
831-
832-
# greptoken =
833-
# "[0-9]:[0-9][0-9]\s\+valgrind.*\(%s\).*application_name.*partition_number:\s*%s"
834-
# % \
835-
# ("\|".join(set([bootfile_name_to_execname(procinfo.name) for
836-
# procinfo in procinfos])), \
837-
# os.environ["DAQINTERFACE_PARTITION_NUMBER"])
838820

839821
grepped_lines = []
840822
pids = get_pids(greptoken, host, grepped_lines)
841823

842-
ssh_pids = get_pids(sshgreptoken, host)
843-
844-
cleaned_pids = [pid for pid in pids if pid not in ssh_pids]
845-
cleaned_lines = [line for line in grepped_lines if " ssh " not in line]
846-
824+
pids = []
847825
labels_of_found_processes = []
848826

849-
for line in cleaned_lines:
827+
for line in grepped_lines:
850828
res = re.search(r"application_name:\s+(\S+)", line)
851-
assert res
852-
labels_of_found_processes.append(res.group(1))
829+
if res:
830+
pids.append(line.split()[1])
831+
labels_of_found_processes.append(res.group(1))
853832

854-
return cleaned_pids, labels_of_found_processes
833+
return pids, labels_of_found_processes
855834

856835

857836
def get_related_pids_for_process(procinfo):

rc/control/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def host_is_local(host):
118118

119119
def get_pids(greptoken, host="localhost", grepresults=None):
120120

121-
cmd = 'ps aux | grep "%s" | grep -v grep' % (greptoken)
121+
cmd = 'ps aux | grep "%s" | grep -v ssh | grep -v grep' % (greptoken)
122122

123123
if not host_is_local(host):
124124
cmd = "ssh -o BatchMode=yes -x %s '%s'" % (host, cmd)

0 commit comments

Comments
 (0)