Skip to content
Snippets Groups Projects
Commit 08dc933f authored by Sebastian Brommer's avatar Sebastian Brommer :hand_splayed_tone4:
Browse files

update prepare script

parent f7e0376a
Branches
No related tags found
No related merge requests found
#!/usr/bin/python3
import os
import sys
import json
def get_job_ad():
......@@ -16,7 +15,7 @@ def get_job_ad():
if " = " in line:
key = line.split(" = ")[0]
value = line.replace(f"{key} = ", "")
job_ad[key.strip()] = value.strip()
job_ad[key.strip().replace('"', "")] = value.strip().replace('"', "")
return job_ad
......@@ -56,10 +55,11 @@ def check_image_availability(image_path):
def main():
job_ad = get_job_ad()
status_message = ""
# write job_ad to a json file for debugging
dumpfilepath = "/scratch/job_ad.json"
# write job_ad to a file for debugging
dumpfilepath = "/scratch/job_ad_initial.json"
with open(dumpfilepath, "w") as f:
json.dump(job_ad, f, indent=4)
for key, value in job_ad.items():
f.write(f"{key} = {value}\n")
container_image = job_ad.get("ContainerImage")
docker_image = job_ad.get("DockerImage")
......@@ -73,8 +73,10 @@ def main():
"/cvmfs/unpacked.cern.ch/registry.hub.docker.com/mschnepf/slc7-condocker:latest"
)
job_ad["WantDocker"] = "false"
dumpfilepath = "/scratch/job_ad_updated.json"
with open(dumpfilepath, "w") as f:
json.dump(job_ad, f, indent=4)
for key, value in job_ad.items():
f.write(f"{key} = {value}\n")
return
# pick the args parameter that is not None
image = container_image or docker_image
......@@ -90,8 +92,10 @@ def main():
# dump the updated job ad to a file for debugging
job_ad["ContainerImage"] = condor_arg
job_ad["WantDocker"] = "false"
dumpfilepath = "/scratch/job_ad_updated.json"
with open(dumpfilepath, "w") as f:
json.dump(job_ad, f, indent=4)
for key, value in job_ad.items():
f.write(f"{key} = {value}\n")
status_message = f"Container image {image_path} is available, using it"
print(f"HookStatusMessage = {status_message}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment