From 3199c93394a440787ede5b54cbee6700ea3804f0 Mon Sep 17 00:00:00 2001 From: Joe Garcia Date: Fri, 14 Apr 2023 00:06:55 +0100 Subject: [PATCH] Adding a check to only use the HTTP API server URL when the script is run outside Docker container(s). --- admin-tools/misc/getCruiseId.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/admin-tools/misc/getCruiseId.py b/admin-tools/misc/getCruiseId.py index 1e30553..2bd3e48 100755 --- a/admin-tools/misc/getCruiseId.py +++ b/admin-tools/misc/getCruiseId.py @@ -28,7 +28,7 @@ from python_sealog.settings import apiServerURL, cruisesAPIPath, headers -# FIXME: Override apiServerURL because we're outside of Docker +# FIXME: Override apiServerURL because we're outside of Docker ("fix" in progress) apiServerURL = "https://localhost/sealog/server" @@ -39,6 +39,11 @@ args = parser.parse_args() + # If the script is being run outside the container, use HTTP instead of HTTPS to contact API server. + if not os.path.exists('/.dockerenv'): + print("Outside Docker container environment, using HTTP API server URL.") + apiServerURL = "http://localhost/sealog/server" + r = requests.get(f'{apiServerURL}/{cruisesAPIPath}', headers=headers) cruises = json.loads(r.text)