Fix logging for users that don't rename parent folder to OpenBBTerminal (#1613)

* Fix terminal for issues when the repository keeps GamestonkTerminal name

* the logs will work regardless of parent folder they are in

* Logging : move log folder

* Fixing bug + Refactoring + Allow calling Terminal from outside the repo

* Black

* Remove comment

* SettingsController : fix

* Black

Co-authored-by: jmaslek <jmaslek11@gmail.com>
Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com>
Co-authored-by: Chavithra <chavithra@gmail.com>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
This commit is contained in:
didierlopes.eth
2022-04-04 10:29:50 +01:00
committed by GitHub
parent 826cd8a723
commit 39d6955a04
18 changed files with 104 additions and 176 deletions

View File

@@ -0,0 +1,6 @@
# IMPORTATION STANDARD
from pathlib import Path
REPO_DIR = Path(__file__).parent.parent.parent.parent
ENV_FILE = REPO_DIR.joinpath(".env")
DEFAULT_FILE = REPO_DIR.joinpath("OPENBB_DEFAULTS.json")

View File

@@ -8,13 +8,13 @@ from pathlib import Path
# IMPORTATION INTERNAL
from openbb_terminal.feature_flags import LOG_COLLECTION
from openbb_terminal.log.constants import (
from openbb_terminal.core.log.constants import (
ARCHIVES_FOLDER_NAME,
S3_FOLDER_SUFFIX,
TMP_FOLDER_NAME,
)
from openbb_terminal.log.collection.s3_sender import send_to_s3
from openbb_terminal.log.generation.settings import Settings
from openbb_terminal.core.log.collection.s3_sender import send_to_s3
from openbb_terminal.core.log.generation.settings import Settings
# DO NOT USE THE FILE LOGGER IN THIS MODULE

View File

@@ -14,11 +14,11 @@ else:
WITH_BOTO3 = True
# IMPORTATION INTERNAL
from openbb_terminal.log.constants import (
from openbb_terminal.core.log.constants import (
DEFAULT_API_URL,
DEFAULT_BUCKET,
)
from openbb_terminal.log.generation.settings import AWSSettings
from openbb_terminal.core.log.generation.settings import AWSSettings
# DO NOT USE THE FILE LOGGER IN THIS MODULE

View File

@@ -6,7 +6,8 @@ import re
# IMPORTATION THIRDPARTY
# IMPORTATION INTERNAL
from openbb_terminal.log.generation.settings import AppSettings
from openbb_terminal.core.config.constants import REPO_DIR
from openbb_terminal.core.log.generation.settings import AppSettings
class FormatterWithExceptions(logging.Formatter):
@@ -49,22 +50,16 @@ class FormatterWithExceptions(logging.Formatter):
ip_regex = r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
s_list = []
ip_reg = re.compile(ip_regex)
for word in text.split():
if (
ip_reg.search(word)
# and int(max(word.split("."))) < 256
# and int(min(word.split("."))) >= 0
):
if ip_reg.search(word):
s_list.append("suspected_ip")
elif "@" in word and "." in word:
s_list.append("suspected_email")
elif (
f"OpenBBTerminal{os.sep}" in word
or f"GamestonkTerminal{os.sep}" in word
):
elif f"{REPO_DIR.name}{os.sep}" in word:
s_list.append(
word.split(f"OpenBBTerminal{os.sep}")[1]
word.split(f"{REPO_DIR.name}{os.sep}")[1]
.replace('"', "")
.replace("'", "")
)
@@ -110,7 +105,7 @@ class FormatterWithExceptions(logging.Formatter):
+ cls.filter_piis(text=second_message)
)
elif "CMD: {" not in text and "QUEUE: {" not in text:
cls.filter_piis(text=text)
text = cls.filter_piis(text=text)
return text

View File

@@ -7,17 +7,17 @@ from typing import Callable
# IMPORTATION THIRDPARTY
# IMPORTATION INTERNAL
from openbb_terminal.log.constants import ARCHIVES_FOLDER_NAME, TMP_FOLDER_NAME
from openbb_terminal.log.collection.log_sender import LogSender
from openbb_terminal.log.collection.logging_clock import LoggingClock, Precision
from openbb_terminal.log.generation.directories import get_log_dir, get_log_sub_dir
from openbb_terminal.log.generation.expired_files import (
from openbb_terminal.core.log.constants import ARCHIVES_FOLDER_NAME, TMP_FOLDER_NAME
from openbb_terminal.core.log.collection.log_sender import LogSender
from openbb_terminal.core.log.collection.logging_clock import LoggingClock, Precision
from openbb_terminal.core.log.generation.directories import get_log_dir, get_log_sub_dir
from openbb_terminal.core.log.generation.expired_files import (
get_expired_file_list,
get_timestamp_from_x_days,
remove_file_list,
)
from openbb_terminal.log.generation.settings import Settings
from openbb_terminal.core.log.generation.settings import Settings
class PathTrackingFileHandler(TimedRotatingFileHandler):

View File

@@ -128,9 +128,9 @@ class Settings:
log_settings: LogSettings,
):
"""This model regroups all configurations used by these classes instance :
- openbb_terminal.log.collection.log_sender.LogSender
- openbb_terminal.log.generation.formatter_with_exceptions.FormatterWithExceptions
- openbb_terminal.log.generation.path_tracking_file_handler.PathTrackingFileHandler
- openbb_terminal.core.log.collection.log_sender.LogSender
- openbb_terminal.core.log.generation.formatter_with_exceptions.FormatterWithExceptions
- openbb_terminal.core.log.generation.path_tracking_file_handler.PathTrackingFileHandler
Args:
app_name (str): Instance of AppSettings.

View File

@@ -1,134 +1,88 @@
# IMPORTATION STANDARD
import os
import json
from distutils.util import strtobool
from typing import Union, Optional
# IMPORTATION THIRDPARTY
from dotenv import load_dotenv
OPENBB_defaults_path = os.path.join(os.path.dirname(__file__), "OPENBB_DEFAULTS.json")
if os.path.exists(OPENBB_defaults_path):
with open(OPENBB_defaults_path) as f:
OPENBB_DEFAULTS = json.load(f)
else:
OPENBB_DEFAULTS = dict()
# IMPORTATION INTERNAL
from openbb_terminal.core.config.constants import DEFAULT_FILE, ENV_FILE
env_files = [f for f in os.listdir() if f.endswith(".env")]
if env_files:
load_dotenv(env_files[0])
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
def assign_feature_flag(
feature_flag: str, fallback_value: str, return_bool: bool = False
) -> Optional[Union[str, bool]]:
"""Get the feature flag value in order of priority.
- Env variables have the highest priority
- The OPENBB_DEFAULTS dictionary has the defaults for the bundled app
- Fallback value is used if none of the above mentioned places have feature flag settings
Parameters
----------
feature_flag : str
Feature flag as upper-case string
fallback_value : str
Fallback vabue
return_bool : bool, optional
If a boolean should be returned vs a string, by default False
Returns
-------
Optional[Union[str, bool]]
The feature flag value or None
"""
if bool(os.getenv(feature_flag)):
feature_flag_value = (
strtobool(os.getenv(feature_flag)) # type: ignore
if return_bool
else os.getenv(feature_flag)
)
elif feature_flag in OPENBB_DEFAULTS:
feature_flag_value = (
strtobool(OPENBB_DEFAULTS[feature_flag])
if return_bool
else OPENBB_DEFAULTS[feature_flag]
)
else:
feature_flag_value = (
strtobool(fallback_value) if return_bool else fallback_value
)
return feature_flag_value
if ENV_FILE.is_file():
load_dotenv(ENV_FILE)
# Use tabulate to print dataframes
USE_TABULATE_DF = assign_feature_flag("OPENBB_USE_TABULATE_DF", "True", True)
USE_TABULATE_DF = strtobool(os.getenv("OPENBB_USE_TABULATE_DF", "True"))
# Use clear console after each command
USE_CLEAR_AFTER_CMD = assign_feature_flag("OPENBB_USE_CLEAR_AFTER_CMD", "False", True)
USE_CLEAR_AFTER_CMD = strtobool(os.getenv("OPENBB_USE_CLEAR_AFTER_CMD", "False"))
# Use coloring features
USE_COLOR = assign_feature_flag("OPENBB_USE_COLOR", "True", True)
USE_COLOR = strtobool(os.getenv("OPENBB_USE_COLOR", "True"))
# Select console flair (choose from config_terminal.py list)
USE_FLAIR = assign_feature_flag("OPENBB_USE_FLAIR", ":openbb")
USE_FLAIR = str(os.getenv("OPENBB_USE_FLAIR", ":openbb"))
# Add date and time to command line
USE_DATETIME = assign_feature_flag("OPENBB_USE_DATETIME", "True", True)
USE_DATETIME = strtobool(os.getenv("OPENBB_USE_DATETIME", "True"))
# Enable interactive matplotlib mode
USE_ION = assign_feature_flag("OPENBB_USE_ION", "True", True)
USE_ION = strtobool(os.getenv("OPENBB_USE_ION", "True"))
# Enable watermark in the figures
USE_WATERMARK = assign_feature_flag("OPENBB_USE_WATERMARK", "True", True)
USE_WATERMARK = strtobool(os.getenv("OPENBB_USE_WATERMARK", "True"))
# Enable command and source in the figures
USE_CMD_LOCATION_FIGURE = assign_feature_flag(
"OPENBB_USE_CMD_LOCATION_FIGURE", "True", True
)
USE_CMD_LOCATION_FIGURE = strtobool(os.getenv("OPENBB_USE_CMD_LOCATION_FIGURE", "True"))
# Enable Prompt Toolkit
USE_PROMPT_TOOLKIT = assign_feature_flag("OPENBB_USE_PROMPT_TOOLKIT", "True", True)
USE_PROMPT_TOOLKIT = strtobool(os.getenv("OPENBB_USE_PROMPT_TOOLKIT", "True"))
# Enable Prediction features
ENABLE_PREDICT = assign_feature_flag("OPENBB_ENABLE_PREDICT", "True", True)
ENABLE_PREDICT = strtobool(os.getenv("OPENBB_ENABLE_PREDICT", "True"))
# Enable plot autoscaling
USE_PLOT_AUTOSCALING = assign_feature_flag("OPENBB_USE_PLOT_AUTOSCALING", "False", True)
USE_PLOT_AUTOSCALING = strtobool(os.getenv("OPENBB_USE_PLOT_AUTOSCALING", "False"))
# Enable thoughts of the day
ENABLE_THOUGHTS_DAY = assign_feature_flag("OPENBB_ENABLE_THOUGHTS_DAY", "False", True)
ENABLE_THOUGHTS_DAY = strtobool(os.getenv("OPENBB_ENABLE_THOUGHTS_DAY", "False"))
# Quick exit for testing
ENABLE_QUICK_EXIT = assign_feature_flag("OPENBB_ENABLE_QUICK_EXIT", "False", True)
ENABLE_QUICK_EXIT = strtobool(os.getenv("OPENBB_ENABLE_QUICK_EXIT", "False"))
# Open report as HTML, otherwise notebook
OPEN_REPORT_AS_HTML = assign_feature_flag("OPENBB_OPEN_REPORT_AS_HTML", "True", True)
OPEN_REPORT_AS_HTML = strtobool(os.getenv("OPENBB_OPEN_REPORT_AS_HTML", "True"))
# Enable auto print_help when exiting menus
ENABLE_EXIT_AUTO_HELP = assign_feature_flag(
"OPENBB_ENABLE_EXIT_AUTO_HELP", "False", True
)
ENABLE_EXIT_AUTO_HELP = strtobool(os.getenv("OPENBB_ENABLE_EXIT_AUTO_HELP", "False"))
# Remember contexts during session
REMEMBER_CONTEXTS = assign_feature_flag("OPENBB_REMEMBER_CONTEXTS", "True", True)
REMEMBER_CONTEXTS = strtobool(os.getenv("OPENBB_REMEMBER_CONTEXTS", "True"))
# Use the colorful rich terminal
ENABLE_RICH = assign_feature_flag("OPENBB_ENABLE_RICH", "True", True)
ENABLE_RICH = strtobool(os.getenv("OPENBB_ENABLE_RICH", "True"))
# Use the colorful rich terminal
ENABLE_RICH_PANEL = assign_feature_flag("OPENBB_ENABLE_RICH_PANEL", "True", True)
ENABLE_RICH_PANEL = strtobool(os.getenv("OPENBB_ENABLE_RICH_PANEL", "True"))
# Check API KEYS before running a command
ENABLE_CHECK_API = assign_feature_flag("OPENBB_ENABLE_CHECK_API", "True", True)
ENABLE_CHECK_API = strtobool(os.getenv("OPENBB_ENABLE_CHECK_API", "True"))
# Send logs to data lake
LOG_COLLECTION = bool(assign_feature_flag("OPENBB_LOG_COLLECTION", "True", True))
LOG_COLLECTION = strtobool(os.getenv("OPENBB_LOG_COLLECTION", "True"))
# Provide export folder path. If empty that means default.
EXPORT_FOLDER_PATH = assign_feature_flag("OPENBB_EXPORT_FOLDER_PATH", "")
EXPORT_FOLDER_PATH = str(os.getenv("OPENBB_EXPORT_FOLDER_PATH", ""))
# Set a flag if the application is running from a packaged bundle
PACKAGED_APPLICATION = assign_feature_flag("OPENBB_PACKAGED_APPLICATION", "False", True)
PACKAGED_APPLICATION = strtobool(os.getenv("OPENBB_PACKAGED_APPLICATION", "False"))
LOGGING_COMMIT_HASH = str(
assign_feature_flag("OPENBB_LOGGING_COMMIT_HASH", "REPLACE_ME")
)
LOGGING_COMMIT_HASH = str(os.getenv("OPENBB_LOGGING_COMMIT_HASH", "REPLACE_ME"))

View File

@@ -3,7 +3,6 @@ __docformat__ = "numpy"
# IMPORTATION STANDARD
import logging
import os
import sys
import time
from pathlib import Path
@@ -28,19 +27,19 @@ from openbb_terminal.config_terminal import (
LOGGING_ROLLING_CLOCK,
LOGGING_VERBOSITY,
)
from openbb_terminal.log.generation.settings import (
from openbb_terminal.core.log.generation.settings import (
AppSettings,
AWSSettings,
LogSettings,
Settings,
)
from openbb_terminal.log.generation.path_tracking_file_handler import (
from openbb_terminal.core.log.generation.path_tracking_file_handler import (
PathTrackingFileHandler,
)
from openbb_terminal.log.generation.formatter_with_exceptions import (
from openbb_terminal.core.log.generation.formatter_with_exceptions import (
FormatterWithExceptions,
)
from openbb_terminal.log.generation.directories import get_log_dir
from openbb_terminal.core.log.generation.directories import get_log_dir
logging.getLogger("requests").setLevel(LOGGING_VERBOSITY)
logging.getLogger("urllib3").setLevel(LOGGING_VERBOSITY)
@@ -75,11 +74,10 @@ def get_commit_hash() -> str:
if obbff.LOGGING_COMMIT_HASH != "REPLACE_ME":
return obbff.LOGGING_COMMIT_HASH
file_path = Path(__file__)
git_dir = file_path.parent.parent.absolute().joinpath(".git")
git_dir = Path(__file__).parent.parent.joinpath(".git")
if WITH_GIT and os.path.isdir(git_dir.absolute()):
repo = git.Repo(search_parent_directories=True)
if WITH_GIT and git_dir.is_dir():
repo = git.Repo(path=git_dir)
sha = repo.head.object.hexsha
short_sha = repo.git.rev_parse(sha, short=8)
commit_hash = f"sha:{short_sha}"

View File

@@ -1,17 +1,19 @@
"""Settings Controller Module"""
__docformat__ = "numpy"
# IMPORTATION STANDARD
import argparse
import logging
import os
from pathlib import Path
from typing import List
import dotenv
# IMPORTATION THIRDPARTY
from dotenv import load_dotenv, 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
@@ -19,9 +21,12 @@ 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
# pylint:disable=import-outside-toplevel
logger = logging.getLogger(__name__)
# pylint:disable=import-outside-toplevel
if ENV_FILE.is_file():
load_dotenv(ENV_FILE)
class SettingsController(BaseController):
@@ -55,14 +60,6 @@ class SettingsController(BaseController):
"monitor",
]
PATH = "/settings/"
env_file = ".env"
env_files = [f for f in os.listdir() if f.endswith(".env")]
if env_files:
env_file = env_files[0]
dotenv.load_dotenv(env_file)
else:
# create env file
Path(".env")
def __init__(self, queue: List[str] = None):
"""Constructor"""
@@ -154,78 +151,64 @@ class SettingsController(BaseController):
def call_logcollection(self, _):
"""Process logcollection command"""
obbff.LOG_COLLECTION = not obbff.LOG_COLLECTION
dotenv.set_key(
self.env_file, "OPENBB_LOG_COLLECTION", str(obbff.LOG_COLLECTION)
)
set_key(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
dotenv.set_key(
self.env_file, "OPENBB_USE_TABULATE_DF", str(obbff.USE_TABULATE_DF)
)
set_key(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
dotenv.set_key(
self.env_file, "OPENBB_USE_CLEAR_AFTER_CMD", str(obbff.USE_CLEAR_AFTER_CMD)
)
set_key(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
dotenv.set_key(self.env_file, "OPENBB_USE_COLOR", str(obbff.USE_COLOR))
set_key(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
dotenv.set_key(
self.env_file, "OPENBB_USE_PROMPT_TOOLKIT", str(obbff.USE_PROMPT_TOOLKIT)
)
set_key(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
dotenv.set_key(
self.env_file, "OPENBB_ENABLE_PREDICT", str(obbff.ENABLE_PREDICT)
)
set_key(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
dotenv.set_key(
self.env_file, "OPENBB_ENABLE_THOUGHTS_DAY", str(obbff.ENABLE_THOUGHTS_DAY)
)
set_key(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
dotenv.set_key(
self.env_file, "OPENBB_OPEN_REPORT_AS_HTML", str(obbff.OPEN_REPORT_AS_HTML)
)
set_key(ENV_FILE, "OPENBB_OPEN_REPORT_AS_HTML", str(obbff.OPEN_REPORT_AS_HTML))
console.print("")
@log_start_end(log=logger)
def call_exithelp(self, _):
"""Process exithelp command"""
obbff.ENABLE_EXIT_AUTO_HELP = not obbff.ENABLE_EXIT_AUTO_HELP
dotenv.set_key(
self.env_file,
set_key(
ENV_FILE,
"OPENBB_ENABLE_EXIT_AUTO_HELP",
str(obbff.ENABLE_EXIT_AUTO_HELP),
)
@@ -235,54 +218,50 @@ class SettingsController(BaseController):
def call_rcontext(self, _):
"""Process rcontext command"""
obbff.REMEMBER_CONTEXTS = not obbff.REMEMBER_CONTEXTS
dotenv.set_key(
self.env_file, "OPENBB_REMEMBER_CONTEXTS", str(obbff.REMEMBER_CONTEXTS)
)
set_key(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
dotenv.set_key(self.env_file, "OPENBB_USE_DATETIME", str(obbff.USE_DATETIME))
set_key(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
dotenv.set_key(self.env_file, "OPENBB_ENABLE_RICH", str(obbff.ENABLE_RICH))
set_key(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
dotenv.set_key(
self.env_file, "OPENBB_ENABLE_RICH_PANEL", str(obbff.ENABLE_RICH_PANEL)
)
set_key(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
dotenv.set_key(self.env_file, "OPENBB_USE_ION", str(obbff.USE_ION))
set_key(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
dotenv.set_key(self.env_file, "OPENBB_USE_WATERMARK", str(obbff.USE_WATERMARK))
set_key(ENV_FILE, "OPENBB_USE_WATERMARK", str(obbff.USE_WATERMARK))
console.print("")
@log_start_end(log=logger)
def call_cmdloc(self, _):
"""Process cmdloc command"""
obbff.USE_CMD_LOCATION_FIGURE = not obbff.USE_CMD_LOCATION_FIGURE
dotenv.set_key(
self.env_file,
set_key(
ENV_FILE,
"OPENBB_USE_CMD_LOCATION_FIGURE",
str(obbff.USE_CMD_LOCATION_FIGURE),
)
@@ -292,8 +271,8 @@ class SettingsController(BaseController):
def call_autoscaling(self, _):
"""Process autoscaling command"""
obbff.USE_PLOT_AUTOSCALING = not obbff.USE_PLOT_AUTOSCALING
dotenv.set_key(
self.env_file,
set_key(
ENV_FILE,
"OPENBB_USE_PLOT_AUTOSCALING",
str(obbff.USE_PLOT_AUTOSCALING),
)
@@ -319,7 +298,7 @@ class SettingsController(BaseController):
other_args.insert(0, "-v")
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
dotenv.set_key(self.env_file, "OPENBB_PLOT_DPI", str(ns_parser.value))
set_key(ENV_FILE, "OPENBB_PLOT_DPI", str(ns_parser.value))
cfg_plot.PLOT_DPI = ns_parser.value
console.print("")
@@ -343,7 +322,7 @@ class SettingsController(BaseController):
other_args.insert(0, "-v")
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
dotenv.set_key(self.env_file, "OPENBB_PLOT_HEIGHT", str(ns_parser.value))
set_key(ENV_FILE, "OPENBB_PLOT_HEIGHT", str(ns_parser.value))
cfg_plot.PLOT_HEIGHT = ns_parser.value
console.print("")
@@ -367,7 +346,7 @@ class SettingsController(BaseController):
other_args.insert(0, "-v")
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
dotenv.set_key(self.env_file, "OPENBB_PLOT_WIDTH", str(ns_parser.value))
set_key(ENV_FILE, "OPENBB_PLOT_WIDTH", str(ns_parser.value))
cfg_plot.PLOT_WIDTH = ns_parser.value
console.print("")
@@ -391,9 +370,7 @@ class SettingsController(BaseController):
other_args.insert(0, "-v")
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
dotenv.set_key(
self.env_file, "OPENBB_PLOT_HEIGHT_PERCENTAGE", str(ns_parser.value)
)
set_key(ENV_FILE, "OPENBB_PLOT_HEIGHT_PERCENTAGE", str(ns_parser.value))
cfg_plot.PLOT_HEIGHT_PERCENTAGE = ns_parser.value
console.print("")
@@ -417,9 +394,7 @@ class SettingsController(BaseController):
other_args.insert(0, "-v")
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
dotenv.set_key(
self.env_file, "OPENBB_PLOT_WIDTH_PERCENTAGE", str(ns_parser.value)
)
set_key(ENV_FILE, "OPENBB_PLOT_WIDTH_PERCENTAGE", str(ns_parser.value))
cfg_plot.PLOT_WIDTH_PERCENTAGE = ns_parser.value
console.print("")
@@ -443,7 +418,7 @@ class SettingsController(BaseController):
other_args.insert(0, "-v")
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
dotenv.set_key(self.env_file, "OPENBB_MONITOR", str(ns_parser.value))
set_key(ENV_FILE, "OPENBB_MONITOR", str(ns_parser.value))
cfg_plot.MONITOR = ns_parser.value
console.print("")
@@ -467,7 +442,7 @@ class SettingsController(BaseController):
other_args.insert(0, "-v")
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
dotenv.set_key(self.env_file, "OPENBB_BACKEND", str(ns_parser.value))
set_key(ENV_FILE, "OPENBB_BACKEND", str(ns_parser.value))
if ns_parser.value == "None":
cfg_plot.BACKEND = None # type: ignore
else: