Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix settings not updating right away #2851

Merged
merged 10 commits into from
Oct 18, 2022
41 changes: 36 additions & 5 deletions openbb_terminal/config_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
import dotenv

from openbb_terminal.core.config.paths import USER_ENV_FILE, REPOSITORY_ENV_FILE
from openbb_terminal.rich_config import console

dotenv.load_dotenv(USER_ENV_FILE)
dotenv.load_dotenv(REPOSITORY_ENV_FILE, override=True)

PLOT_DPI = int(os.getenv("OPENBB_PLOT_DPI", "100"))
try:
PLOT_DPI = int(os.getenv("OPENBB_PLOT_DPI", "100"))
except ValueError:
PLOT_DPI = 100
console.print(
f"[red]OPENBB_PLOT_DPI is not an integer, using default value of {PLOT_DPI}[/red]"
)

# Backend to use for plotting
BACKEND = os.getenv("OPENBB_BACKEND", "None")
Expand All @@ -21,12 +28,36 @@
# See more: https://matplotlib.org/stable/tutorials/introductory/usage.html#the-builtin-backends

# Used when USE_PLOT_AUTOSCALING is set to False
PLOT_HEIGHT = int(os.getenv("OPENBB_PLOT_HEIGHT", "500"))
PLOT_WIDTH = int(os.getenv("OPENBB_PLOT_WIDTH", "800"))
try:
PLOT_HEIGHT = int(os.getenv("OPENBB_PLOT_HEIGHT", "500"))
except ValueError:
PLOT_HEIGHT = 500
console.print(
"[red] Invalid value for OPENBB_PLOT_HEIGHT. Please use a number.[/red]\n"
)
try:
PLOT_WIDTH = int(os.getenv("OPENBB_PLOT_WIDTH", "800"))
except ValueError:
PLOT_WIDTH = 800
console.print(
"[red] Invalid value for OPENBB_PLOT_WIDTH. Please use a number.[/red]\n"
)

# Used when USE_PLOT_AUTOSCALING is set to True
PLOT_HEIGHT_PERCENTAGE = float(os.getenv("OPENBB_PLOT_HEIGHT_PERCENTAGE", "50.00"))
PLOT_WIDTH_PERCENTAGE = float(os.getenv("OPENBB_PLOT_WIDTH_PERCENTAGE", "70.00"))
try:
PLOT_HEIGHT_PERCENTAGE = float(os.getenv("OPENBB_PLOT_HEIGHT_PERCENTAGE", "50.00"))
except ValueError:
PLOT_HEIGHT_PERCENTAGE = 50.00
console.print(
"[red] Invalid value for OPENBB_PLOT_HEIGHT_PERCENTAGE. Please use a number.[/red]\n"
)
try:
PLOT_WIDTH_PERCENTAGE = float(os.getenv("OPENBB_PLOT_WIDTH_PERCENTAGE", "70.00"))
except ValueError:
PLOT_WIDTH_PERCENTAGE = 70.00
console.print(
"[red] Invalid value for OPENBB_PLOT_WIDTH_PERCENTAGE. Please use a number.[/red]\n"
)

# When autoscaling is True, choose which monitor to scale to
# Primary monitor = 0, secondary monitor use 1
Expand Down
1 change: 1 addition & 0 deletions openbb_terminal/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ def replace_user_timezone(user_tz: str) -> None:
"""
if is_timezone_valid(user_tz):
dotenv.set_key(USER_ENV_FILE, "OPENBB_TIMEZONE", user_tz)
os.environ["OPENBB_TIMEZONE"] = user_tz
console.print("Timezone successfully updated", "\n")
else:
console.print("Timezone selected is not valid", "\n")
Expand Down