fix: add clearScreen function and handle exceptions in systemCommand

This commit is contained in:
patilk 2024-11-16 00:42:22 +01:00
parent a8136a7ff4
commit 9da95ee850
Signed by: s500042
GPG Key ID: 1921AD722E7392EE
2 changed files with 13 additions and 5 deletions

View File

@ -19,15 +19,23 @@ def clearCondition(command: str) -> bool:
return command in ["c", "clear", "cls"] return command in ["c", "clear", "cls"]
def clearScreen():
print(run_command("clear"))
return None
def systemCommand(command: str) -> str: def systemCommand(command: str) -> str:
words = command[1:].split() words = command[1:].split()
if words[0] == "": if words[0] == "":
return "Command not found. Write 'h' for help." return "Command not found. Write 'h' for help."
try:
print( print(
run_command( run_command(
f'docker exec -it webscraper {" ".join(words)}', f'docker exec -it webscraper {" ".join(words)}',
) )
) )
except Exception as e:
print(f"An error occurred: {e}")
return None return None

View File

@ -15,7 +15,7 @@ def prompt():
print(help_list()) print(help_list())
continue continue
if clearCondition(command): if clearCondition(command):
run_command("clear") clearScreen()
continue continue
if command.startswith("$"): if command.startswith("$"):
systemCommand(command) systemCommand(command)