diff --git a/SuperScriptViewer/CustomConfig.py b/SuperScriptViewer/CustomConfig.py index df0e4c4..4201536 100644 --- a/SuperScriptViewer/CustomConfig.py +++ b/SuperScriptViewer/CustomConfig.py @@ -7,4 +7,4 @@ export_db = "export.db" decorated_db = "decorate.db" env_db = "env.db" force_regenerate = False - +debug_mode = False diff --git a/SuperScriptViewer/SuperScriptViewer.py b/SuperScriptViewer/SuperScriptViewer.py index c56ec5d..96a30c1 100644 --- a/SuperScriptViewer/SuperScriptViewer.py +++ b/SuperScriptViewer/SuperScriptViewer.py @@ -4,16 +4,17 @@ import ServerCore import os import sys import getopt +import logging try: - opts, args = getopt.getopt(sys.argv[1:], "hi:o:e:f") + opts, args = getopt.getopt(sys.argv[1:], "hi:o:e:c:fd") except getopt.GetoptError: print('Wrong arguments!') - print('python SuperScriptViewer.py -i -o -e -c -f') + print('python SuperScriptViewer.py -i -o -e -c -f -d') sys.exit(1) for opt, arg in opts: if opt == '-h': - print('python SuperScriptViewer.py -i -o -e -c -f') + print('python SuperScriptViewer.py -i -o -e -c -f -d') sys.exit(0) elif opt == '-i': CustomConfig.export_db = arg @@ -25,13 +26,18 @@ for opt, arg in opts: CustomConfig.database_encoding = arg elif opt == '-f': CustomConfig.force_regenerate = True + elif opt == '-d': + CustomConfig.debug_mode = True +print('Super Script View') +print('Homepage: https://github.com/yyc12345/SuperScriptMaterializer') +print('Report bug: https://github.com/yyc12345/SuperScriptMaterializer/issues') +print('') # process -f if (CustomConfig.force_regenerate): if os.path.isfile(CustomConfig.decorated_db): os.remove(CustomConfig.decorated_db) -print('Super Script View') if not os.path.isfile(CustomConfig.env_db): print('No environment database. Fail to generate. Exit app.') sys.exit(1) @@ -43,7 +49,16 @@ if not os.path.isfile(CustomConfig.decorated_db): sys.exit(1) # generate db - DecoratorCore.run() + if CustomConfig.debug_mode: + DecoratorCore.run() + else: + try: + DecoratorCore.run() + except Exception as ex: + print("!!! An error occurs. Please report follwoing error output and reproduce file to developer. !!!") + logging.exception(ex) + sys.exit(1) + print('Decorated database generating done.') # todo: start flask diff --git a/SuperScriptViewer/SuperScriptViewer.pyproj b/SuperScriptViewer/SuperScriptViewer.pyproj index 34cc9c7..3953a33 100644 --- a/SuperScriptViewer/SuperScriptViewer.pyproj +++ b/SuperScriptViewer/SuperScriptViewer.pyproj @@ -12,8 +12,7 @@ SuperScriptViewer SuperScriptViewer Standard Python launcher - - + -f -d False