mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-09 19:02:19 +00:00
Default env for packaged apps (#1693)
* Remove defaults json in favor of a .env in a cross platform specfile * Use ENV_FILE from obff across the app * Add venv packaging support to the specfile * Make silencing explicit * Fix bug in integration tests report printout Co-authored-by: piiq <piiq@tinag.ru>
This commit is contained in:
committed by
GitHub
parent
15501940e5
commit
a5b414bf1a
25
build/pyinstaller/.env
vendored
Normal file
25
build/pyinstaller/.env
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
OPENBB_PACKAGED_APPLICATION=true
|
||||
OPENBB_LOGGING_COMMIT_HASH='sha:aabb76ef'
|
||||
OPENBB_ENABLE_PREDICT=true
|
||||
OPENBB_ENABLE_CHECK_API=true
|
||||
OPENBB_ENABLE_THOUGHTS_DAY=false
|
||||
OPENBB_REMEMBER_CONTEXTS=true
|
||||
OPENBB_USE_FLAIR=:openbb
|
||||
OPENBB_USE_WATERMARK=true
|
||||
OPENBB_USE_CMD_LOCATION_FIGURE=true
|
||||
OPENBB_USE_PROMPT_TOOLKIT=true
|
||||
OPENBB_USE_COLOR=true
|
||||
OPENBB_USE_ION=true
|
||||
OPENBB_USE_PLOT_AUTOSCALING=false
|
||||
OPENBB_ENABLE_RICH=true
|
||||
OPENBB_ENABLE_RICH_PANEL=true
|
||||
OPENBB_MPLSTYLE=dark
|
||||
OPENBB_MPFSTYLE=dark
|
||||
OPENBB_RICHSTYLE=dark
|
||||
OPENBB_DEBUG_MODE=false
|
||||
OPENBB_USE_TABULATE_DF=true
|
||||
OPENBB_USE_CLEAR_AFTER_CMD=false
|
||||
OPENBB_USE_DATETIME=true
|
||||
OPENBB_OPEN_REPORT_AS_HTML=true
|
||||
OPENBB_ENABLE_QUICK_EXIT=false
|
||||
OPENBB_ENABLE_EXIT_AUTO_HELP=false
|
||||
27
build/pyinstaller/OPENBB_DEFAULTS.json
vendored
27
build/pyinstaller/OPENBB_DEFAULTS.json
vendored
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"OPENBB_PACKAGED_APPLICATION": "True",
|
||||
"OPENBB_LOGGING_COMMIT_HASH": "sha:b171083f",
|
||||
"OPENBB_ENABLE_PREDICT": "True",
|
||||
"OPENBB_ENABLE_CHECK_API": "True",
|
||||
"OPENBB_ENABLE_THOUGHTS_DAY": "False",
|
||||
"OPENBB_REMEMBER_CONTEXTS": "True",
|
||||
"OPENBB_USE_FLAIR": ":openbb",
|
||||
"OPENBB_USE_WATERMARK": "True",
|
||||
"OPENBB_USE_CMD_LOCATION_FIGURE": "True",
|
||||
"OPENBB_USE_PROMPT_TOOLKIT": "True",
|
||||
"OPENBB_USE_COLOR": "True",
|
||||
"OPENBB_USE_ION": "True",
|
||||
"OPENBB_USE_PLOT_AUTOSCALING": "False",
|
||||
"OPENBB_ENABLE_RICH": "True",
|
||||
"OPENBB_ENABLE_RICH_PANEL": "True",
|
||||
"OPENBB_MPLSTYLE": "dark",
|
||||
"OPENBB_MPFSTYLE": "dark",
|
||||
"OPENBB_RICHSTYLE": "dark",
|
||||
"OPENBB_DEBUG_MODE": "False",
|
||||
"OPENBB_USE_TABULATE_DF": "True",
|
||||
"OPENBB_USE_CLEAR_AFTER_CMD": "False",
|
||||
"OPENBB_USE_DATETIME": "True",
|
||||
"OPENBB_OPEN_REPORT_AS_HTML": "True",
|
||||
"OPENBB_ENABLE_QUICK_EXIT": "False",
|
||||
"OPENBB_ENABLE_EXIT_AUTO_HELP": "False"
|
||||
}
|
||||
6
build/pyinstaller/build4mac.sh
vendored
6
build/pyinstaller/build4mac.sh
vendored
@@ -6,9 +6,9 @@ DISK_IMAGE_NAME="OpenBB Terminal"
|
||||
set -e
|
||||
|
||||
# Clean Up artifacts from previous builds
|
||||
rm -rf build/terminal_mac && rm -rf dist && rm -rf DMG
|
||||
rm -rf build/terminal && rm -rf dist && rm -rf DMG
|
||||
|
||||
pyinstaller build/pyinstaller/terminal_mac.spec
|
||||
pyinstaller build/pyinstaller/terminal.spec
|
||||
|
||||
# Create the folder that is used for packaging
|
||||
mkdir DMG
|
||||
@@ -26,4 +26,4 @@ hdiutil create \
|
||||
"$DISK_IMAGE_NAME".dmg
|
||||
|
||||
# Clean Up artifacts from this build
|
||||
rm -rf build/terminal_mac && rm -rf dist && rm -rf DMG
|
||||
rm -rf build/terminal && rm -rf dist && rm -rf DMG
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
from dotenv import set_key
|
||||
|
||||
from PyInstaller.compat import is_darwin, is_win
|
||||
from PyInstaller.building.api import PYZ, EXE, COLLECT
|
||||
from PyInstaller.building.splash import Splash
|
||||
from PyInstaller.building.build_main import Analysis
|
||||
|
||||
|
||||
from openbb_terminal.loggers import get_commit_hash
|
||||
|
||||
NAME = "OpenBBTerminal"
|
||||
@@ -18,20 +17,13 @@ build_type = (
|
||||
)
|
||||
|
||||
# Local python environment packages folder
|
||||
pathex = os.path.join(
|
||||
os.path.dirname(sys.executable), "..", "lib", "python3.8", "site-packages"
|
||||
)
|
||||
pathex = os.path.join(os.path.dirname(os.__file__), "site-packages")
|
||||
|
||||
# Get latest commit
|
||||
commit_hash = get_commit_hash()
|
||||
build_assets_folder = os.path.join(os.getcwd(), "build", "pyinstaller")
|
||||
default_feature_flags_path = os.path.join(build_assets_folder, "OPENBB_DEFAULTS.json")
|
||||
with open(default_feature_flags_path, "r") as f:
|
||||
default_gtff = json.load(f)
|
||||
|
||||
default_gtff["OPENBB_LOGGING_COMMIT_HASH"] = commit_hash
|
||||
with open(default_feature_flags_path, "w") as f:
|
||||
json.dump(default_gtff, f, indent=4)
|
||||
default_env_file = os.path.join(build_assets_folder, ".env")
|
||||
set_key(default_env_file, "OPENBB_LOGGING_COMMIT_HASH", str(commit_hash))
|
||||
|
||||
# Files that are explicitly pulled into the bundle
|
||||
added_files = [
|
||||
@@ -42,7 +34,6 @@ added_files = [
|
||||
("user_agent", "user_agent"),
|
||||
("vaderSentiment", "vaderSentiment"),
|
||||
(os.path.join("frozendict", "VERSION"), "frozendict"),
|
||||
("OPENBB_DEFAULTS.json", "."),
|
||||
(
|
||||
os.path.join(pathex, "linearmodels", "datasets"),
|
||||
os.path.join("linearmodels", "datasets"),
|
||||
@@ -51,9 +42,9 @@ added_files = [
|
||||
os.path.join(pathex, "statsmodels", "datasets"),
|
||||
os.path.join("statsmodels", "datasets"),
|
||||
),
|
||||
(".env", "."),
|
||||
]
|
||||
|
||||
|
||||
# Python libraries that are explicitly pulled into the bundle
|
||||
hidden_imports = [
|
||||
"sklearn.utils._cython_blas",
|
||||
145
build/pyinstaller/terminal_windows.spec
vendored
145
build/pyinstaller/terminal_windows.spec
vendored
@@ -1,145 +0,0 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
from PyInstaller.compat import is_darwin, is_win
|
||||
from PyInstaller.building.api import PYZ, EXE, COLLECT
|
||||
from PyInstaller.building.splash import Splash
|
||||
from PyInstaller.building.build_main import Analysis
|
||||
|
||||
# adding Folder to the system path - if needed (when you aren't using a venv)
|
||||
#sys.path.insert(0, '{install_folder}\GamestonkTerminal')
|
||||
from openbb_terminal.loggers import get_commit_hash
|
||||
|
||||
NAME = "OpenBBTerminal"
|
||||
|
||||
build_type = (
|
||||
os.getenv("OPENBB_BUILD_TYPE") if bool(os.getenv("OPENBB_BUILD_TYPE")) else "folder"
|
||||
)
|
||||
|
||||
# Local python environment packages folder
|
||||
pathex = os.path.join(
|
||||
os.path.dirname(sys.executable), "..", "lib", "python3.8", "site-packages"
|
||||
)
|
||||
|
||||
# Get latest commit
|
||||
commit_hash = get_commit_hash()
|
||||
build_assets_folder = os.path.join(os.getcwd(), "build", "pyinstaller")
|
||||
default_feature_flags_path = os.path.join(build_assets_folder, "OPENBB_DEFAULTS.json")
|
||||
with open(default_feature_flags_path, "r") as f:
|
||||
default_gtff = json.load(f)
|
||||
|
||||
default_gtff["OPENBB_LOGGING_COMMIT_HASH"] = commit_hash
|
||||
with open(default_feature_flags_path, "w") as f:
|
||||
json.dump(default_gtff, f, indent=4)
|
||||
|
||||
# Files that are explicitly pulled into the bundle
|
||||
added_files = [
|
||||
(os.path.join(os.getcwd(), "openbb_terminal"), "openbb_terminal"),
|
||||
(os.path.join(os.getcwd(), "routines"), "routines"),
|
||||
(os.path.join(os.getcwd(), "styles"), "styles"),
|
||||
("property_cached", "property_cached"),
|
||||
("user_agent", "user_agent"),
|
||||
("vaderSentiment", "vaderSentiment"),
|
||||
(os.path.join("frozendict", "VERSION"), "frozendict"),
|
||||
("OPENBB_DEFAULTS.json", "."),
|
||||
]
|
||||
|
||||
# Python libraries that are explicitly pulled into the bundle
|
||||
hidden_imports = [
|
||||
"sklearn.utils._cython_blas",
|
||||
"sklearn.utils._typedefs",
|
||||
"sklearn.neighbors.quad_tree",
|
||||
"sklearn.tree._utils",
|
||||
"sklearn.neighbors._partition_nodes",
|
||||
"squarify",
|
||||
"linearmodels",
|
||||
"statsmodels",
|
||||
"user_agent",
|
||||
"vaderSentiment",
|
||||
"frozendict",
|
||||
"boto3",
|
||||
"textwrap3",
|
||||
"pyEX",
|
||||
"tensorflow",
|
||||
]
|
||||
|
||||
analysis_kwargs = dict(
|
||||
scripts=[os.path.join(os.getcwd(), "terminal.py")],
|
||||
pathex=[pathex, "."],
|
||||
binaries=[],
|
||||
datas=added_files,
|
||||
hiddenimports=hidden_imports,
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=None,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
a = Analysis(**analysis_kwargs)
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=analysis_kwargs["cipher"])
|
||||
|
||||
exe_args = [
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
]
|
||||
|
||||
exe_kwargs = dict(
|
||||
name=NAME,
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=False,
|
||||
upx_exclude=[],
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
target_arch="x86_64",
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
# Packaging settings
|
||||
if build_type == "onefile":
|
||||
exe_args += [a.binaries, a.zipfiles, a.datas]
|
||||
exe_kwargs["runtime_tmpdir"] = None
|
||||
elif build_type == "folder":
|
||||
exe_kwargs["exclude_binaries"] = True
|
||||
collect_args = [
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
]
|
||||
collect_kwargs = dict(
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name=NAME,
|
||||
)
|
||||
|
||||
|
||||
# Platform specific settings
|
||||
if is_win:
|
||||
splash = Splash(
|
||||
os.path.join(os.getcwd(), "images", "openbb_splashscreen.png"),
|
||||
binaries=a.binaries,
|
||||
datas=a.datas,
|
||||
text_pos=(200, 400),
|
||||
text_size=12,
|
||||
text_color="white",
|
||||
)
|
||||
exe_args += [splash, splash.binaries]
|
||||
exe_kwargs["icon"] = (os.path.join(os.getcwd(), "images", "openbb_icon.ico"),)
|
||||
|
||||
if is_darwin:
|
||||
exe_kwargs["icon"] = (os.path.join(os.getcwd(), "images", "openbb.icns"),)
|
||||
|
||||
exe = EXE(*exe_args, **exe_kwargs)
|
||||
|
||||
if build_type == "folder":
|
||||
coll = COLLECT(*([exe] + collect_args), **collect_kwargs)
|
||||
@@ -1,6 +1,7 @@
|
||||
# IMPORTATION STANDARD
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
REPO_DIR = Path(__file__).parent.parent.parent.parent
|
||||
USER_HOME = Path(os.path.expanduser("~"))
|
||||
ENV_FILE = REPO_DIR.joinpath(".env")
|
||||
DEFAULT_FILE = REPO_DIR.joinpath("OPENBB_DEFAULTS.json")
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
# IMPORTATION STANDARD
|
||||
import os
|
||||
import json
|
||||
from distutils.util import strtobool
|
||||
|
||||
# IMPORTATION THIRDPARTY
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# IMPORTATION INTERNAL
|
||||
from openbb_terminal.core.config.constants import DEFAULT_FILE, ENV_FILE
|
||||
|
||||
if DEFAULT_FILE.is_file():
|
||||
with open(DEFAULT_FILE) as f:
|
||||
default_dict = json.load(f)
|
||||
|
||||
for key, value in default_dict.items():
|
||||
os.environ[key] = value
|
||||
from openbb_terminal.core.config.constants import ENV_FILE
|
||||
|
||||
if ENV_FILE.is_file():
|
||||
load_dotenv(dotenv_path=ENV_FILE, override=True)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""Keys Controller Module"""
|
||||
__docformat__ = "numpy"
|
||||
|
||||
# pylint: disable=too-many-lines
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
@@ -29,13 +31,11 @@ from openbb_terminal.menu import session
|
||||
from openbb_terminal.parent_classes import BaseController
|
||||
from openbb_terminal.rich_config import console
|
||||
|
||||
# pylint: disable=too-many-lines,no-member,too-many-public-methods,C0302
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
# pylint:disable=import-outside-toplevel
|
||||
|
||||
|
||||
class KeysController(BaseController):
|
||||
class KeysController(BaseController): # pylint: disable=too-many-public-methods
|
||||
"""Keys Controller class"""
|
||||
|
||||
CHOICES_COMMANDS: List[str] = [
|
||||
@@ -107,7 +107,7 @@ class KeysController(BaseController):
|
||||
df = TimeSeries(
|
||||
key=cfg.API_KEY_ALPHAVANTAGE, output_format="pandas"
|
||||
).get_intraday(symbol="AAPL")
|
||||
if df[0].empty:
|
||||
if df[0].empty: # pylint: disable=no-member
|
||||
logger.warning("Alpha Vantage key defined, test failed")
|
||||
self.key_dict["ALPHA_VANTAGE"] = "defined, test failed"
|
||||
else:
|
||||
|
||||
@@ -7,13 +7,12 @@ import logging
|
||||
from typing import List
|
||||
|
||||
# IMPORTATION THIRDPARTY
|
||||
from dotenv import load_dotenv, set_key
|
||||
from dotenv import set_key
|
||||
from prompt_toolkit.completion import NestedCompleter
|
||||
|
||||
# IMPORTATION INTERNAL
|
||||
from openbb_terminal import config_plot as cfg_plot
|
||||
from openbb_terminal import feature_flags as obbff
|
||||
from openbb_terminal.core.config.constants import ENV_FILE
|
||||
from openbb_terminal.decorators import log_start_end
|
||||
from openbb_terminal.helper_funcs import get_flair, parse_known_args_and_warn
|
||||
from openbb_terminal.menu import session
|
||||
@@ -25,9 +24,6 @@ from openbb_terminal.rich_config import console
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if ENV_FILE.is_file():
|
||||
load_dotenv(ENV_FILE)
|
||||
|
||||
|
||||
class SettingsController(BaseController):
|
||||
"""Settings Controller class"""
|
||||
@@ -151,56 +147,72 @@ class SettingsController(BaseController):
|
||||
def call_logcollection(self, _):
|
||||
"""Process logcollection command"""
|
||||
obbff.LOG_COLLECTION = not obbff.LOG_COLLECTION
|
||||
set_key(ENV_FILE, "OPENBB_LOG_COLLECTION", str(obbff.LOG_COLLECTION))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_LOG_COLLECTION", str(obbff.LOG_COLLECTION))
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_tab(self, _):
|
||||
"""Process tab command"""
|
||||
obbff.USE_TABULATE_DF = not obbff.USE_TABULATE_DF
|
||||
set_key(ENV_FILE, "OPENBB_USE_TABULATE_DF", str(obbff.USE_TABULATE_DF))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_USE_TABULATE_DF", str(obbff.USE_TABULATE_DF))
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_cls(self, _):
|
||||
"""Process cls command"""
|
||||
obbff.USE_CLEAR_AFTER_CMD = not obbff.USE_CLEAR_AFTER_CMD
|
||||
set_key(ENV_FILE, "OPENBB_USE_CLEAR_AFTER_CMD", str(obbff.USE_CLEAR_AFTER_CMD))
|
||||
set_key(
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_USE_CLEAR_AFTER_CMD",
|
||||
str(obbff.USE_CLEAR_AFTER_CMD),
|
||||
)
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_color(self, _):
|
||||
"""Process color command"""
|
||||
obbff.USE_COLOR = not obbff.USE_COLOR
|
||||
set_key(ENV_FILE, "OPENBB_USE_COLOR", str(obbff.USE_COLOR))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_USE_COLOR", str(obbff.USE_COLOR))
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_promptkit(self, _):
|
||||
"""Process promptkit command"""
|
||||
obbff.USE_PROMPT_TOOLKIT = not obbff.USE_PROMPT_TOOLKIT
|
||||
set_key(ENV_FILE, "OPENBB_USE_PROMPT_TOOLKIT", str(obbff.USE_PROMPT_TOOLKIT))
|
||||
set_key(
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_USE_PROMPT_TOOLKIT",
|
||||
str(obbff.USE_PROMPT_TOOLKIT),
|
||||
)
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_predict(self, _):
|
||||
"""Process predict command"""
|
||||
obbff.ENABLE_PREDICT = not obbff.ENABLE_PREDICT
|
||||
set_key(ENV_FILE, "OPENBB_ENABLE_PREDICT", str(obbff.ENABLE_PREDICT))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_ENABLE_PREDICT", str(obbff.ENABLE_PREDICT))
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_thoughts(self, _):
|
||||
"""Process thoughts command"""
|
||||
obbff.ENABLE_THOUGHTS_DAY = not obbff.ENABLE_THOUGHTS_DAY
|
||||
set_key(ENV_FILE, "OPENBB_ENABLE_THOUGHTS_DAY", str(obbff.ENABLE_THOUGHTS_DAY))
|
||||
set_key(
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_ENABLE_THOUGHTS_DAY",
|
||||
str(obbff.ENABLE_THOUGHTS_DAY),
|
||||
)
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_reporthtml(self, _):
|
||||
"""Process reporthtml command"""
|
||||
obbff.OPEN_REPORT_AS_HTML = not obbff.OPEN_REPORT_AS_HTML
|
||||
set_key(ENV_FILE, "OPENBB_OPEN_REPORT_AS_HTML", str(obbff.OPEN_REPORT_AS_HTML))
|
||||
set_key(
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_OPEN_REPORT_AS_HTML",
|
||||
str(obbff.OPEN_REPORT_AS_HTML),
|
||||
)
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@@ -208,7 +220,7 @@ class SettingsController(BaseController):
|
||||
"""Process exithelp command"""
|
||||
obbff.ENABLE_EXIT_AUTO_HELP = not obbff.ENABLE_EXIT_AUTO_HELP
|
||||
set_key(
|
||||
ENV_FILE,
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_ENABLE_EXIT_AUTO_HELP",
|
||||
str(obbff.ENABLE_EXIT_AUTO_HELP),
|
||||
)
|
||||
@@ -218,42 +230,50 @@ class SettingsController(BaseController):
|
||||
def call_rcontext(self, _):
|
||||
"""Process rcontext command"""
|
||||
obbff.REMEMBER_CONTEXTS = not obbff.REMEMBER_CONTEXTS
|
||||
set_key(ENV_FILE, "OPENBB_REMEMBER_CONTEXTS", str(obbff.REMEMBER_CONTEXTS))
|
||||
set_key(
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_REMEMBER_CONTEXTS",
|
||||
str(obbff.REMEMBER_CONTEXTS),
|
||||
)
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_dt(self, _):
|
||||
"""Process dt command"""
|
||||
obbff.USE_DATETIME = not obbff.USE_DATETIME
|
||||
set_key(ENV_FILE, "OPENBB_USE_DATETIME", str(obbff.USE_DATETIME))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_USE_DATETIME", str(obbff.USE_DATETIME))
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_rich(self, _):
|
||||
"""Process rich command"""
|
||||
obbff.ENABLE_RICH = not obbff.ENABLE_RICH
|
||||
set_key(ENV_FILE, "OPENBB_ENABLE_RICH", str(obbff.ENABLE_RICH))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_ENABLE_RICH", str(obbff.ENABLE_RICH))
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_richpanel(self, _):
|
||||
"""Process richpanel command"""
|
||||
obbff.ENABLE_RICH_PANEL = not obbff.ENABLE_RICH_PANEL
|
||||
set_key(ENV_FILE, "OPENBB_ENABLE_RICH_PANEL", str(obbff.ENABLE_RICH_PANEL))
|
||||
set_key(
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_ENABLE_RICH_PANEL",
|
||||
str(obbff.ENABLE_RICH_PANEL),
|
||||
)
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_ion(self, _):
|
||||
"""Process ion command"""
|
||||
obbff.USE_ION = not obbff.USE_ION
|
||||
set_key(ENV_FILE, "OPENBB_USE_ION", str(obbff.USE_ION))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_USE_ION", str(obbff.USE_ION))
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_watermark(self, _):
|
||||
"""Process watermark command"""
|
||||
obbff.USE_WATERMARK = not obbff.USE_WATERMARK
|
||||
set_key(ENV_FILE, "OPENBB_USE_WATERMARK", str(obbff.USE_WATERMARK))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_USE_WATERMARK", str(obbff.USE_WATERMARK))
|
||||
console.print("")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@@ -261,7 +281,7 @@ class SettingsController(BaseController):
|
||||
"""Process cmdloc command"""
|
||||
obbff.USE_CMD_LOCATION_FIGURE = not obbff.USE_CMD_LOCATION_FIGURE
|
||||
set_key(
|
||||
ENV_FILE,
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_USE_CMD_LOCATION_FIGURE",
|
||||
str(obbff.USE_CMD_LOCATION_FIGURE),
|
||||
)
|
||||
@@ -272,7 +292,7 @@ class SettingsController(BaseController):
|
||||
"""Process autoscaling command"""
|
||||
obbff.USE_PLOT_AUTOSCALING = not obbff.USE_PLOT_AUTOSCALING
|
||||
set_key(
|
||||
ENV_FILE,
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_USE_PLOT_AUTOSCALING",
|
||||
str(obbff.USE_PLOT_AUTOSCALING),
|
||||
)
|
||||
@@ -298,7 +318,7 @@ class SettingsController(BaseController):
|
||||
other_args.insert(0, "-v")
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if ns_parser:
|
||||
set_key(ENV_FILE, "OPENBB_PLOT_DPI", str(ns_parser.value))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_PLOT_DPI", str(ns_parser.value))
|
||||
cfg_plot.PLOT_DPI = ns_parser.value
|
||||
console.print("")
|
||||
|
||||
@@ -322,7 +342,7 @@ class SettingsController(BaseController):
|
||||
other_args.insert(0, "-v")
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if ns_parser:
|
||||
set_key(ENV_FILE, "OPENBB_PLOT_HEIGHT", str(ns_parser.value))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_PLOT_HEIGHT", str(ns_parser.value))
|
||||
cfg_plot.PLOT_HEIGHT = ns_parser.value
|
||||
console.print("")
|
||||
|
||||
@@ -346,7 +366,7 @@ class SettingsController(BaseController):
|
||||
other_args.insert(0, "-v")
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if ns_parser:
|
||||
set_key(ENV_FILE, "OPENBB_PLOT_WIDTH", str(ns_parser.value))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_PLOT_WIDTH", str(ns_parser.value))
|
||||
cfg_plot.PLOT_WIDTH = ns_parser.value
|
||||
console.print("")
|
||||
|
||||
@@ -370,7 +390,11 @@ class SettingsController(BaseController):
|
||||
other_args.insert(0, "-v")
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if ns_parser:
|
||||
set_key(ENV_FILE, "OPENBB_PLOT_HEIGHT_PERCENTAGE", str(ns_parser.value))
|
||||
set_key(
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_PLOT_HEIGHT_PERCENTAGE",
|
||||
str(ns_parser.value),
|
||||
)
|
||||
cfg_plot.PLOT_HEIGHT_PERCENTAGE = ns_parser.value
|
||||
console.print("")
|
||||
|
||||
@@ -394,7 +418,11 @@ class SettingsController(BaseController):
|
||||
other_args.insert(0, "-v")
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if ns_parser:
|
||||
set_key(ENV_FILE, "OPENBB_PLOT_WIDTH_PERCENTAGE", str(ns_parser.value))
|
||||
set_key(
|
||||
obbff.ENV_FILE,
|
||||
"OPENBB_PLOT_WIDTH_PERCENTAGE",
|
||||
str(ns_parser.value),
|
||||
)
|
||||
cfg_plot.PLOT_WIDTH_PERCENTAGE = ns_parser.value
|
||||
console.print("")
|
||||
|
||||
@@ -418,7 +446,7 @@ class SettingsController(BaseController):
|
||||
other_args.insert(0, "-v")
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if ns_parser:
|
||||
set_key(ENV_FILE, "OPENBB_MONITOR", str(ns_parser.value))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_MONITOR", str(ns_parser.value))
|
||||
cfg_plot.MONITOR = ns_parser.value
|
||||
console.print("")
|
||||
|
||||
@@ -442,7 +470,7 @@ class SettingsController(BaseController):
|
||||
other_args.insert(0, "-v")
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if ns_parser:
|
||||
set_key(ENV_FILE, "OPENBB_BACKEND", str(ns_parser.value))
|
||||
set_key(obbff.ENV_FILE, "OPENBB_BACKEND", str(ns_parser.value))
|
||||
if ns_parser.value == "None":
|
||||
cfg_plot.BACKEND = None # type: ignore
|
||||
else:
|
||||
|
||||
@@ -15,7 +15,7 @@ import dotenv
|
||||
|
||||
from prompt_toolkit.completion import NestedCompleter
|
||||
|
||||
from openbb_terminal.core.config.constants import REPO_DIR
|
||||
from openbb_terminal.core.config.constants import REPO_DIR, ENV_FILE
|
||||
from openbb_terminal import feature_flags as obbff
|
||||
from openbb_terminal.helper_funcs import (
|
||||
check_path,
|
||||
@@ -44,7 +44,7 @@ from openbb_terminal.terminal_helper import (
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
env_file = ".env"
|
||||
env_file = str(ENV_FILE)
|
||||
|
||||
|
||||
class TerminalController(BaseController):
|
||||
@@ -767,7 +767,7 @@ def main(
|
||||
if fails:
|
||||
console.print("\n[red]Failures:[/red]\n")
|
||||
for key, value in fails.items():
|
||||
file_name = key[key.rfind("OpenBBTerminal") :].replace( # noqa: E203
|
||||
file_name = key[key.rfind(REPO_DIR.name) :].replace( # noqa: E203
|
||||
"\\", "/"
|
||||
)
|
||||
logger.error("%s: %s failed", file_name, value)
|
||||
|
||||
Reference in New Issue
Block a user