From fa5157298cbbf682250b2fd5f29ec5ce21d30df2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 19 Jan 2022 16:31:31 +0100 Subject: [PATCH] Improved project for compiling --- scripts/compile.sh | 16 ++++++++++++++++ scripts/run.sh | 5 +++++ src/py_to_uxf/application.py | 22 ++++++++++++++-------- 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 scripts/compile.sh create mode 100644 scripts/run.sh diff --git a/scripts/compile.sh b/scripts/compile.sh new file mode 100644 index 0000000..2486e46 --- /dev/null +++ b/scripts/compile.sh @@ -0,0 +1,16 @@ +#!/bin/bash +cd src + +pyinstaller --specpath ../dist/cspec \ + --workpath ../dist/cbuild \ + --distpath ../dist/cdist \ + --add-data ../../src/py_to_uxf/appsettings.json:. \ + --hidden-import pynput.keyboard._xorg \ + --hidden-import pynput.mouse._xorg \ + --hidden-import pyfiglet.fonts \ + --collect-data pyfiglet \ + -n py_to_uxf \ + -y \ + py_to_uxf/main.py + +cd ../ \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100644 index 0000000..41a61e1 --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,5 @@ +cd dist/cdist/py_to_uxf + +time ./py_to_uxf -p ../../../../sh_gismo/src -o gismo.uxf + +cd ../../../ diff --git a/src/py_to_uxf/application.py b/src/py_to_uxf/application.py index 8c31326..39311ec 100644 --- a/src/py_to_uxf/application.py +++ b/src/py_to_uxf/application.py @@ -47,15 +47,21 @@ class Application(ApplicationABC): Console.write_line(f'\t{func.access_modifier.value}{func.name}({args}): {func.return_type}') Console.write_line() + @staticmethod + def _exit(msg: str, tb=None): + if tb is not None: + Console.error(msg, tb) + else: + Console.error(msg) + sys.exit() + def main(self): Console.banner('Py to UXF') if self._path is None: - Console.error('Expected path') - return + self._exit('Expected path\n') if self._file is None: - Console.error(f'Expected output file') - return + self._exit(f'Expected output file\n') Console.write_line(f'Input path:', self._path) Console.write_line(f'Output path:', self._file) @@ -68,13 +74,13 @@ class Application(ApplicationABC): # self._console_output(classes) xml = self._umlet_creator.generate_xml(classes, implementations) except Exception as e: - Console.error('Parsing failed', f'{e} -> {traceback.format_exc()}') - sys.exit() + self._exit('Parsing failed', f'{e} -> {traceback.format_exc()}\n') if not self._file.endswith('.uxf'): - Console.error(f'Unexpected file {self._file}') - sys.exit() + self._exit(f'Unexpected file {self._file}\n') with open(self._file, 'w+') as file: file.write(xml) file.close() + + Console.write_line('\n')