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): def stop(self):
self.run = False self.run = False
self.log.info(i18n.stop) self.log.info(i18n.stop)
asyncio.run(self.web_stop()) if config.WebAPI["enabled"]:
asyncio.run(self.web_stop())
exit(0) 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.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.completion import NestedCompleter from prompt_toolkit.completion import NestedCompleter
from prompt_toolkit.history import FileHistory from prompt_toolkit.history import FileHistory
from prompt_toolkit.patch_stdout import patch_stdout
from core import get_logger from core import get_logger
@ -186,8 +187,12 @@ class Console:
session = PromptSession(history=FileHistory('./.cmdhistory')) session = PromptSession(history=FileHistory('./.cmdhistory'))
while True: while True:
try: try:
cmd_in = await session.prompt_async(self.__prompt_in, with patch_stdout():
completer=self.completer, auto_suggest=AutoSuggestFromHistory()) cmd_in = await session.prompt_async(
self.__prompt_in,
completer=self.completer,
auto_suggest=AutoSuggestFromHistory()
)
cmd_s = cmd_in.split(" ") cmd_s = cmd_in.split(" ")
cmd = cmd_s[0] cmd = cmd_s[0]
if cmd == "": if cmd == "":
@ -210,13 +215,3 @@ class Console:
def stop(self, *args, **kwargs): def stop(self, *args, **kwargs):
self.__is_run = False self.__is_run = False
raise KeyboardInterrupt 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())