mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 05:52:23 +00:00
Add check for updates at terminal startup (#1839)
* Add check for updates at terminal startup * Fix ycrv missing from documentation * Add new line after update check message Co-authored-by: didierlopes.eth <dro.lopes@campus.fct.unl.pt> Co-authored-by: James Maslek <jmaslek11@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c75f15471e
commit
7b374b7662
@@ -11,6 +11,7 @@ import sys
|
||||
from typing import List
|
||||
|
||||
# IMPORTATION THIRDPARTY
|
||||
import requests
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# IMPORTATION INTERNAL
|
||||
@@ -160,12 +161,44 @@ def bootup():
|
||||
console.print(e, "\n")
|
||||
|
||||
|
||||
def welcome_message():
|
||||
# Print first welcome message and help
|
||||
console.print(f"\nWelcome to OpenBB Terminal v{obbff.VERSION}")
|
||||
def check_for_updates() -> None:
|
||||
"""Check if the latest version is running.
|
||||
|
||||
Checks github for the latest release version and compares it to obbff.VERSION.
|
||||
"""
|
||||
# The commit has was commented out because the terminal was crashing due to git import for multiple users
|
||||
# ({str(git.Repo('.').head.commit)[:7]})
|
||||
try:
|
||||
r = requests.get(
|
||||
"https://api.github.com/repos/openbb-finance/openbbterminal/releases/latest",
|
||||
timeout=1,
|
||||
)
|
||||
except Exception:
|
||||
r = None
|
||||
|
||||
if r is not None and r.status_code == 200:
|
||||
release = r.json()["html_url"].split("/")[-1].replace("v", "")
|
||||
if obbff.VERSION == release:
|
||||
console.print("[green]You are using the latest version[/green]")
|
||||
else:
|
||||
console.print("[red]You are not using the latest version[/red]")
|
||||
console.print(
|
||||
"[yellow]Check for updates at https://openbb.co/products/terminal#get-started[/yellow]"
|
||||
)
|
||||
else:
|
||||
console.print(
|
||||
"[yellow]Unable to check for updates... "
|
||||
+ "Check your internet connection and try again...[/yellow]"
|
||||
)
|
||||
console.print("")
|
||||
|
||||
|
||||
def welcome_message():
|
||||
"""Print the welcome message
|
||||
|
||||
Prints first welcome message, help and a notification if updates are available.
|
||||
"""
|
||||
console.print(f"\nWelcome to OpenBB Terminal v{obbff.VERSION}")
|
||||
|
||||
if obbff.ENABLE_THOUGHTS_DAY:
|
||||
console.print("-------------------")
|
||||
|
||||
@@ -32,6 +32,7 @@ from openbb_terminal.rich_config import console
|
||||
from openbb_terminal.terminal_helper import (
|
||||
about_us,
|
||||
bootup,
|
||||
check_for_updates,
|
||||
is_reset,
|
||||
print_goodbye,
|
||||
reset,
|
||||
@@ -519,6 +520,7 @@ def terminal(jobs_cmds: List[str] = None, appName: str = "gst"):
|
||||
if not jobs_cmds:
|
||||
welcome_message()
|
||||
t_controller.print_help()
|
||||
check_for_updates()
|
||||
|
||||
env_files = [f for f in os.listdir() if f.endswith(".env")]
|
||||
if env_files:
|
||||
|
||||
Reference in New Issue
Block a user