def _initialize_module(module_name, module): """Call initialization method in the module if it exists""" # Perform setup related initialization on the module setup.init(module_name, module) try: init = module.init except AttributeError: logger.debug('No init() for module - %s', module.__name__) return try: init() except Exception as exception: logger.exception('Exception while running init for %s: %s', module, exception) if cfg.debug: raise
def _initialize_module(module_name, module): """Perform module initialization""" # Perform setup related initialization on the module setup.init(module_name, module) try: module_classes = inspect.getmembers(module, inspect.isclass) app_class = [ cls for cls in module_classes if issubclass(cls[1], app.App) ] if module_classes and app_class: module.app = app_class[0][1]() if module.setup_helper.get_state( ) != 'needs-setup' and module.app.is_enabled(): module.app.set_enabled(True) except Exception as exception: logger.exception('Exception while running init for %s: %s', module, exception) if cfg.develop: raise