From 4016649c320b9d0346630932bf74ed253178241f Mon Sep 17 00:00:00 2001 From: didier Date: Sat, 8 May 2021 01:08:24 +0100 Subject: [PATCH 1/3] add reset command to terminal --- gamestonk_terminal/main_helper.py | 1 + terminal.py | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gamestonk_terminal/main_helper.py b/gamestonk_terminal/main_helper.py index 0261e231870..7848dc191f4 100644 --- a/gamestonk_terminal/main_helper.py +++ b/gamestonk_terminal/main_helper.py @@ -28,6 +28,7 @@ def print_help(s_ticker, s_start, s_interval, b_is_market_open): """Print help""" print("What do you want to do?") print(" help help to see this menu again") + print(" reset reset terminal and reload configs") print(" quit to abandon the program") print("") print(" clear clear a specific stock ticker from analysis") diff --git a/terminal.py b/terminal.py index 03189c3b1fc..d22a4303d73 100644 --- a/terminal.py +++ b/terminal.py @@ -4,6 +4,7 @@ import argparse import sys import os +import subprocess from datetime import datetime, timedelta import pandas as pd import yfinance as yf @@ -75,6 +76,7 @@ def main(): "help", "quit", "q", + "reset", "clear", "load", "candle", @@ -164,7 +166,11 @@ def main(): if ns_known_args.opt == "help": should_print_help = True - elif (ns_known_args.opt == "quit") or (ns_known_args.opt == "q"): + elif ( + (ns_known_args.opt == "quit") + or (ns_known_args.opt == "q") + or (ns_known_args.opt == "reset") + ): break elif ns_known_args.opt == "clear": @@ -393,7 +399,17 @@ def main(): if not main_cmd: should_print_help = True - print_goodbye() + if ns_known_args.opt == "reset": + print("resetting...") + + completed_process = subprocess.run("python terminal.py", shell=True) + if completed_process.returncode != 0: + completed_process = subprocess.run("python3 terminal.py", shell=True) + if completed_process.returncode != 0: + print("Unfortunately, resetting wasn't possible!\n") + print_goodbye() + else: + print_goodbye() if __name__ == "__main__": From 611e32e9873c1b7a65a3472649f8ce59c1d564cd Mon Sep 17 00:00:00 2001 From: didier Date: Sat, 8 May 2021 01:12:14 +0100 Subject: [PATCH 2/3] add check arg to subprocess.run --- terminal.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/terminal.py b/terminal.py index d22a4303d73..e225de3c3db 100644 --- a/terminal.py +++ b/terminal.py @@ -402,9 +402,13 @@ def main(): if ns_known_args.opt == "reset": print("resetting...") - completed_process = subprocess.run("python terminal.py", shell=True) + completed_process = subprocess.run( + "python terminal.py", shell=True, check=False + ) if completed_process.returncode != 0: - completed_process = subprocess.run("python3 terminal.py", shell=True) + completed_process = subprocess.run( + "python3 terminal.py", shell=True, check=False + ) if completed_process.returncode != 0: print("Unfortunately, resetting wasn't possible!\n") print_goodbye() From 7a9d8745658e3cf691c43e91815ec8ebef7d64d0 Mon Sep 17 00:00:00 2001 From: didier Date: Sat, 8 May 2021 01:33:44 +0100 Subject: [PATCH 3/3] fix quick exit test --- terminal.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/terminal.py b/terminal.py index e225de3c3db..593cc5b0823 100644 --- a/terminal.py +++ b/terminal.py @@ -399,21 +399,22 @@ def main(): if not main_cmd: should_print_help = True - if ns_known_args.opt == "reset": - print("resetting...") + if not gtff.ENABLE_QUICK_EXIT: + if ns_known_args.opt == "reset": + print("resetting...") - completed_process = subprocess.run( - "python terminal.py", shell=True, check=False - ) - if completed_process.returncode != 0: completed_process = subprocess.run( - "python3 terminal.py", shell=True, check=False + "python terminal.py", shell=True, check=False ) if completed_process.returncode != 0: - print("Unfortunately, resetting wasn't possible!\n") - print_goodbye() - else: - print_goodbye() + completed_process = subprocess.run( + "python3 terminal.py", shell=True, check=False + ) + if completed_process.returncode != 0: + print("Unfortunately, resetting wasn't possible!\n") + print_goodbye() + else: + print_goodbye() if __name__ == "__main__":