def register_handlers_in_dir(path): # Attempts to register any handler modules under the given path. if not path or not os.path.isdir(path): return potential_handlers = util.find_modules(path) for (fname, mod_name) in potential_handlers.items(): try: mod_locs, looked_locs = importer.find_module( mod_name, [""], ["list_types", "handle_part"] ) if not mod_locs: LOG.warning( "Could not find a valid user-data handler" " named %s in file %s (searched %s)", mod_name, fname, looked_locs, ) continue mod = importer.import_module(mod_locs[0]) mod = handlers.fixup_handler(mod) types = c_handlers.register(mod) if types: LOG.debug( "Added custom handler for %s [%s] from %s", types, mod, fname, ) except Exception: util.logexc( LOG, "Failed to register handler from %s", fname )
def register_handlers_in_dir(path): # Attempts to register any handler modules under the given path. if not path or not os.path.isdir(path): return potential_handlers = util.find_modules(path) for (fname, mod_name) in potential_handlers.items(): try: mod_locs, looked_locs = importer.find_module( mod_name, [''], ['list_types', 'handle_part']) if not mod_locs: LOG.warn("Could not find a valid user-data handler" " named %s in file %s (searched %s)", mod_name, fname, looked_locs) continue mod = importer.import_module(mod_locs[0]) mod = handlers.fixup_handler(mod) types = c_handlers.register(mod) if types: LOG.debug("Added custom handler for %s [%s] from %s", types, mod, fname) except Exception: util.logexc(LOG, "Failed to register handler from %s", fname)