Skip to content

Commit

Permalink
Added logging_redirect_tqdm call and specified shell in build_executa…
Browse files Browse the repository at this point in the history
…ble.yml workflow.
  • Loading branch information
Shararamosh committed Aug 10, 2024
1 parent da071c9 commit 62493eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_executable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
run: pyinstaller --onefile --name="flatc_deserializer" --console --icon=images\flatbuffers-logo-clean.png --add-data="images:images" --add-data="localization:localization" main.py
- name: Copy Executable from dist to root directory
run: copy dist\flatc_deserializer.exe .
shell: cmd
- name: Create Automatic Windows Release
uses: marvinpinto/action-automatic-releases@latest
with:
Expand Down
23 changes: 13 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import i18n
from PIL.ImageTk import PhotoImage
from tqdm import tqdm
from tqdm.contrib.logging import logging_redirect_tqdm
from flatc_funcs import deserialize # pylint: disable=import-error


Expand Down Expand Up @@ -40,10 +41,10 @@ def get_resource_path(filename: str) -> str:
root.iconphoto(True, PhotoImage(file=get_resource_path("images/flatbuffers-logo-clean.png")))


def main() -> int:
def main() -> int | str:
"""
Десериализация бинарных файлов Flatbuffers по заданной схеме.
:return: Код ошибки.
:return: Код ошибки или строка об ошибке.
"""
flatc_path = askopenfilename(title=i18n.t("main.tkinter_flatc_select"),
filetypes=[(i18n.t("main.exe_filetype"), "*.exe")])
Expand All @@ -59,14 +60,16 @@ def main() -> int:
(i18n.t("main.flatc_binary_filetype"), "*." + schema_name)])
output_path = askdirectory(title=i18n.t("flatc_funcs.tkinter_output_select"))
full_size = sum(os.stat(binary_path).st_size for binary_path in binary_paths)
pbar = tqdm(total=full_size, position=0, unit="B", unit_scale=True, desc=i18n.t("main.files"))
for binary_path in binary_paths:
pbar.set_postfix_str(binary_path)
pbar.clear()
deserialize(flatc_path, schema_path, binary_path, output_path)
pbar.update(os.stat(binary_path).st_size)
pbar.set_postfix_str("")
pbar.close()
with logging_redirect_tqdm():
pbar = tqdm(total=full_size, position=0, unit="B", unit_scale=True,
desc=i18n.t("main.files"))
for binary_path in binary_paths:
pbar.set_postfix_str(binary_path)
pbar.clear()
deserialize(flatc_path, schema_path, binary_path, output_path)
pbar.update(os.stat(binary_path).st_size)
pbar.set_postfix_str("")
pbar.close()
return os.EX_OK


Expand Down

0 comments on commit 62493eb

Please sign in to comment.