diff --git a/mpcdf_common.py b/mpcdf_common.py index 91534463d712ca67b6d6fadea3ea9aea7a64d4b5..04c70d4964190aab52ad36e9e888991b83a53f1d 100644 --- a/mpcdf_common.py +++ b/mpcdf_common.py @@ -150,28 +150,28 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False): for enable in build.findall("./enable"): build.remove(enable) - compilers = get_attribute_values(api_url, project, package, "MPCDF:compiler_modules", with_project=True) - all_compilers = get_attribute_values(api_url, project, None, "MPCDF:compiler_modules") - mpis = get_attribute_values(api_url, project, package, "MPCDF:mpi_modules", with_project=True) - cudas = get_attribute_values(api_url, project, package, "MPCDF:cuda_modules", with_project=True) - try: - default_compilers = get_attribute_values(api_url, project, None, "MPCDF:default_compiler") - except UnsetAttributeException: - print("ERROR: Attribute MPCDF:default_compiler not set for project", file=sys.stderr) - raise SystemExit(1) + enable_repos = get_attribute_values(api_url, project, package, "MPCDF:enable_repositories") + except Exception: + if verbose: + print("Warning: Could not get attribute MPCDF:enable_repositories for package {0}, skipping".format(package)) + return False - try: - default_mpis = get_attribute_values(api_url, project, None, "MPCDF:default_mpi") - except UnsetAttributeException: - print("ERROR: Attribute MPCDF:default_mpi not set for project", file=sys.stderr) - raise SystemExit(1) + def try_get_attribute(attribute, package, with_project=False): + try: + return get_attribute_values(api_url, project, package, "MPCDF:" + attribute, with_project=with_project) + except UnsetAttributeException: + print("ERROR: Attribute MPCDF:" + attribute + " is not set, aborting here", file=sys.stderr) + raise SystemExit(1) - try: - default_cudas = get_attribute_values(api_url, project, None, "MPCDF:default_cuda") - except UnsetAttributeException: - print("ERROR: Attribute MPCDF:default_cuda not set for project", file=sys.stderr) - raise SystemExit(1) + compilers = try_get_attribute(package, "compiler_modules", with_project=True) + all_compilers = try_get_attribute(None, "compiler_modules") + mpis = try_get_attribute(package, "mpi_modules", with_project=True) + cudas = try_get_attribute(package, "cuda_modules", with_project=True) + + default_compilers = try_get_attribute(None, "default_compiler") + default_mpis = try_get_attribute(None, "default_mpi") + default_cudas = try_get_attribute(None, "default_cuda") def enable(name): node = ElementTree.Element("enable") @@ -181,13 +181,6 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False): if verbose: print("Enabling", name) - try: - enable_repos = get_attribute_values(api_url, project, package, "MPCDF:enable_repositories") - except Exception: - if verbose: - print("Warning: Could not get attribute MPCDF:enable_repositories for package {0}".format(package)) - return False - def actual_compilers(): for compiler in compilers: if compiler == "intel":