Hotfix/plotsbackend start (#4404)

* readd removed plots_backend().start() from merged PR

* Update backend.py

---------

Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
This commit is contained in:
teh_coderer
2023-03-06 08:30:41 -06:00
committed by GitHub
parent 7917ce30d1
commit 9c582ad53f
3 changed files with 9 additions and 3 deletions

View File

@@ -5,11 +5,12 @@ import os
import i18n
# IMPORTATION INTERNAL
from openbb_terminal.core.config.paths import MISCELLANEOUS_DIRECTORY
from openbb_terminal.base_helpers import load_env_vars, strtobool
from openbb_terminal.core.config.paths import MISCELLANEOUS_DIRECTORY
from openbb_terminal.core.plots.backend import plots_backend
from openbb_terminal.core.session.current_user import get_current_user
from .helper_classes import TerminalStyle as _TerminalStyle
from .helper_classes import TerminalStyle as _TerminalStyle
# # Terminal UX section
current_user = get_current_user()
@@ -19,6 +20,9 @@ theme = _TerminalStyle(
current_user.preferences.RICH_STYLE,
)
# Start Backend for plotting
plots_backend().start(load_env_vars("DEBUG_MODE", strtobool, False))
# Logging section
# USE IN LOG LINES + FOR FOLDER NAME INSIDE S3 BUCKET

View File

@@ -30,6 +30,8 @@ class PreferencesModel:
PLOT_WIDTH: PositiveInt = 800
PLOT_HEIGHT_PERCENTAGE: PositiveFloat = 50.0
PLOT_WIDTH_PERCENTAGE: PositiveFloat = 70.0
# Whether to open plot image exports after they are created
PLOT_OPEN_EXPORT: bool = False
# FEATURE FLAGS
SYNC_ENABLED: bool = True

View File

@@ -179,7 +179,7 @@ class Backend(pywry.PyWry):
img_path.unlink(missing_ok=True)
renderPDF.drawToFile(drawing, str(export_image))
if strtobool(os.environ.get("OPENBB_PLOT_OPEN_EXPORT", False)):
if get_current_user().preferences.PLOT_OPEN_EXPORT:
if sys.platform == "win32":
os.startfile(export_image) # nosec: B606
else: