Skip to content

Commit

Permalink
[Tools/DDL] added code to update a DDL (#208)
Browse files Browse the repository at this point in the history
* [Tools/DDL] added code to update a DDL

* [tools/DDL] update URL field only if it matches the previous value
  • Loading branch information
Jyotsnarajan authored Sep 20, 2024
1 parent fe48e16 commit 5c4252f
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tools/DDL/ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,31 @@ def create_demo(demo_id, host, title, state):
print(f"Could not create demo {demo_id}")


def update_ddl(demos):
"""
Update the build.url field in a DDL
"""

for editorsdemoid in demos:
try:
# Open the JSON file and load its content
with open("DDLs/" + str(editorsdemoid) + ".json", "r") as file:
ddl = json.load(file)

# Update the build.url field
if 'build' in ddl and 'url' in ddl['build']:
if ddl['build']['url'] == f"[email protected]:mlbriefs/{editorsdemoid}.git":
print(f"Original build URL for {editorsdemoid}: {ddl['build']['url']}")
ddl['build']['url'] = f"[email protected]:ipol-journal/{editorsdemoid}.git"
print(f"Updated build URL for {editorsdemoid}: {ddl['build']['url']}")

# Write the updated content back to the file
with open("DDLs/" + str(editorsdemoid) + ".json", 'w') as file:
json.dump(ddl, file, indent=4)
except Exception as ex:
print("ERROR: Failed to update the DDL {} - {}".format(editorsdemoid, ex))


# Parse program arguments
LOCAL_IP = "127.0.0.1"

Expand Down Expand Up @@ -184,5 +209,9 @@ def create_demo(demo_id, host, title, state):
do_write(args.command[1:], host)
elif command == "writeall" or command == "putall":
do_write_all(host)
elif command == "update_git_url":
do_read(args.command[1:], host)
update_ddl(args.command[1:])
do_write(args.command[1:], host)
else:
print(f"Error: unknown command '{command}'")
print(f"Error: unknown command '{command}'")

0 comments on commit 5c4252f

Please sign in to comment.