summaryrefslogtreecommitdiff
path: root/support/openscad
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2015-09-11 21:55:58 +0200
committerMichael Schwarz <michi.schwarz@gmail.com>2015-09-16 01:50:23 +0200
commit096db19a9a465cc667aa5d0ef92df2eeac5955b2 (patch)
treeeba053a06141adb569d6f33fb9e28675faecc0a6 /support/openscad
parent93f96964914ae30686d30e5667bff92f2d17b791 (diff)
downloadpogojig-096db19a9a465cc667aa5d0ef92df2eeac5955b2.tar.gz
pogojig-096db19a9a465cc667aa5d0ef92df2eeac5955b2.tar.bz2
pogojig-096db19a9a465cc667aa5d0ef92df2eeac5955b2.zip
Wrap all Python main functions with decorator.
This decorator check if a module was called as the main module and catches exceptions.
Diffstat (limited to 'support/openscad')
-rw-r--r--support/openscad/__main__.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/support/openscad/__main__.py b/support/openscad/__main__.py
index 28de2cf..0eae27e 100644
--- a/support/openscad/__main__.py
+++ b/support/openscad/__main__.py
@@ -1,4 +1,4 @@
-import os, sys
+import os
from lib import util
@@ -10,6 +10,7 @@ def _write_dependencies(path, target, dependencies):
util.write_file(path, '{}: {}\n'.format(target, ' '.join(dependencies)).encode())
+@util.main
def main(in_path, out_path, deps_path):
cwd = os.getcwd()
@@ -43,12 +44,3 @@ def main(in_path, out_path, deps_path):
# Write output files.
_write_dependencies(deps_path, relpath(out_path), deps - ignored_files)
util.rename_atomic(temp_out_path, out_path)
-
-
-try:
- main(*sys.argv[1:])
-except util.UserError as e:
- print 'Error:', e
- sys.exit(1)
-except KeyboardInterrupt:
- sys.exit(2)