diff --git a/README.md b/README.md index ba7c812..f2c1585 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ bshm
- + @@ -26,7 +26,7 @@ YAML файлы хранятся в папке (библиотеке). Для к # Установка ``` -pip install bashmator +pip install --upgrade bashmator ``` В комадной строке станет доступен под короткими названиям `bashmator` и `bshm`. diff --git a/bshm/__init__.py b/bshm/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bshm/bashmator.py b/bshm/bashmator.py index 1a296c3..1f41f05 100755 --- a/bshm/bashmator.py +++ b/bshm/bashmator.py @@ -14,7 +14,7 @@ from bshm.bones.config import Configuration def main(): - __version__ = "1.1.7" + __version__ = "1.1.8" __programm_location__ = os.path.dirname(os.path.realpath(__file__)) __default_lib_path__ = os.path.join(__programm_location__,'library') __config_location__ = user_config_dir('bashmator') diff --git a/bshm/bones/__init__.py b/bshm/bones/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bshm/bones/funcs.py b/bshm/bones/funcs.py index 4dc49c0..29912f2 100644 --- a/bshm/bones/funcs.py +++ b/bshm/bones/funcs.py @@ -1,4 +1,4 @@ -import datetime +from datetime import datetime from bshm.bones.msg import style_line, style_line2 @@ -13,11 +13,7 @@ def make_lines(text): return (s1+s2+s3) def get_local_time(): - now = datetime.datetime.now(datetime.timezone.utc) - form_now = now.strftime("%Y-%m-%d %H:%M:%S") - local_tz = datetime.timezone.utc - out=f'{form_now} ({local_tz})' - return(out) + return(datetime.now().astimezone()) def get_code_print_header(shell: str, item: int): s1 = style_line2 diff --git a/bshm/bones/yamlscript.py b/bshm/bones/yamlscript.py index db4affe..9ff73ea 100644 --- a/bshm/bones/yamlscript.py +++ b/bshm/bones/yamlscript.py @@ -13,7 +13,7 @@ from bshm.bones.funcs import get_main_header, get_local_time, get_code_log, get_alt_code_cog, get_log_header, get_log_end, get_code_print_header from bshm.bones.validate import YamlValidator, re_compile -breaker_time = 1 +breaker_time = 2 class YamlScript: def __shell_collector__(self, item: int, shell: str): @@ -155,7 +155,7 @@ def __init__(self, path: str, self.has_main_script = False self.has_files = False self.only_fags_mode = False - self.interrupt_time = time() + self.interrupt_time = time() - 2*breaker_time self.interrupt_count = 0 # Параметры аргументов self.items_launch_set = [0] @@ -500,6 +500,18 @@ def __build_log_header__(self, script: str, shell: str, item: int, new_log): headerstr += get_log_header() return headerstr + def __keyboard_interrupt_stoper__(self): + out = False + if time() - self.interrupt_time < breaker_time: + self.interrupt_count += 1 + else: + self.interrupt_count = 0 + self.interrupt_time = time() + self.msg.warning('Interrupted by user', 'Script execution was interrupted. Press 3 times to abort completely.') + if self.interrupt_count > 2: + out = True + return(out) + def execute(self, show_log: bool, popen_cmd: list, item: int, new_log=True, last_log=True): if show_log: headerstr = self.__build_log_header__(script=popen_cmd[-1], shell=' '.join(popen_cmd[:-1]), item=item, new_log=new_log) @@ -511,12 +523,7 @@ def execute(self, show_log: bool, popen_cmd: list, item: int, new_log=True, las self.msg.warning_file(' '.join(popen_cmd[:-1])) sys.exit(1) except KeyboardInterrupt: - if time() - self.interrupt_time < breaker_time: - self.interrupt_count += 1 - else: - self.interrupt_count = 0 - self.interrupt_time = time() - if self.interrupt_count > 2: + if self.__keyboard_interrupt_stoper__(): raise finally: if show_log: @@ -547,12 +554,7 @@ def execute_and_log(self, logging: str, show_log: bool, popen_cmd: list, shell_e self.msg.warning_file(' '.join(popen_cmd[:-1])) sys.exit(1) except KeyboardInterrupt: - if time() - self.interrupt_time < breaker_time: - self.interrupt_count += 1 - else: - self.interrupt_count = 0 - self.interrupt_time = time() - if self.interrupt_count > 2: + if self.__keyboard_interrupt_stoper__(): raise finally: # Запись и отображение последнего заголовка логера diff --git a/pyproject.toml b/pyproject.toml index fdb97fc..46f588a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bashmator" -version = "1.1.7" +version = "1.1.8" description = "Console script manager based on YAML format" authors = ["vinzekatze "] license = "MIT"