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"]
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."
try:
print(
run_command(
f'docker exec -it webscraper {" ".join(words)}',
)
)
except Exception as e:
print(f"An error occurred: {e}")
return None

View File

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