diff --git a/build/pyinstaller/terminal.spec b/build/pyinstaller/terminal.spec index 9e606f8028d..8d2902e5e0b 100644 --- a/build/pyinstaller/terminal.spec +++ b/build/pyinstaller/terminal.spec @@ -40,7 +40,6 @@ set_key(default_env_file, "OPENBB_LOGGING_COMMIT_HASH", str(commit_hash)) # Files that are explicitly pulled into the bundle added_files = [ (os.path.join(os.getcwd(), "openbb_terminal"), "openbb_terminal"), - (os.path.join(os.getcwd(), "routines"), "routines"), (os.path.join(pathex, "property_cached"), "property_cached"), (os.path.join(pathex, "user_agent"), "user_agent"), (os.path.join(pathex, "vaderSentiment"), "vaderSentiment"), diff --git a/routines/.gitkeep b/openbb_terminal/miscellaneous/routines/.gitkeep similarity index 100% rename from routines/.gitkeep rename to openbb_terminal/miscellaneous/routines/.gitkeep diff --git a/routines/README.md b/openbb_terminal/miscellaneous/routines/README.md similarity index 96% rename from routines/README.md rename to openbb_terminal/miscellaneous/routines/README.md index deb991051cb..72dbe67a594 100644 --- a/routines/README.md +++ b/openbb_terminal/miscellaneous/routines/README.md @@ -3,11 +3,13 @@ This folder introduces the concept of routines, which are meant for the user to develop and run at once. The notebook reports is a better approach to this idea, but currently the development of this is not trivial. On the other hand, the development of this is trivial as long as the user is familiar with our terminal interface. Try out with: -``` + +```bash python terminal.py routines/example.openbb ``` Or within the Terminal, use: -``` + +```bash exe routines/example.openbb -``` \ No newline at end of file +``` diff --git a/routines/comparison_demo.openbb b/openbb_terminal/miscellaneous/routines/comparison_demo.openbb similarity index 100% rename from routines/comparison_demo.openbb rename to openbb_terminal/miscellaneous/routines/comparison_demo.openbb diff --git a/routines/darkpool_demo.openbb b/openbb_terminal/miscellaneous/routines/darkpool_demo.openbb similarity index 100% rename from routines/darkpool_demo.openbb rename to openbb_terminal/miscellaneous/routines/darkpool_demo.openbb diff --git a/routines/dd_demo.openbb b/openbb_terminal/miscellaneous/routines/dd_demo.openbb similarity index 100% rename from routines/dd_demo.openbb rename to openbb_terminal/miscellaneous/routines/dd_demo.openbb diff --git a/routines/discovery_demo.openbb b/openbb_terminal/miscellaneous/routines/discovery_demo.openbb similarity index 100% rename from routines/discovery_demo.openbb rename to openbb_terminal/miscellaneous/routines/discovery_demo.openbb diff --git a/routines/due_diligence_stock.openbb b/openbb_terminal/miscellaneous/routines/due_diligence_stock.openbb similarity index 100% rename from routines/due_diligence_stock.openbb rename to openbb_terminal/miscellaneous/routines/due_diligence_stock.openbb diff --git a/routines/econometrics_demo.openbb b/openbb_terminal/miscellaneous/routines/econometrics_demo.openbb similarity index 100% rename from routines/econometrics_demo.openbb rename to openbb_terminal/miscellaneous/routines/econometrics_demo.openbb diff --git a/routines/example.openbb b/openbb_terminal/miscellaneous/routines/example.openbb similarity index 100% rename from routines/example.openbb rename to openbb_terminal/miscellaneous/routines/example.openbb diff --git a/routines/example_with_inputs.openbb b/openbb_terminal/miscellaneous/routines/example_with_inputs.openbb similarity index 100% rename from routines/example_with_inputs.openbb rename to openbb_terminal/miscellaneous/routines/example_with_inputs.openbb diff --git a/routines/example_with_inputs_saved.openbb b/openbb_terminal/miscellaneous/routines/example_with_inputs_saved.openbb similarity index 100% rename from routines/example_with_inputs_saved.openbb rename to openbb_terminal/miscellaneous/routines/example_with_inputs_saved.openbb diff --git a/routines/fa_demo.openbb b/openbb_terminal/miscellaneous/routines/fa_demo.openbb similarity index 100% rename from routines/fa_demo.openbb rename to openbb_terminal/miscellaneous/routines/fa_demo.openbb diff --git a/routines/gov_demo.openbb b/openbb_terminal/miscellaneous/routines/gov_demo.openbb similarity index 100% rename from routines/gov_demo.openbb rename to openbb_terminal/miscellaneous/routines/gov_demo.openbb diff --git a/routines/insider_demo.openbb b/openbb_terminal/miscellaneous/routines/insider_demo.openbb similarity index 100% rename from routines/insider_demo.openbb rename to openbb_terminal/miscellaneous/routines/insider_demo.openbb diff --git a/routines/options_demo.openbb b/openbb_terminal/miscellaneous/routines/options_demo.openbb similarity index 100% rename from routines/options_demo.openbb rename to openbb_terminal/miscellaneous/routines/options_demo.openbb diff --git a/routines/portfolio_optimization_demo.openbb b/openbb_terminal/miscellaneous/routines/portfolio_optimization_demo.openbb similarity index 100% rename from routines/portfolio_optimization_demo.openbb rename to openbb_terminal/miscellaneous/routines/portfolio_optimization_demo.openbb diff --git a/routines/stock_screener_demo.openbb b/openbb_terminal/miscellaneous/routines/stock_screener_demo.openbb similarity index 100% rename from routines/stock_screener_demo.openbb rename to openbb_terminal/miscellaneous/routines/stock_screener_demo.openbb diff --git a/routines/stocks_demo.openbb b/openbb_terminal/miscellaneous/routines/stocks_demo.openbb similarity index 100% rename from routines/stocks_demo.openbb rename to openbb_terminal/miscellaneous/routines/stocks_demo.openbb diff --git a/routines/ta_demo.openbb b/openbb_terminal/miscellaneous/routines/ta_demo.openbb similarity index 100% rename from routines/ta_demo.openbb rename to openbb_terminal/miscellaneous/routines/ta_demo.openbb diff --git a/routines/template.openbb b/openbb_terminal/miscellaneous/routines/template.openbb similarity index 100% rename from routines/template.openbb rename to openbb_terminal/miscellaneous/routines/template.openbb diff --git a/scripts/.gitkeep b/openbb_terminal/miscellaneous/scripts/.gitkeep similarity index 100% rename from scripts/.gitkeep rename to openbb_terminal/miscellaneous/scripts/.gitkeep diff --git a/scripts/test_alt_covid.openbb b/openbb_terminal/miscellaneous/scripts/test_alt_covid.openbb similarity index 100% rename from scripts/test_alt_covid.openbb rename to openbb_terminal/miscellaneous/scripts/test_alt_covid.openbb diff --git a/scripts/test_alt_oss.openbb b/openbb_terminal/miscellaneous/scripts/test_alt_oss.openbb similarity index 100% rename from scripts/test_alt_oss.openbb rename to openbb_terminal/miscellaneous/scripts/test_alt_oss.openbb diff --git a/scripts/test_crypto_dd.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_dd.openbb similarity index 100% rename from scripts/test_crypto_dd.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_dd.openbb diff --git a/scripts/test_crypto_defi.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_defi.openbb similarity index 100% rename from scripts/test_crypto_defi.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_defi.openbb diff --git a/scripts/test_crypto_disc.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_disc.openbb similarity index 100% rename from scripts/test_crypto_disc.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_disc.openbb diff --git a/scripts/test_crypto_nft.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_nft.openbb similarity index 100% rename from scripts/test_crypto_nft.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_nft.openbb diff --git a/scripts/test_crypto_onchain.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_onchain.openbb similarity index 100% rename from scripts/test_crypto_onchain.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_onchain.openbb diff --git a/scripts/test_crypto_ov.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_ov.openbb similarity index 100% rename from scripts/test_crypto_ov.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_ov.openbb diff --git a/scripts/test_crypto_pred.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_pred.openbb similarity index 100% rename from scripts/test_crypto_pred.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_pred.openbb diff --git a/scripts/test_crypto_ta.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_ta.openbb similarity index 100% rename from scripts/test_crypto_ta.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_ta.openbb diff --git a/scripts/test_crypto_tools.openbb b/openbb_terminal/miscellaneous/scripts/test_crypto_tools.openbb similarity index 100% rename from scripts/test_crypto_tools.openbb rename to openbb_terminal/miscellaneous/scripts/test_crypto_tools.openbb diff --git a/scripts/test_econometrics_panel.openbb b/openbb_terminal/miscellaneous/scripts/test_econometrics_panel.openbb similarity index 100% rename from scripts/test_econometrics_panel.openbb rename to openbb_terminal/miscellaneous/scripts/test_econometrics_panel.openbb diff --git a/scripts/test_econometrics_ts.openbb b/openbb_terminal/miscellaneous/scripts/test_econometrics_ts.openbb similarity index 100% rename from scripts/test_econometrics_ts.openbb rename to openbb_terminal/miscellaneous/scripts/test_econometrics_ts.openbb diff --git a/scripts/test_economy.openbb b/openbb_terminal/miscellaneous/scripts/test_economy.openbb similarity index 100% rename from scripts/test_economy.openbb rename to openbb_terminal/miscellaneous/scripts/test_economy.openbb diff --git a/scripts/test_etf.openbb b/openbb_terminal/miscellaneous/scripts/test_etf.openbb similarity index 100% rename from scripts/test_etf.openbb rename to openbb_terminal/miscellaneous/scripts/test_etf.openbb diff --git a/scripts/test_etf_ca.openbb b/openbb_terminal/miscellaneous/scripts/test_etf_ca.openbb similarity index 100% rename from scripts/test_etf_ca.openbb rename to openbb_terminal/miscellaneous/scripts/test_etf_ca.openbb diff --git a/scripts/test_etf_disc.openbb b/openbb_terminal/miscellaneous/scripts/test_etf_disc.openbb similarity index 100% rename from scripts/test_etf_disc.openbb rename to openbb_terminal/miscellaneous/scripts/test_etf_disc.openbb diff --git a/scripts/test_etf_pred.openbb b/openbb_terminal/miscellaneous/scripts/test_etf_pred.openbb similarity index 100% rename from scripts/test_etf_pred.openbb rename to openbb_terminal/miscellaneous/scripts/test_etf_pred.openbb diff --git a/scripts/test_etf_scr.openbb b/openbb_terminal/miscellaneous/scripts/test_etf_scr.openbb similarity index 100% rename from scripts/test_etf_scr.openbb rename to openbb_terminal/miscellaneous/scripts/test_etf_scr.openbb diff --git a/scripts/test_etf_ta.openbb b/openbb_terminal/miscellaneous/scripts/test_etf_ta.openbb similarity index 100% rename from scripts/test_etf_ta.openbb rename to openbb_terminal/miscellaneous/scripts/test_etf_ta.openbb diff --git a/scripts/test_forecast.openbb b/openbb_terminal/miscellaneous/scripts/test_forecast.openbb similarity index 100% rename from scripts/test_forecast.openbb rename to openbb_terminal/miscellaneous/scripts/test_forecast.openbb diff --git a/scripts/test_forecast_advanced.openbb b/openbb_terminal/miscellaneous/scripts/test_forecast_advanced.openbb similarity index 100% rename from scripts/test_forecast_advanced.openbb rename to openbb_terminal/miscellaneous/scripts/test_forecast_advanced.openbb diff --git a/scripts/test_forex_av.openbb b/openbb_terminal/miscellaneous/scripts/test_forex_av.openbb similarity index 100% rename from scripts/test_forex_av.openbb rename to openbb_terminal/miscellaneous/scripts/test_forex_av.openbb diff --git a/scripts/test_forex_base.openbb b/openbb_terminal/miscellaneous/scripts/test_forex_base.openbb similarity index 100% rename from scripts/test_forex_base.openbb rename to openbb_terminal/miscellaneous/scripts/test_forex_base.openbb diff --git a/scripts/test_forex_load.openbb b/openbb_terminal/miscellaneous/scripts/test_forex_load.openbb similarity index 100% rename from scripts/test_forex_load.openbb rename to openbb_terminal/miscellaneous/scripts/test_forex_load.openbb diff --git a/scripts/test_forex_oanda.openbb b/openbb_terminal/miscellaneous/scripts/test_forex_oanda.openbb similarity index 100% rename from scripts/test_forex_oanda.openbb rename to openbb_terminal/miscellaneous/scripts/test_forex_oanda.openbb diff --git a/scripts/test_forex_oanda_base.openbb b/openbb_terminal/miscellaneous/scripts/test_forex_oanda_base.openbb similarity index 100% rename from scripts/test_forex_oanda_base.openbb rename to openbb_terminal/miscellaneous/scripts/test_forex_oanda_base.openbb diff --git a/scripts/test_forex_pred.openbb b/openbb_terminal/miscellaneous/scripts/test_forex_pred.openbb similarity index 100% rename from scripts/test_forex_pred.openbb rename to openbb_terminal/miscellaneous/scripts/test_forex_pred.openbb diff --git a/scripts/test_forex_qa.openbb b/openbb_terminal/miscellaneous/scripts/test_forex_qa.openbb similarity index 100% rename from scripts/test_forex_qa.openbb rename to openbb_terminal/miscellaneous/scripts/test_forex_qa.openbb diff --git a/scripts/test_forex_ta.openbb b/openbb_terminal/miscellaneous/scripts/test_forex_ta.openbb similarity index 100% rename from scripts/test_forex_ta.openbb rename to openbb_terminal/miscellaneous/scripts/test_forex_ta.openbb diff --git a/scripts/test_funds.openbb b/openbb_terminal/miscellaneous/scripts/test_funds.openbb similarity index 100% rename from scripts/test_funds.openbb rename to openbb_terminal/miscellaneous/scripts/test_funds.openbb diff --git a/scripts/test_jupyter_base.openbb b/openbb_terminal/miscellaneous/scripts/test_jupyter_base.openbb similarity index 100% rename from scripts/test_jupyter_base.openbb rename to openbb_terminal/miscellaneous/scripts/test_jupyter_base.openbb diff --git a/scripts/test_keys_.openbb b/openbb_terminal/miscellaneous/scripts/test_keys_.openbb similarity index 100% rename from scripts/test_keys_.openbb rename to openbb_terminal/miscellaneous/scripts/test_keys_.openbb diff --git a/scripts/test_news.openbb b/openbb_terminal/miscellaneous/scripts/test_news.openbb similarity index 100% rename from scripts/test_news.openbb rename to openbb_terminal/miscellaneous/scripts/test_news.openbb diff --git a/scripts/test_portfolio.openbb b/openbb_terminal/miscellaneous/scripts/test_portfolio.openbb similarity index 100% rename from scripts/test_portfolio.openbb rename to openbb_terminal/miscellaneous/scripts/test_portfolio.openbb diff --git a/scripts/test_portfolio_boolean_args.openbb b/openbb_terminal/miscellaneous/scripts/test_portfolio_boolean_args.openbb similarity index 100% rename from scripts/test_portfolio_boolean_args.openbb rename to openbb_terminal/miscellaneous/scripts/test_portfolio_boolean_args.openbb diff --git a/scripts/test_reports_base.openbb b/openbb_terminal/miscellaneous/scripts/test_reports_base.openbb similarity index 100% rename from scripts/test_reports_base.openbb rename to openbb_terminal/miscellaneous/scripts/test_reports_base.openbb diff --git a/scripts/test_reports_crypto.openbb b/openbb_terminal/miscellaneous/scripts/test_reports_crypto.openbb similarity index 100% rename from scripts/test_reports_crypto.openbb rename to openbb_terminal/miscellaneous/scripts/test_reports_crypto.openbb diff --git a/scripts/test_reports_economy.openbb b/openbb_terminal/miscellaneous/scripts/test_reports_economy.openbb similarity index 100% rename from scripts/test_reports_economy.openbb rename to openbb_terminal/miscellaneous/scripts/test_reports_economy.openbb diff --git a/scripts/test_reports_equity.openbb b/openbb_terminal/miscellaneous/scripts/test_reports_equity.openbb similarity index 100% rename from scripts/test_reports_equity.openbb rename to openbb_terminal/miscellaneous/scripts/test_reports_equity.openbb diff --git a/scripts/test_reports_etf.openbb b/openbb_terminal/miscellaneous/scripts/test_reports_etf.openbb similarity index 100% rename from scripts/test_reports_etf.openbb rename to openbb_terminal/miscellaneous/scripts/test_reports_etf.openbb diff --git a/scripts/test_reports_forex.openbb b/openbb_terminal/miscellaneous/scripts/test_reports_forex.openbb similarity index 100% rename from scripts/test_reports_forex.openbb rename to openbb_terminal/miscellaneous/scripts/test_reports_forex.openbb diff --git a/scripts/test_reports_portfolio.openbb b/openbb_terminal/miscellaneous/scripts/test_reports_portfolio.openbb similarity index 100% rename from scripts/test_reports_portfolio.openbb rename to openbb_terminal/miscellaneous/scripts/test_reports_portfolio.openbb diff --git a/scripts/test_shroom.openbb b/openbb_terminal/miscellaneous/scripts/test_shroom.openbb similarity index 100% rename from scripts/test_shroom.openbb rename to openbb_terminal/miscellaneous/scripts/test_shroom.openbb diff --git a/openbb_terminal/miscellaneous/scripts/test_stocks.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks.openbb new file mode 100644 index 00000000000..66f1a7d247d --- /dev/null +++ b/openbb_terminal/miscellaneous/scripts/test_stocks.openbb @@ -0,0 +1,9 @@ +stocks +search apple +load aapl -s 2022-10-01 +tob +tob -e EDGX +candle +codes +news +exit diff --git a/scripts/test_stocks_ba.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_ba.openbb similarity index 100% rename from scripts/test_stocks_ba.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_ba.openbb diff --git a/scripts/test_stocks_bt.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_bt.openbb similarity index 100% rename from scripts/test_stocks_bt.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_bt.openbb diff --git a/scripts/test_stocks_ca.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_ca.openbb similarity index 100% rename from scripts/test_stocks_ca.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_ca.openbb diff --git a/scripts/test_stocks_dd.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_dd.openbb similarity index 100% rename from scripts/test_stocks_dd.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_dd.openbb diff --git a/scripts/test_stocks_disc.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_disc.openbb similarity index 100% rename from scripts/test_stocks_disc.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_disc.openbb diff --git a/scripts/test_stocks_dps.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_dps.openbb similarity index 100% rename from scripts/test_stocks_dps.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_dps.openbb diff --git a/scripts/test_stocks_fa.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_fa.openbb similarity index 100% rename from scripts/test_stocks_fa.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_fa.openbb diff --git a/scripts/test_stocks_fa_base.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_fa_base.openbb similarity index 100% rename from scripts/test_stocks_fa_base.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_fa_base.openbb diff --git a/scripts/test_stocks_gov.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_gov.openbb similarity index 100% rename from scripts/test_stocks_gov.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_gov.openbb diff --git a/scripts/test_stocks_ins.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_ins.openbb similarity index 100% rename from scripts/test_stocks_ins.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_ins.openbb diff --git a/scripts/test_stocks_options.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_options.openbb similarity index 100% rename from scripts/test_stocks_options.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_options.openbb diff --git a/scripts/test_stocks_options_payoff.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_options_payoff.openbb similarity index 100% rename from scripts/test_stocks_options_payoff.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_options_payoff.openbb diff --git a/scripts/test_stocks_options_pricing.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_options_pricing.openbb similarity index 100% rename from scripts/test_stocks_options_pricing.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_options_pricing.openbb diff --git a/scripts/test_stocks_options_screen.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_options_screen.openbb similarity index 100% rename from scripts/test_stocks_options_screen.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_options_screen.openbb diff --git a/scripts/test_stocks_qa.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_qa.openbb similarity index 100% rename from scripts/test_stocks_qa.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_qa.openbb diff --git a/scripts/test_stocks_scr.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_scr.openbb similarity index 100% rename from scripts/test_stocks_scr.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_scr.openbb diff --git a/scripts/test_stocks_sia.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_sia.openbb similarity index 100% rename from scripts/test_stocks_sia.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_sia.openbb diff --git a/scripts/test_stocks_ta.openbb b/openbb_terminal/miscellaneous/scripts/test_stocks_ta.openbb similarity index 100% rename from scripts/test_stocks_ta.openbb rename to openbb_terminal/miscellaneous/scripts/test_stocks_ta.openbb diff --git a/openbb_terminal/terminal_controller.py b/openbb_terminal/terminal_controller.py index eb46d7f5093..264d998195c 100644 --- a/openbb_terminal/terminal_controller.py +++ b/openbb_terminal/terminal_controller.py @@ -6,6 +6,7 @@ import argparse import difflib import logging import os +from pathlib import Path import platform import sys import webbrowser @@ -21,10 +22,11 @@ import pandas as pd from openbb_terminal import feature_flags as obbff from openbb_terminal.core.config.paths import ( - REPOSITORY_DIRECTORY, - USER_ENV_FILE, - REPOSITORY_ENV_FILE, HOME_DIRECTORY, + MISCELLANEOUS_DIRECTORY, + REPOSITORY_ENV_FILE, + USER_DATA_DIRECTORY, + USER_ENV_FILE, USER_ROUTINES_DIRECTORY, ) from openbb_terminal.core.log.generation.path_tracking_file_handler import ( @@ -116,7 +118,7 @@ class TerminalController(BaseController): """Update runtime choices""" self.ROUTINE_FILES = { filepath.name: filepath - for filepath in (REPOSITORY_DIRECTORY / "routines").rglob("*.openbb") + for filepath in (MISCELLANEOUS_DIRECTORY / "routines").rglob("*.openbb") } self.ROUTINE_FILES.update( { @@ -594,13 +596,14 @@ class TerminalController(BaseController): # pylint: disable=global-statement -def terminal(jobs_cmds: List[str] = None, appName: str = "gst"): +def terminal(jobs_cmds: List[str] = None, appName: str = "gst", test_mode=False): """Terminal Menu""" # TODO: HELP WANTED! Refactor the appName setting if a more elegant solution comes up if obbff.PACKAGED_APPLICATION: appName = "gst_packaged" - setup_logging(appName) + if not test_mode: + setup_logging(appName) logger.info("START") log_settings() @@ -793,7 +796,7 @@ def log_settings() -> None: def run_scripts( - path: str, + path: Path, test_mode: bool = False, verbose: bool = False, routines_args: List[str] = None, @@ -812,8 +815,9 @@ def run_scripts( One or multiple inputs to be replaced in the routine and separated by commas. E.g. GME,AMC,BTC-USD """ - if os.path.isfile(path): - with open(path) as fp: + + if path.exists(): + with path.open() as fp: raw_lines = [x for x in fp if (not is_reset(x)) and ("#" not in x) and x] raw_lines = [ raw_line.strip("\n") for raw_line in raw_lines if raw_line.strip("\n") @@ -850,22 +854,95 @@ def run_scripts( # TODO: Add way to track how many commands are tested else: if verbose: - terminal(file_cmds, appName="openbb_script") + terminal(file_cmds, appName="openbb_script", test_mode=True) else: with suppress_stdout(): - terminal(file_cmds, appName="openbb_script") - + terminal(file_cmds, appName="openbb_script", test_mode=True) else: console.print(f"File '{path}' doesn't exist. Launching base terminal.\n") if not test_mode: terminal() +def build_test_path_list(path_list: List[str], filtert: str) -> List[Path]: + if path_list == "": + console.print("Please send a path when using test mode") + return [] + + test_files = [] + + for path in path_list: + user_script_path = USER_DATA_DIRECTORY / "scripts" / path + default_script_path = MISCELLANEOUS_DIRECTORY / path + + if user_script_path.exists(): + chosen_path = user_script_path + elif default_script_path.exists(): + chosen_path = default_script_path + else: + console.print(f"\n[red]Can't find the file:{path}[/red]\n") + continue + + if chosen_path.is_file() and str(chosen_path).endswith(".openbb"): + test_files.append(chosen_path) + elif chosen_path.is_dir(): + script_directory = chosen_path + script_list = script_directory.glob("**/*.openbb") + script_list = [script for script in script_list if script.is_file()] + script_list = [script for script in script_list if filtert in str(script)] + test_files.extend(script_list) + + return test_files + + +def run_test_list(path_list: List[str], filtert: str, verbose: bool): + os.environ["DEBUG_MODE"] = "true" + + test_files = build_test_path_list(path_list=path_list, filtert=filtert) + SUCCESSES = 0 + FAILURES = 0 + fails = {} + length = len(test_files) + i = 0 + console.print("[green]OpenBB Terminal Integrated Tests:\n[/green]") + for file in test_files: + console.print(f"{((i/length)*100):.1f}% {file}") + try: + run_scripts(file, test_mode=True, verbose=verbose) + SUCCESSES += 1 + except Exception as e: + fails[file] = e + FAILURES += 1 + i += 1 + if fails: + console.print("\n[red]Failures:[/red]\n") + for file, exception in fails.items(): + logger.error("%s: %s failed", file, exception) + console.print(f"{file}: {exception}\n") + console.print( + f"Summary: [green]Successes: {SUCCESSES}[/green] [red]Failures: {FAILURES}[/red]" + ) + + +def run_routine(file: str, routines_args=List[str]): + user_routine_path = USER_DATA_DIRECTORY / "routines" / file + default_routine_path = MISCELLANEOUS_DIRECTORY / "routines" / file + + if user_routine_path.exists(): + run_scripts(path=user_routine_path, routines_args=routines_args) + elif default_routine_path.exists(): + run_scripts(path=default_routine_path, routines_args=routines_args) + else: + print( + f"Routine not found, please put your `.openbb` file into : {user_routine_path}." + ) + + def main( debug: bool, test: bool, filtert: str, - paths: List[str], + path_list: List[str], verbose: bool, routines_args: List[str] = None, ): @@ -890,71 +967,15 @@ def main( """ if test: - os.environ["DEBUG_MODE"] = "true" - - if paths == "": - console.print("Please send a path when using test mode") - return - test_files = [] - for path in paths: - if path.endswith(".openbb"): - file = str(REPOSITORY_DIRECTORY / path) - test_files.append(file) - else: - folder = str(REPOSITORY_DIRECTORY / path) - files = [ - f"{folder}/{name}" - for name in os.listdir(folder) - if os.path.isfile(os.path.join(folder, name)) - and name.endswith(".openbb") - and (filtert in f"{folder}/{name}") - ] - test_files += files - test_files.sort() - SUCCESSES = 0 - FAILURES = 0 - fails = {} - length = len(test_files) - i = 0 - console.print("[green]OpenBB Terminal Integrated Tests:\n[/green]") - for file in test_files: - file = file.replace("//", "/") - repo_path_position = file.rfind(REPOSITORY_DIRECTORY.name) - if repo_path_position >= 0: - file_name = file[repo_path_position:].replace("\\", "/") - else: - file_name = file - console.print(f"{file_name} {((i/length)*100):.1f}%") - try: - if not os.path.isfile(file): - raise ValueError("Given file does not exist") - run_scripts(file, test_mode=True, verbose=verbose) - SUCCESSES += 1 - except Exception as e: - fails[file] = e - FAILURES += 1 - i += 1 - if fails: - console.print("\n[red]Failures:[/red]\n") - for key, value in fails.items(): - repo_path_position = key.rfind(REPOSITORY_DIRECTORY.name) - if repo_path_position >= 0: - file_name = key[repo_path_position:].replace("\\", "/") - else: - file_name = key - logger.error("%s: %s failed", file_name, value) - console.print(f"{file_name}: {value}\n") - console.print( - f"Summary: [green]Successes: {SUCCESSES}[/green] [red]Failures: {FAILURES}[/red]" - ) + run_test_list(path_list=path_list, filtert=filtert, verbose=verbose) return if debug: os.environ["DEBUG_MODE"] = "true" - if isinstance(paths, list) and paths[0].endswith(".openbb"): - run_scripts(paths[0], routines_args=routines_args) - elif paths: - argv_cmds = list([" ".join(paths).replace(" /", "/home/")]) + if isinstance(path_list, list) and path_list[0].endswith(".openbb"): + run_routine(file=path_list[0], routines_args=routines_args) + elif path_list: + argv_cmds = list([" ".join(path_list).replace(" /", "/home/")]) argv_cmds = insert_start_slash(argv_cmds) if argv_cmds else argv_cmds terminal(argv_cmds) else: