diff --git a/.github/workflows/Mac.yml b/.github/workflows/Mac.yml index 0636f0aea05..996a29b56f8 100644 --- a/.github/workflows/Mac.yml +++ b/.github/workflows/Mac.yml @@ -1,4 +1,7 @@ name: Mac OS X Full Clean Build with ML +env: + GTFF_USE_PROMPT_TOOLKIT: false + GTFF_USE_ION: false on: push: branches: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 382a74b02e7..59b23e270f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,7 @@ name: Tests +env: + GTFF_USE_PROMPT_TOOLKIT: false + GTFF_USE_ION: false on: [pull_request, push] jobs: linting: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 940138e40df..3e469e6fddf 100755 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,4 +1,7 @@ name: Windows 10 Full Clean Build with ML +env: + GTFF_USE_PROMPT_TOOLKIT: false + GTFF_USE_ION: false on: push: branches: diff --git a/gamestonk_terminal/feature_flags.py b/gamestonk_terminal/feature_flags.py index cb7481d9127..f8360c1872b 100644 --- a/gamestonk_terminal/feature_flags.py +++ b/gamestonk_terminal/feature_flags.py @@ -1,12 +1,13 @@ +from distutils.util import strtobool import os -USE_COLOR = os.getenv("GTFF_USE_COLOR") or True +USE_COLOR = strtobool(os.getenv("GTFF_USE_COLOR", "True")) USE_FLAIR = os.getenv("GTFF_USE_FLAIR") or "stars" -USE_ION = os.getenv("GTFF_USE_ION") or True -USE_PROMPT_TOOLKIT = os.getenv("GTFF_USE_PROMPT_TOOLKIT") or False +USE_ION = strtobool(os.getenv("GTFF_USE_ION", "True")) +USE_PROMPT_TOOLKIT = strtobool(os.getenv("GTFF_USE_PROMPT_TOOLKIT", "False")) # Enable Prediction features -ENABLE_PREDICT = os.getenv("GTFF_ENABLE_PREDICT") or False +ENABLE_PREDICT = strtobool(os.getenv("GTFF_ENABLE_PREDICT", "False")) # Enable plot autoscaling -USE_PLOT_AUTOSCALING = os.getenv("GTFF_USE_PLOT_AUTOSCALING") or False +USE_PLOT_AUTOSCALING = strtobool(os.getenv("GTFF_USE_PLOT_AUTOSCALING", "False")) diff --git a/gamestonk_terminal/menu.py b/gamestonk_terminal/menu.py index 8fb14e0e4a3..00e818a0f0d 100644 --- a/gamestonk_terminal/menu.py +++ b/gamestonk_terminal/menu.py @@ -1,11 +1,25 @@ import os +from matplotlib import pyplot + from prompt_toolkit import PromptSession +from prompt_toolkit.eventloop.inputhook import set_eventloop_with_inputhook from prompt_toolkit.history import FileHistory + +def inputhook(inputhook_context): + while not inputhook_context.input_is_ready(): + pyplot.pause(0.1) + return False + + history_file = os.path.join(os.path.expanduser("~"), ".gamestonk_terminal.his") try: session = PromptSession(history=FileHistory(history_file)) + set_eventloop_with_inputhook(inputhook) except Exception as e: # noqa: F841 + print( + "WARNING: Prompt toolkit is turned on but did not initialize successfully. Falling back to input()..." + ) session = None