Skip to content

Commit

Permalink
don't return early in install loop
Browse files Browse the repository at this point in the history
  • Loading branch information
rkm committed Nov 15, 2024
1 parent 16e7c2d commit b04d286
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
11 changes: 7 additions & 4 deletions roles/hicservices_rdmp/tasks/deploy_rdmp_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ def main() -> int:
parser.add_argument("versions", type=json.loads)
args = parser.parse_args()

rc = 0
for version, version_data in args.versions.items():

install_dir = f"{args.install_root}/v{version}"

if os.path.isdir(install_dir):
print(f"{install_dir} already exists")
return 0
continue
os.mkdir(install_dir)

with tempfile.TemporaryDirectory() as tempdir:
Expand All @@ -35,7 +36,7 @@ def main() -> int:
f"Checksum format not supported: {p['checksum']}",
file=sys.stderr,
)
return 1
return 2

package_name = p["name"].replace("<VERSION>", version)
url = f"{args.base_url}/v{version}/{package_name}"
Expand All @@ -51,7 +52,7 @@ def main() -> int:
f"Expected {expected_sha256}, got {file_sha256}"
)
print(err, file=sys.stderr)
return 1
return 2

package_ext = package_path.split(".")[-1]
if package_ext == "xz":
Expand All @@ -75,7 +76,9 @@ def main() -> int:
assert len(rdmp_cli_dir) == 1, f"Expected only one match: {rdmp_cli_dir}"
shutil.copytree(rdmp_cli_dir[0], f"{install_dir}/rdmp-cli")

return 0
rc = 1

return rc


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion roles/hicservices_rdmp/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
{{ hicservices_rdmp_base_dir }} \
'{{ hicservices_rdmp_versions | to_json }}'
register: deploy_result
changed_when: deploy_result.rc != 0
changed_when: deploy_result.rc == 1
failed_when: deploy_result.rc > 1

- name: Set rdmp-cli permissions
ansible.builtin.file:
Expand Down
11 changes: 7 additions & 4 deletions roles/smi_isidentifiable/tasks/deploy_isidentifiable.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ def main() -> int:
parser.add_argument("versions", type=json.loads)
args = parser.parse_args()

rc = 0
for version, version_data in args.versions.items():

install_dir = f"{args.install_root}/v{version}"

if os.path.isdir(install_dir):
print(f"{install_dir} already exists")
return 0
continue
os.mkdir(install_dir)

with tempfile.TemporaryDirectory() as tempdir:
Expand All @@ -35,7 +36,7 @@ def main() -> int:
f"Checksum format not supported: {p['checksum']}",
file=sys.stderr,
)
return 1
return 2

package_name = p["name"].replace("<VERSION>", version)
url = f"{args.base_url}/v{version}/{package_name}"
Expand All @@ -50,7 +51,7 @@ def main() -> int:
f"Checksum error. Expected {expected_md5}, got {file_md5}",
file=sys.stderr,
)
return 1
return 2

package_ext = package_path.split(".")[-1]
if package_ext == "gz":
Expand Down Expand Up @@ -83,7 +84,9 @@ def main() -> int:
for f in glob.glob(f"{tempdir}/*.{ext}"):
shutil.copy2(f, f"{install_dir}/")

return 0
rc = 1

return rc


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion roles/smi_isidentifiable/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
{{ smi_isidentifiable_base_dir }} \
'{{ smi_isidentifiable_versions | to_json }}'
register: deploy_result
changed_when: deploy_result.rc != 0
changed_when: deploy_result.rc == 1
failed_when: deploy_result.rc > 1
11 changes: 7 additions & 4 deletions roles/smi_smiservices/tasks/deploy_smiservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ def main() -> int:
parser.add_argument("versions", type=json.loads)
args = parser.parse_args()

rc = 0
for version, version_data in args.versions.items():

install_dir = f"{args.install_root}/v{version}"

if os.path.isdir(install_dir):
print(f"{install_dir} already exists")
return 0
continue
os.mkdir(install_dir)

with tempfile.TemporaryDirectory() as tempdir:
Expand All @@ -36,7 +37,7 @@ def main() -> int:
f"Checksum format not supported: {p['checksum']}",
file=sys.stderr,
)
return 1
return 2

package_name = p["name"].replace("<VERSION>", version)
url = f"{args.base_url}/v{version}/{package_name}"
Expand All @@ -51,7 +52,7 @@ def main() -> int:
f"Checksum error. Expected {expected_md5}, got {file_md5}",
file=sys.stderr,
)
return 1
return 2

package_ext = package_path.split(".")[-1]
if package_ext == "tgz":
Expand Down Expand Up @@ -88,7 +89,9 @@ def main() -> int:
ctp_jar = f"{tempdir}/ctpanonymiser-1.0.0/CTPAnonymiser-portable-1.0.0.jar"
shutil.copy2(ctp_jar, f"{install_dir}/CTPAnonymiser.jar")

return 0
rc = 1

return rc


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion roles/smi_smiservices/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
{{ smi_smiservices_base_dir }} \
'{{ smi_smiservices_versions | to_json }}'
register: deploy_result
changed_when: deploy_result.rc != 0
changed_when: deploy_result.rc == 0
failed_when: deploy_result.rc > 1

0 comments on commit b04d286

Please sign in to comment.