Run the application
()
| 17 | |
| 18 | |
| 19 | def run(): |
| 20 | """Run the application""" |
| 21 | # import faulthandler |
| 22 | # faulthandler.enable() |
| 23 | |
| 24 | parser = argparse.ArgumentParser(prog="pyxrf", description="Command line arguments") |
| 25 | parser.add_argument( |
| 26 | "-c", |
| 27 | "--catalog-name", |
| 28 | default=None, |
| 29 | type=str, |
| 30 | dest="catalog_name", |
| 31 | help="Name of the Databroker catalog to open, e.g. 'srx'", |
| 32 | ) |
| 33 | parser.add_argument( |
| 34 | "-l", |
| 35 | "--loglevel", |
| 36 | default="INFO", |
| 37 | type=str, |
| 38 | dest="loglevel", |
| 39 | choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], |
| 40 | help="Logger level. Set to 'DEBUG' in order to see debug information.", |
| 41 | ) |
| 42 | parser.add_argument( |
| 43 | "-ct", |
| 44 | "--color-theme", |
| 45 | default="DEFAULT", |
| 46 | type=str, |
| 47 | dest="color_theme", |
| 48 | choices=["DEFAULT", "DARK"], |
| 49 | help="Color theme: DARK theme is only for debugging purposes.", |
| 50 | ) |
| 51 | args = parser.parse_args() |
| 52 | |
| 53 | from .model.catalog_management import catalog_info |
| 54 | |
| 55 | if args.catalog_name: |
| 56 | catalog_info.set_name(args.catalog_name) |
| 57 | |
| 58 | from .gui_module.main_window import MainWindow |
| 59 | from .gui_support.gpc_class import GlobalProcessingClasses |
| 60 | |
| 61 | # Setup the Logger |
| 62 | logger.setLevel(args.loglevel) |
| 63 | formatter = logging.Formatter(fmt="%(asctime)s : %(levelname)s : %(message)s") |
| 64 | stream_handler = logging.StreamHandler() |
| 65 | stream_handler.setFormatter(formatter) |
| 66 | stream_handler.setLevel(args.loglevel) |
| 67 | logger.addHandler(stream_handler) |
| 68 | |
| 69 | # Suppress warnings except if the program is run in debug mode |
| 70 | if args.loglevel != "DEBUG": |
| 71 | sys.tracebacklimit = 0 |
| 72 | |
| 73 | gpc = GlobalProcessingClasses() |
| 74 | # Initialize 'gpc' in 'MainWindow.__init__' |
| 75 | |
| 76 | app = QApplication(sys.argv) |
no test coverage detected