From 45f2702403dba91b463b72e3ea984eaccb145f91 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Wed, 12 May 2021 16:58:46 +0300 Subject: [PATCH] Reverted back to fetching file directory first when resolving GCP keys. This is to make gcp key file relative to utils directory, not the current file. This will make it less confusing, because people usually navigate directories, not files. --- envs/monkey_zoo/blackbox/utils/gcp_machine_handlers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/envs/monkey_zoo/blackbox/utils/gcp_machine_handlers.py b/envs/monkey_zoo/blackbox/utils/gcp_machine_handlers.py index dd72112ba..c438e92f5 100644 --- a/envs/monkey_zoo/blackbox/utils/gcp_machine_handlers.py +++ b/envs/monkey_zoo/blackbox/utils/gcp_machine_handlers.py @@ -11,7 +11,7 @@ class GCPHandler(object): MACHINE_STARTING_COMMAND = "gcloud compute instances start %s --zone=%s" MACHINE_STOPPING_COMMAND = "gcloud compute instances stop %s --zone=%s" - # Key path location relative to this file + # Key path location relative to this file's directory RELATIVE_KEY_PATH = "../../gcp_keys/gcp_key.json" DEFAULT_ZONE = "europe-west3-a" DEFAULT_PROJECT = "guardicore-22050661" @@ -33,7 +33,8 @@ class GCPHandler(object): @staticmethod def get_absolute_key_path() -> str: - absolute_key_path = os.path.join(__file__, GCPHandler.RELATIVE_KEY_PATH) + file_dir = os.path.dirname(os.path.realpath(__file__)) + absolute_key_path = os.path.join(file_dir, GCPHandler.RELATIVE_KEY_PATH) absolute_key_path = os.path.realpath(absolute_key_path) if not os.path.isfile(absolute_key_path):