-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move debug_mode out of system settings (#5366)
* move debug_mode out of system settings * Update router.py
- Loading branch information
1 parent
2fb9f90
commit 5d82fb3
Showing
7 changed files
with
44 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
from os import _Environ | ||
from pathlib import Path | ||
|
||
import dotenv | ||
|
||
from openbb_core.app.model.abstract.singleton import SingletonMeta | ||
|
||
|
||
class Env(metaclass=SingletonMeta): | ||
_environ: _Environ | ||
|
||
def __init__(self) -> None: | ||
current_dir = os.path.dirname(os.path.realpath(__file__)) | ||
dotenv.load_dotenv(Path(current_dir, ".env")) | ||
self._environ = os.environ | ||
|
||
@property | ||
def DEBUG_MODE(self) -> bool: | ||
return self.str_to_bool(self._environ.get("DEBUG_MODE", False)) | ||
|
||
@staticmethod | ||
def str_to_bool(value) -> bool: | ||
"""Match a string to a boolean value.""" | ||
if isinstance(value, bool): | ||
return value | ||
if value.lower() in {"false", "f", "0", "no", "n"}: | ||
return False | ||
if value.lower() in {"true", "t", "1", "yes", "y"}: | ||
return True | ||
raise ValueError(f"Failed to cast {value} to bool.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ class SystemService: | |
"log_collect", | ||
"test_mode", | ||
"headless", | ||
"debug_mode", | ||
"dbms_uri", | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters