From fcd0a8e358d64481a4d82acc3c054010c0698808 Mon Sep 17 00:00:00 2001 From: Jooho Lee Date: Wed, 4 Jun 2025 19:55:09 -0400 Subject: [PATCH 1/2] fix path for input_env_file Signed-off-by: Jooho Lee --- loopy | 1 + src/cli/commands/utils.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/loopy b/loopy index 27709bf..0aef6aa 100755 --- a/loopy +++ b/loopy @@ -1,6 +1,7 @@ #!/bin/bash ROOT_PATH="${LOOPY_ROOT_PATH:-$(pwd)}" +export ORIGINAL_DIR=$(pwd) pushd "$ROOT_PATH" > /dev/null PYTHONPATH=.:src python ./cmd/loopy.py "$@" diff --git a/src/cli/commands/utils.py b/src/cli/commands/utils.py index 1a0c41c..e73b28a 100644 --- a/src/cli/commands/utils.py +++ b/src/cli/commands/utils.py @@ -142,8 +142,10 @@ def parse_key_value_pairs(ctx, param, value): def load_env_file_if_exist(file): additional_vars = {} if file is not None: - if os.path.exists(file): - with open(file, "r") as file: + original_dir = os.environ.get("ORIGINAL_DIR", os.getcwd()) + input_path = os.path.normpath(os.path.join(original_dir, file)) + if os.path.exists(input_path): + with open(input_path, "r") as file: for line in file: if not line.strip() or line.startswith("#"): # Skip # part continue @@ -153,7 +155,7 @@ def load_env_file_if_exist(file): else: additional_vars[key] = value else: - logger.error(f"File({file}) does not exist") + logger.error(f"File({input_path}) does not exist") exit(1) return additional_vars From cf2d3c57302f2cbc8d510b5171418a55a552e58a Mon Sep 17 00:00:00 2001 From: Jooho Lee Date: Wed, 4 Jun 2025 20:09:56 -0400 Subject: [PATCH 2/2] follow up reviews Signed-off-by: Jooho Lee --- src/cli/commands/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli/commands/utils.py b/src/cli/commands/utils.py index e73b28a..b2f1382 100644 --- a/src/cli/commands/utils.py +++ b/src/cli/commands/utils.py @@ -145,8 +145,8 @@ def load_env_file_if_exist(file): original_dir = os.environ.get("ORIGINAL_DIR", os.getcwd()) input_path = os.path.normpath(os.path.join(original_dir, file)) if os.path.exists(input_path): - with open(input_path, "r") as file: - for line in file: + with open(input_path, "r") as f: + for line in f: if not line.strip() or line.startswith("#"): # Skip # part continue key, value = line.strip().split("=")