-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tools/DDL] added code to update a DDL (#208)
* [Tools/DDL] added code to update a DDL * [tools/DDL] update URL field only if it matches the previous value
- Loading branch information
1 parent
fe48e16
commit 5c4252f
Showing
1 changed file
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
||
|
@@ -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}'") |