From 921a7125108e0f6f2c129ebe54eb99fbb9e707ca Mon Sep 17 00:00:00 2001 From: Elliot Matson Date: Sun, 31 Jul 2022 15:03:12 -0500 Subject: [PATCH] Clean up logic --- pgadmin-config-creator/app.py | 39 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/pgadmin-config-creator/app.py b/pgadmin-config-creator/app.py index 79667dd..de7da2e 100644 --- a/pgadmin-config-creator/app.py +++ b/pgadmin-config-creator/app.py @@ -4,27 +4,26 @@ # quit if config file already exists if os.path.exists("/config/servers.json"): - print("/config/servers.json already exists. Quitting...") - quit() - - -# open json file in docker volume -with open("/config/servers.json", "w") as f: - print("created " + f.name) - # template json string - template_string = ( - '{"Servers": {"1": {"Name": "DavinciResolve", ' - '"Group": "Servers", "Port": 5432, "Username": ' - '"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' - ) - data = json.loads(template_string) - # fix username - data["Servers"]["1"]["Username"] = os.getenv("POSTGRES_USER") - print("printing json to file...") - print(data) - # update config file - json.dump(data, f, indent=2) + print("/config/servers.json already exists.") +else: + # open json file in docker volume + with open("/config/servers.json", "w") as f: + print("created " + f.name) + # template json string + template_string = ( + '{"Servers": {"1": {"Name": "DavinciResolve", ' + '"Group": "Servers", "Port": 5432, "Username": ' + '"postgres", "Host": "postgres", "SSLMode": "prefer", "MaintenanceDB": "postgres"}}}' + ) + data = json.loads(template_string) + # fix username + data["Servers"]["1"]["Username"] = os.getenv("POSTGRES_USER") + print("Printing json to file...") + print(data) + # update config file + json.dump(data, f, indent=2) +print("Done. Sleeping...") # Sleep until GHA Healthchecks are complete. # I'm sure there's a better way to get this to not