summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Radovanovic <74266147+IgorWounds@users.noreply.github.com>2024-05-13 10:21:11 +0200
committerGitHub <noreply@github.com>2024-05-13 08:21:11 +0000
commitb99655a9733599c45588a3c6fd4d0c436a8ca3b2 (patch)
tree19bc84bc5f75244fea9b51ef3839857fac909831
parent0139dbf7a233e71fb5aee17ecb74cb6e0a2322f4 (diff)
[BugFix] - Remove unused old code (#6395)
* Remove unused old code * Remvove from settings choices * Fix CLI exit when FileNotFound error on routine --------- Co-authored-by: Henrique Joaquim <henriquecjoaquim@gmail.com>
-rw-r--r--cli/openbb_cli/controllers/cli_controller.py20
-rw-r--r--cli/openbb_cli/controllers/settings_controller.py1
-rw-r--r--cli/openbb_cli/controllers/utils.py90
3 files changed, 9 insertions, 102 deletions
diff --git a/cli/openbb_cli/controllers/cli_controller.py b/cli/openbb_cli/controllers/cli_controller.py
index aec72410a84..5f16f070229 100644
--- a/cli/openbb_cli/controllers/cli_controller.py
+++ b/cli/openbb_cli/controllers/cli_controller.py
@@ -16,7 +16,6 @@ from pathlib import Path
from types import MethodType
from typing import Any, Dict, List, Optional
-import certifi
import pandas as pd
import requests
from openbb import obb
@@ -37,7 +36,6 @@ from openbb_cli.controllers.utils import (
bootup,
first_time_user,
get_flair_and_username,
- is_installer,
parse_and_split_input,
print_goodbye,
print_rich_table,
@@ -66,13 +64,6 @@ logger = logging.getLogger(__name__)
env_file = str(ENV_FILE_SETTINGS)
session = Session()
-if is_installer():
- # Necessary for installer so that it can locate the correct certificates for
- # API calls and https
- # https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error/73270162#73270162
- os.environ["REQUESTS_CA_BUNDLE"] = certifi.where()
- os.environ["SSL_CERT_FILE"] = certifi.where()
-
class CLIController(BaseController):
"""CLI Controller class."""
@@ -432,8 +423,9 @@ class CLIController(BaseController):
else:
return
- with open(routine_path) as fp:
- raw_lines = list(fp)
+ try:
+ with open(routine_path) as fp:
+ raw_lines = list(fp)
# Capture ARGV either as list if args separated by commas or as single value
if ns_parser.routine_args:
@@ -487,6 +479,12 @@ class CLIController(BaseController):
)
self.queue = self.queue[1:]
+ except FileNotFoundError:
+ session.console.print(
+ f"[red]File '{routine_path}' doesn't exist.[/red]\n"
+ )
+ return
+
def handle_job_cmds(jobs_cmds: Optional[List[str]]) -> Optional[List[str]]:
"""Handle job commands."""
diff --git a/cli/openbb_cli/controllers/settings_controller.py b/cli/openbb_cli/controllers/settings_controller.py
index f01742f6cb2..8783ef47e1b 100644
--- a/cli/openbb_cli/controllers/settings_controller.py
+++ b/cli/openbb_cli/controllers/settings_controller.py
@@ -19,7 +19,6 @@ class SettingsController(BaseController):
"""Settings Controller class."""
CHOICES_COMMANDS: List[str] = [
- "tab",
"interactive",
"cls",
"watermark",
diff --git a/cli/openbb_cli/controllers/utils.py b/cli/openbb_cli/controllers/utils.py
index cfeb7cbadab..333ad0b0cc6 100644
--- a/cli/openbb_cli/controllers/utils.py
+++ b/cli/openbb_cli/controllers/utils.py
@@ -21,7 +21,6 @@ from openbb_charting.core.backend import create_backend, get_backend
from openbb_cli.config.constants import AVAILABLE_FLAIRS, ENV_FILE_SETTINGS
from openbb_cli.session import Session
from openbb_core.app.model.charts.charting_settings import ChartingSettings
-from packaging import version
from pytz import all_timezones, timezone
from rich.table import Table
@@ -91,24 +90,6 @@ Please feel free to check out our other products:
Session().console.print(text)
-def hide_splashscreen():
- """Hide the splashscreen on Windows bundles.
-
- `pyi_splash` is a PyInstaller "fake-package" that's used to communicate
- with the splashscreen on Windows.
- Sending the `close` signal to the splash screen is required.
- The splash screen remains open until this function is called or the Python
- program is terminated.
- """
- try:
- import pyi_splash # type: ignore # pylint: disable=import-outside-toplevel
-
- pyi_splash.update_text("CLI Loaded!")
- pyi_splash.close()
- except Exception as e:
- Session().console.print(f"Error: Unable to hide splashscreen: {e}")
-
-
def print_guest_block_msg():
"""Block guest users from using the cli."""
if Session().is_local():
@@ -120,19 +101,11 @@ def print_guest_block_msg():
)
-def is_installer() -> bool:
- """Check whether or not it is a packaged version (Windows or Mac installer."""
- return getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")
-
-
def bootup():
"""Bootup the cli."""
if sys.platform == "win32":
# Enable VT100 Escape Sequence for WINDOWS 10 Ver. 1607
os.system("") # nosec # noqa: S605,S607
- # Hide splashscreen loader of the packaged app
- if is_installer():
- hide_splashscreen()
try:
if os.name == "nt":
@@ -144,69 +117,6 @@ def bootup():
Session().console.print(e, "\n")
-def check_for_updates() -> None:
- """Check if the latest version is running.
-
- Checks github for the latest release version and compares it to cfg.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 = request(
- "https://api.github.com/repos/openbb-finance/openbbterminal/releases/latest"
- )
- except Exception:
- r = None
-
- if r and r.status_code == 200:
- latest_tag_name = r.json()["tag_name"]
- latest_version = version.parse(latest_tag_name)
- current_version = version.parse(Session().settings.VERSION)
-
- if check_valid_versions(latest_version, current_version):
- if current_version == latest_version:
- Session().console.print(
- "[green]You are using the latest stable version[/green]"
- )
- else:
- Session().console.print(
- "[yellow]You are not using the latest stable version[/yellow]"
- )
- if current_version < latest_version:
- Session().console.print(
- "[yellow]Check for updates at https://my.openbb.co/app/terminal/download[/yellow]"
- )
-
- else:
- Session().console.print(
- "[yellow]You are using an unreleased version[/yellow]"
- )
-
- else:
- Session().console.print("[red]You are using an unrecognized version.[/red]")
- else:
- Session().console.print(
- "[yellow]Unable to check for updates... "
- + "Check your internet connection and try again...[/yellow]"
- )
- Session().console.print("\n")
-
-
-def check_valid_versions(
- latest_version: version.Version,
- current_version: version.Version,
-) -> bool:
- """Check if the versions are valid."""
- if (
- not latest_version
- or not current_version
- or not isinstance(latest_version, version.Version)
- or not isinstance(current_version, version.Version)
- ):
- return False
- return True
-
-
def welcome_message():
"""Print the welcome message.