diff --git a/flatc_deserializer.py b/flatc_deserializer.py index 1721ea3..25fc839 100644 --- a/flatc_deserializer.py +++ b/flatc_deserializer.py @@ -10,6 +10,7 @@ from main import prepare_app, get_flatc_path, execute_deserialize if __name__ == "__main__": + sys.tracebacklimit = 0 prepare_app("images/flatbuffers-logo-clean.png") parser = argparse.ArgumentParser(prog=t("main.flatc_deserializer_name"), description=t("main.flatc_deserializer_desc")) @@ -21,5 +22,5 @@ parser.add_argument("-f", "--flatc_path", type=str, default="", help=t("main.flatc_path_arg")) args = parser.parse_args() sys.exit(execute_deserialize( - get_flatc_path(os.getcwd(), True) if args.flatc_path == "" else args.flatc_path, + get_flatc_path(os.getcwd(), True, False) if args.flatc_path == "" else args.flatc_path, args.schema_path, args.binary_paths, args.output_path)) diff --git a/flatc_deserializer_batch.py b/flatc_deserializer_batch.py index 9858586..12cc937 100644 --- a/flatc_deserializer_batch.py +++ b/flatc_deserializer_batch.py @@ -11,6 +11,7 @@ from main import prepare_app, get_flatc_path, execute_deserialize_batch if __name__ == "__main__": + sys.tracebacklimit = 0 prepare_app("images/flatbuffers-batch-logo-clean.png") parser = argparse.ArgumentParser(prog=t("main.flatc_deserializer_name"), description=t("main.flatc_derializer_desc")) @@ -23,5 +24,5 @@ parser.add_argument("-f", "--flatc_path", type=str, default="", help=t("main.flatc_path_arg")) args = parser.parse_args() sys.exit(execute_deserialize_batch( - get_flatc_path(os.getcwd(), True) if args.flatc_path == "" else args.flatc_path, + get_flatc_path(os.getcwd(), True, False) if args.flatc_path == "" else args.flatc_path, args.schemas_path, args.binaries_path, args.output_path)) diff --git a/flatc_downloader.py b/flatc_downloader.py index fab8fd1..b0176c1 100644 --- a/flatc_downloader.py +++ b/flatc_downloader.py @@ -10,10 +10,11 @@ from main import prepare_app, execute_download if __name__ == "__main__": + sys.tracebacklimit = 0 prepare_app("images/flatbuffers-downloader-logo-clean.png") parser = argparse.ArgumentParser(prog=t("main.flatc_downloader_name"), description=t("main.flatc_downloader_desc")) - parser.add_argument("downloads_directory", type=str, default=os.getcwd(), + parser.add_argument("downloads_directory", nargs="?", type=str, default=os.getcwd(), help=t("main.download_directory_arg")) args = parser.parse_args() sys.exit(execute_download(args.downloads_directory)) diff --git a/main.py b/main.py index 99eb7b5..2fb2c2a 100644 --- a/main.py +++ b/main.py @@ -51,19 +51,19 @@ def prepare_app(icon_path: str): root.iconphoto(True, PhotoImage(file=get_resource_path(icon_path))) -def get_flatc_path(root_path: str, allow_ask: bool, suppress_ask_error: bool = True) -> str: +def get_flatc_path(root_path: str, allow_ask: bool, suppress_error: bool) -> str: """ Получение пути к файлу компилятора Flatbuffers. :param root_path: Путь к текущей рабочей директории. :param allow_ask: Позволить открыть файл через диалоговое окно, если файла нет в рабочей директории. - :param suppress_ask_error: Игнорировать ошибку FileNotFoundError, если не выводится диалоговое окно для файла. + :param suppress_error: Игнорировать ошибку FileNotFoundError. :return: Путь к файлу. """ flatc_path = which("flatc", path=root_path + os.sep) if flatc_path is not None: return os.path.abspath(flatc_path) if not allow_ask: - if suppress_ask_error: + if suppress_error: return "" raise FileNotFoundError(i18n.t("main.executable_not_found") % "flatc") if sys.platform == "win32": @@ -72,9 +72,13 @@ def get_flatc_path(root_path: str, allow_ask: bool, suppress_ask_error: bool = T filetypes = [] flatc_path = askopenfilename(title=i18n.t("main.tkinter_flatc_select"), filetypes=filetypes) if flatc_path == "": + if suppress_error: + return "" raise FileNotFoundError(i18n.t("main.executable_not_found") % "flatc") flatc_path = which(os.path.split(flatc_path)[1], path=os.path.split(flatc_path)[0]) if flatc_path is None: + if suppress_error: + return "" raise FileNotFoundError(i18n.t("main.executable_not_found") % "flatc") return os.path.abspath(flatc_path)