def load_plugins(): """Load all plugins.""" modules = chain() for iterable in ([get_modules_in_package("gadget.default_plugins")] + [get_modules_in_directory(dir) for dir in get_setting("PLUGIN_PATHS")]): modules = chain(modules, iterable) for module in modules: if hasattr(module, "initialize"): print "Loading plugin", module.__name__ try: module.initialize() Globals.plugins.update({module.__name__: module}) except UnsupportedPlugin as e: print "Plugin %s is unsupported: %s" % (module.__name__, e.message) else: print "Warning: plugin %s does not have an initialize function" % (module.__name__,)
def load_protocols(): """Load all protocols.""" modules = chain() for iterable in ([get_modules_in_package("gadget.default_protocols")] + [get_modules_in_directory(dir) for dir in get_setting("PROTOCOL_PATHS")]): modules = chain(modules, iterable) for module in modules: if hasattr(module, "build_protocol"): print "Loading protocol", module.__name__ try: protocol = module.build_protocol() if protocol: Globals.protocols.update({module.__name__: protocol}) except UnsupportedProtocol as e: print "Protocol %s is unsupported: %s" % (module.__name__, e.message) else: print "Warning: protocol %s does not have a build_protocol function" % (module.__name__,)