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 if inputRelease
is None:
21 inputRelease=flags.Input.Release
24 if inputRelease ==
"" or not inputRelease.startswith(
"Athena-"):
25 msg.debug(
"flags.Input.Release is read as empty or it does not start with 'Athena-'")
28 if not relPattern.match(inputRelease):
29 raise RuntimeError(
"Input release number %s doesn't match the expected format"%inputRelease)
32 if rel1.count(
".") == 2: rel1=f
"{rel1}.0"
33 if rel2.count(
".") == 2: rel2=f
"{rel2}.0"
34 if inputRelease.count(
".") == 2: inputRelease=f
"{inputRelease}.0"
40 def identifyMajorAndMinorRel(rel):
41 idx = rel.rfind(
".", 0, rel.rfind(
"."))
44 def mangleRunningAndPatch(rel):
45 rel_split = rel.split(
".")
46 return int(rel_split[2])*10000 + int(rel_split[3])
48 if identifyMajorAndMinorRel(rel1) != identifyMajorAndMinorRel(rel2):
49 raise RuntimeError(
"Boundary releases not from the same release series, got %s and %s"%(rel1,rel2))
51 if identifyMajorAndMinorRel(rel1) != identifyMajorAndMinorRel(inputRelease):
52 msg.info(
"Input release %s not from the same release series %s.", inputRelease, rel1)
56 lower=mangleRunningAndPatch(rel1)
57 upper=mangleRunningAndPatch(rel2)
58 current=mangleRunningAndPatch(inputRelease)
61 raise RuntimeError(
"Lower boundary releases %s larger then upper boundary release %s" % (rel1,rel2))
63 if (current >= lower
and current <= upper):