comparison scripts/pytouhou @ 603:e9300aae4b24

Display the traceback on module load error.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 04 Nov 2014 16:44:59 +0100
parents 244c99c568c8
children 2cf518129725
comparison
equal deleted inserted replaced
602:c84227022765 603:e9300aae4b24
62 62
63 def load_module(type_, name, items=None): 63 def load_module(type_, name, items=None):
64 try: 64 try:
65 module = import_module('pytouhou.games.%s.%s' % (name, type_)) 65 module = import_module('pytouhou.games.%s.%s' % (name, type_))
66 except ImportError: 66 except ImportError:
67 logger.critical('Module “%s” doesn’t contain %s data, aborting.', name, type_) 67 logger.exception('Module “%s” doesn’t contain %s data, aborting:', name, type_)
68 sys.exit(1) 68 sys.exit(1)
69 if items is None: 69 if items is None:
70 return module 70 return module
71 return (getattr(module, item) for item in items) 71 return (getattr(module, item) for item in items)
72 72
94 else: 94 else:
95 options = {} 95 options = {}
96 96
97 try: 97 try:
98 backend = import_module('pytouhou.ui.%s.backend' % backend_name) 98 backend = import_module('pytouhou.ui.%s.backend' % backend_name)
99 except ImportError as e: 99 except ImportError:
100 logger.exception('Failed to import backend %s:', backend_name) 100 logger.exception('Failed to import backend %s:', backend_name)
101 continue 101 continue
102 102
103 try: 103 try:
104 backend.init(options) 104 backend.init(options)
105 except Exception as e: 105 except Exception:
106 logger.exception('Backend %s failed to initialize:', backend_name) 106 logger.exception('Backend %s failed to initialize:', backend_name)
107 continue 107 continue
108 108
109 GameRenderer = backend.GameRenderer 109 GameRenderer = backend.GameRenderer
110 break 110 break