From 32695e195a286276846f0b4f7133c30cf5a62b18 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 28 Apr 2018 21:26:53 -0400 Subject: move extension classes into inkstitch/extensions and add inkstitch.py --- inkstitch.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 inkstitch.py (limited to 'inkstitch.py') diff --git a/inkstitch.py b/inkstitch.py new file mode 100644 index 00000000..bd3f3f48 --- /dev/null +++ b/inkstitch.py @@ -0,0 +1,36 @@ +import sys +import traceback +from argparse import ArgumentParser +from inkstitch.utils import save_stderr, restore_stderr +from inkstitch import extensions + + +def get_extension(): + parser = ArgumentParser() + parser.add_argument("--extension") + args, extras = parser.parse_known_args() + + return args.extension + + +extension_name = get_extension() +extension_class = getattr(extensions, extension_name.capitalize()) +extension = extension_class() + +exception = None + +save_stderr() +try: + extension.affect() +except (SystemExit, KeyboardInterrupt): + raise +except Exception: + exception = traceback.format_exc() +finally: + restore_stderr() + +if exception: + print >> sys.stderr, exception + sys.exit(1) +else: + sys.exit(0) -- cgit v1.2.3 From b5fbc23f746c86cc985711026d6585991c3251f4 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 28 Apr 2018 22:14:23 -0400 Subject: fixes --- inkstitch.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'inkstitch.py') diff --git a/inkstitch.py b/inkstitch.py index bd3f3f48..fe8d6ecb 100644 --- a/inkstitch.py +++ b/inkstitch.py @@ -5,15 +5,11 @@ from inkstitch.utils import save_stderr, restore_stderr from inkstitch import extensions -def get_extension(): - parser = ArgumentParser() - parser.add_argument("--extension") - args, extras = parser.parse_known_args() +parser = ArgumentParser() +parser.add_argument("--extension") +my_args, remaining_args = parser.parse_known_args() - return args.extension - - -extension_name = get_extension() +extension_name = my_args.extension extension_class = getattr(extensions, extension_name.capitalize()) extension = extension_class() @@ -21,7 +17,7 @@ exception = None save_stderr() try: - extension.affect() + extension.affect(args=remaining_args) except (SystemExit, KeyboardInterrupt): raise except Exception: -- cgit v1.2.3 From 1b31806423c8fec4040fed6d1009db016860b763 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 1 May 2018 20:37:51 -0400 Subject: rename inkstitch/ to lib/ You can't have a module and a package named the same thing. PyInstaller wants to import the main script as if it were a module, and this doesn't work unless there's no directory of the same name with a __init__.py in it. --- inkstitch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inkstitch.py') diff --git a/inkstitch.py b/inkstitch.py index fe8d6ecb..a9ce829e 100644 --- a/inkstitch.py +++ b/inkstitch.py @@ -1,8 +1,8 @@ import sys import traceback from argparse import ArgumentParser -from inkstitch.utils import save_stderr, restore_stderr -from inkstitch import extensions +from lib.utils import save_stderr, restore_stderr +from lib import extensions parser = ArgumentParser() -- cgit v1.2.3