Skip to content
Snippets Groups Projects
Commit b5d2f9b5 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Better error handling for unset attributes

parent 425612a5
No related branches found
No related tags found
No related merge requests found
...@@ -150,28 +150,28 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False): ...@@ -150,28 +150,28 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False):
for enable in build.findall("./enable"): for enable in build.findall("./enable"):
build.remove(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: try:
default_compilers = get_attribute_values(api_url, project, None, "MPCDF:default_compiler") enable_repos = get_attribute_values(api_url, project, package, "MPCDF:enable_repositories")
except UnsetAttributeException: except Exception:
print("ERROR: Attribute MPCDF:default_compiler not set for project", file=sys.stderr) if verbose:
raise SystemExit(1) print("Warning: Could not get attribute MPCDF:enable_repositories for package {0}, skipping".format(package))
return False
try: def try_get_attribute(attribute, package, with_project=False):
default_mpis = get_attribute_values(api_url, project, None, "MPCDF:default_mpi") try:
except UnsetAttributeException: return get_attribute_values(api_url, project, package, "MPCDF:" + attribute, with_project=with_project)
print("ERROR: Attribute MPCDF:default_mpi not set for project", file=sys.stderr) except UnsetAttributeException:
raise SystemExit(1) print("ERROR: Attribute MPCDF:" + attribute + " is not set, aborting here", file=sys.stderr)
raise SystemExit(1)
try: compilers = try_get_attribute(package, "compiler_modules", with_project=True)
default_cudas = get_attribute_values(api_url, project, None, "MPCDF:default_cuda") all_compilers = try_get_attribute(None, "compiler_modules")
except UnsetAttributeException: mpis = try_get_attribute(package, "mpi_modules", with_project=True)
print("ERROR: Attribute MPCDF:default_cuda not set for project", file=sys.stderr) cudas = try_get_attribute(package, "cuda_modules", with_project=True)
raise SystemExit(1)
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): def enable(name):
node = ElementTree.Element("enable") node = ElementTree.Element("enable")
...@@ -181,13 +181,6 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False): ...@@ -181,13 +181,6 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False):
if verbose: if verbose:
print("Enabling", name) 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(): def actual_compilers():
for compiler in compilers: for compiler in compilers:
if compiler == "intel": if compiler == "intel":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment