From 9da95ee850e63f0a7bc08557f0a52db9bd56c3f0 Mon Sep 17 00:00:00 2001 From: paprykdev <58005447+paprykdev@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:42:22 +0100 Subject: [PATCH] fix: add clearScreen function and handle exceptions in systemCommand --- scripts/threads/commands.py | 16 ++++++++++++---- scripts/threads/prompt.py | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/threads/commands.py b/scripts/threads/commands.py index 1e19e54..e687e36 100644 --- a/scripts/threads/commands.py +++ b/scripts/threads/commands.py @@ -19,15 +19,23 @@ def clearCondition(command: str) -> bool: return command in ["c", "clear", "cls"] +def clearScreen(): + print(run_command("clear")) + return None + + def systemCommand(command: str) -> str: words = command[1:].split() if words[0] == "": return "Command not found. Write 'h' for help." - print( - run_command( - f'docker exec -it webscraper {" ".join(words)}', + try: + print( + run_command( + f'docker exec -it webscraper {" ".join(words)}', + ) ) - ) + except Exception as e: + print(f"An error occurred: {e}") return None diff --git a/scripts/threads/prompt.py b/scripts/threads/prompt.py index 75a1416..c788b94 100644 --- a/scripts/threads/prompt.py +++ b/scripts/threads/prompt.py @@ -15,7 +15,7 @@ def prompt(): print(help_list()) continue if clearCondition(command): - run_command("clear") + clearScreen() continue if command.startswith("$"): systemCommand(command)