From 10e2b38711f66bf8e78226ef1d27a07b0da4b276 Mon Sep 17 00:00:00 2001 From: teh_coderer Date: Tue, 4 Apr 2023 12:34:21 -0500 Subject: [PATCH] init (#4683) --- .../core/plots/plotly_ta/ta_class.py | 7 +++++-- openbb_terminal/core/session/env_handler.py | 20 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/openbb_terminal/core/plots/plotly_ta/ta_class.py b/openbb_terminal/core/plots/plotly_ta/ta_class.py index 838c928c788..1e22c8c8c33 100644 --- a/openbb_terminal/core/plots/plotly_ta/ta_class.py +++ b/openbb_terminal/core/plots/plotly_ta/ta_class.py @@ -1,7 +1,6 @@ # pylint: disable=R0902 import importlib import inspect -import os import sys from pathlib import Path from typing import Any, Dict, List, Optional, Type, Union @@ -219,7 +218,11 @@ class PlotlyTA(PltTA): @staticmethod def _locate_plugins() -> None: """Locate all the plugins in the plugins folder""" - path = REPOSITORY_DIRECTORY if hasattr(sys, "frozen") else Path(os.getcwd()) + path = ( + Path(sys.executable).parent + if hasattr(sys, "frozen") + else REPOSITORY_DIRECTORY + ) current_system = get_current_system() # This is for debugging purposes diff --git a/openbb_terminal/core/session/env_handler.py b/openbb_terminal/core/session/env_handler.py index 93967a1894b..9ebb6fc8246 100644 --- a/openbb_terminal/core/session/env_handler.py +++ b/openbb_terminal/core/session/env_handler.py @@ -1,4 +1,5 @@ # IMPORTS STANDARD +import sys from typing import Any, Dict, Optional # IMPORTS THIRDPARTY @@ -11,18 +12,23 @@ from openbb_terminal.core.config.paths import ( SETTINGS_ENV_FILE, ) +DEFAULT_ORDER = [ + SETTINGS_ENV_FILE, + PACKAGE_ENV_FILE, + REPOSITORY_ENV_FILE, +] + def read_env() -> Dict[str, Any]: __env_dict: Dict[str, Optional[str]] = {} + local_order = DEFAULT_ORDER.copy() - if SETTINGS_ENV_FILE.exists(): - __env_dict.update(**dotenv_values(SETTINGS_ENV_FILE)) + if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"): + local_order.reverse() - if PACKAGE_ENV_FILE.exists(): - __env_dict.update(**dotenv_values(PACKAGE_ENV_FILE)) - - if REPOSITORY_ENV_FILE.exists(): - __env_dict.update(**dotenv_values(REPOSITORY_ENV_FILE)) + for env_file in local_order: + if env_file.exists(): + __env_dict.update(**dotenv_values(env_file)) __env_dict_filtered = { k[len("OPENBBB_") - 1 :]: v