Minor fixes

This commit is contained in:
Maxim Khomutov 2023-07-13 01:17:01 +03:00
parent a15eb316bb
commit 85c379bd9e
2 changed files with 9 additions and 13 deletions

View File

@ -337,5 +337,6 @@ class Core:
def stop(self):
self.run = False
self.log.info(i18n.stop)
if config.WebAPI["enabled"]:
asyncio.run(self.web_stop())
exit(0)

View File

@ -14,6 +14,7 @@ from prompt_toolkit import PromptSession, print_formatted_text, HTML
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.completion import NestedCompleter
from prompt_toolkit.history import FileHistory
from prompt_toolkit.patch_stdout import patch_stdout
from core import get_logger
@ -186,8 +187,12 @@ class Console:
session = PromptSession(history=FileHistory('./.cmdhistory'))
while True:
try:
cmd_in = await session.prompt_async(self.__prompt_in,
completer=self.completer, auto_suggest=AutoSuggestFromHistory())
with patch_stdout():
cmd_in = await session.prompt_async(
self.__prompt_in,
completer=self.completer,
auto_suggest=AutoSuggestFromHistory()
)
cmd_s = cmd_in.split(" ")
cmd = cmd_s[0]
if cmd == "":
@ -210,13 +215,3 @@ class Console:
def stop(self, *args, **kwargs):
self.__is_run = False
raise KeyboardInterrupt
# if __name__ == '__main__':
# c = Console()
# c.logger_hook()
# c.builtins_hook()
# log = logging.getLogger(name="name")
# log.info("Starting console")
# print("Starting console")
# asyncio.run(c.start())