Fix the prompt behavior if terminal is not tty

This commit is contained in:
Artem Veremey
2021-03-10 13:59:45 -08:00
parent dc2adf7301
commit 9af480dc62
2 changed files with 12 additions and 5 deletions

View File

@@ -73,10 +73,13 @@ def disc_menu():
# Loop forever and ever
while True:
# Get input command from user
as_input = session.prompt(
f"{get_flair()} (disc)> ",
completer=word_completer,
)
if session:
as_input = session.prompt(
f"{get_flair()} (disc)> ",
completer=word_completer,
)
else:
as_input = input(f"{get_flair()} (disc)> ")
# Parse fundamental analysis command of the list of possible commands
try:

View File

@@ -4,4 +4,8 @@ from prompt_toolkit import PromptSession
from prompt_toolkit.history import FileHistory
history_file = os.path.join(os.path.expanduser("~"), ".gamestonk_terminal.his")
session = PromptSession(history=FileHistory(history_file))
try:
session = PromptSession(history=FileHistory(history_file))
except Exception as e:
session = None