Skip to content
Snippets Groups Projects
Commit 7fb2cdcf authored by Daniel Nemergut's avatar Daniel Nemergut Committed by Sam Kagan
Browse files

Made the version comparison a little more robust

parent d7c3bc75
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,8 @@ CASA_VERSION_REGEX = r"[a-zA-Z\-]+([\d]+(\.[\d]+){2}(-[\d]+){0,1}).*"
PIPELINE_VERSION_REGEX = r".*([\d]{4}(\.[\d]+){3}).*"
EL_SUFFIX_REGEX = r"[\.\-]el[0-9]+$"
IGNORE_REGEX = r"\.|\-"
DEFAULT_CV = "unknown"
DEFAULT_PV = "default"
def casa_version_from_path(path: str) -> str:
......@@ -57,7 +59,7 @@ def casa_version_from_path(path: str) -> str:
"""
# Defaults
casa_version, pipeline_version = "unknown", "default"
casa_version, pipeline_version = DEFAULT_CV, DEFAULT_PV
cv_search = re.search(CASA_VERSION_REGEX, path)
......@@ -103,15 +105,17 @@ def versions_match(req_v: str, dir_v: str) -> bool:
:param dir_v: Version coming from a directory path
:return: True if the CASA+pipeline versions match
"""
req_cv, req_pv = req_v.split("|")
dir_cv, dir_pv = dir_v.split("|")
req_cv = req_v.split("|")[0]
dir_cv = dir_v.split("|")[0]
req_pv = req_v.split("|")[1] if "|" in req_v else DEFAULT_PV
dir_pv = dir_v.split("|")[1] if "|" in dir_v else DEFAULT_PV
# Ignore comparing '.' and '-' characters because they like to be used interchangeably
req_cv = re.sub(IGNORE_REGEX, "", req_cv)
dir_cv = re.sub(IGNORE_REGEX, "", dir_cv)
# Ignore comparing pipeline versions if they don't exist in the installed version's name
return req_cv == dir_cv and (dir_pv == "default" or req_pv == dir_pv)
return req_cv == dir_cv and (dir_pv == DEFAULT_PV or req_pv == dir_pv)
class CasaMatrixService(CasaMatrixServiceIF):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment