From 76ec36d5b099c2a986c79f45fb081ff5bd3180c0 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 16 May 2019 18:05:12 +0200 Subject: [PATCH] smpirun: use a python chunk to generate missing hostfiles This way, we have a real XML parser, able of parsing any valid XML file. The perl version was so painfully crude thay you could almost believe it was written in Perl or something. --- src/smpi/smpirun.in | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/smpi/smpirun.in b/src/smpi/smpirun.in index 5fbc9b3511..8d6d8ad61e 100755 --- a/src/smpi/smpirun.in +++ b/src/smpi/smpirun.in @@ -301,21 +301,25 @@ if [ -z "${HOSTFILE}" ] ; then HOSTFILE="$(mktemp smpitmp-hostfXXXXXX)" perl -ne 'print "$1\n" if /.*.*/' ${PLATFORM} > ${HOSTFILE} # put all > ${HOSTFILE} + python -c ' +import xml.etree.ElementTree as ET +import sys +import re + +tree = ET.parse(sys.stdin) + +for elem in tree.findall(".//cluster"): + prefix = elem.attrib["prefix"] + radical = elem.attrib["radical"] + suffix = elem.attrib["suffix"] + for r in radical.split(","): + m = re.match("^([^-]*?)-([^-]*)$", r) + if m: + for i in range(int(m.group(1)), int(m.group(2))): + print "{}{}{}".format(prefix, i, suffix) + else: + print "{}{}{}".format(prefix, r, suffix) + ' < ${PLATFORM} >> ${HOSTFILE} fi UNROLLEDHOSTFILETMP=0 -- 2.20.1