From 36ec26cfe94947d489bcf5a5f9f9b8792fc1605e Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Thu, 26 Sep 2019 11:41:15 +0100 Subject: [PATCH 1/2] #75: Change paths --- common/config.py | 2 +- common/logger_setup.py | 2 +- src/swagger/swagger_generator.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/config.py b/common/config.py index e68d87b3..a495439b 100644 --- a/common/config.py +++ b/common/config.py @@ -5,7 +5,7 @@ class Config(object): def __init__(self): - with open("../config.json") as target: + with open("config.json") as target: self.config = json.load(target) target.close() diff --git a/common/logger_setup.py b/common/logger_setup.py index 1b7d9548..035997e5 100644 --- a/common/logger_setup.py +++ b/common/logger_setup.py @@ -2,7 +2,7 @@ from common.config import config log_level = "DEBUG" -LOG_FILE_NAME = "../logs.log" +LOG_FILE_NAME = "logs.log" logger_config = { "version": 1, "formatters": {"default": { diff --git a/src/swagger/swagger_generator.py b/src/swagger/swagger_generator.py index e04bd824..ab9a33e1 100644 --- a/src/swagger/swagger_generator.py +++ b/src/swagger/swagger_generator.py @@ -221,7 +221,7 @@ def get_spec_as_dict(self): class SwaggerGenerator(object): - FILE_PATH = Path.cwd() / "swagger" / "openapi.yaml" + FILE_PATH = Path.cwd() / "src" / "swagger" / "openapi.yaml" def __init__(self): self.endpoints = [] From 6d1f323c39a17424d42bcada9b31e3ba39e4c533 Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Wed, 9 Oct 2019 07:12:23 +0100 Subject: [PATCH 2/2] #75: Use __file__ to get relative paths --- common/config.py | 3 ++- common/logger_setup.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/config.py b/common/config.py index ecb2afa5..720f72a1 100644 --- a/common/config.py +++ b/common/config.py @@ -6,7 +6,8 @@ class Config(object): def __init__(self): - with open(Path("config.json")) as target: + config_path = Path(__file__).parent.parent / "config.json" + with open(config_path) as target: self.config = json.load(target) target.close() diff --git a/common/logger_setup.py b/common/logger_setup.py index 55e237f9..7d9e939d 100644 --- a/common/logger_setup.py +++ b/common/logger_setup.py @@ -4,7 +4,7 @@ from common.config import config log_level = "DEBUG" -LOG_FILE_NAME = Path("logs.log") +LOG_FILE_NAME = Path(__file__).parent.parent / "logs.log" logger_config = { "version": 1, "formatters": {"default": {