4 from AthenaCommon.Logging
import logging
10 msg=logging.getLogger(
"releaseInRange")
14 relPattern=re.compile(
r"^Athena-(\d+(\.\d+){2,3}(\.\*)?)$")
17 if not relPattern.match(r):
18 raise RuntimeError(
"Release number %s doesn't match the expected format"%r)
20 inputRelease=flags.Input.Release
23 if inputRelease ==
"" or not inputRelease.startswith(
"Athena-"):
24 msg.debug(
"flags.Input.Release is read as empty or it does not start with 'Athena-'")
27 if not relPattern.match(inputRelease):
28 raise RuntimeError(
"Input release number %s doesn't match the expected format"%inputRelease)
31 if rel1.count(
".") == 2: rel1=f
"{rel1}.0"
32 if rel2.count(
".") == 2: rel2=f
"{rel2}.0"
33 if inputRelease.count(
".") == 2: inputRelease=f
"{inputRelease}.0"
39 def identifyMajorAndMinorRel(rel):
40 idx = rel.rfind(
".", 0, rel.rfind(
"."))
43 def mangleRunningAndPatch(rel):
44 rel_split = rel.split(
".")
45 return int(rel_split[2])*10000 +
int(rel_split[3])
47 if identifyMajorAndMinorRel(rel1) != identifyMajorAndMinorRel(rel2):
48 raise RuntimeError(
"Boundary releases not from the same release series, got %s and %s"%(rel1,rel2))
50 if identifyMajorAndMinorRel(rel1) != identifyMajorAndMinorRel(inputRelease):
51 msg.info(
"Input release not from the same release series.")
55 lower=mangleRunningAndPatch(rel1)
56 upper=mangleRunningAndPatch(rel2)
57 current=mangleRunningAndPatch(inputRelease)
60 raise RuntimeError(
"Lower boundary releases %s larger then upper boundary release %s" % (rel1,rel2))
62 if (current >= lower
and current <= upper):