Example #1
0
    def loadall(self, paths=[], force=True):
        """
            load all plugins from given paths, if force is true .. 
            otherwise load all plugins for default_plugins list.

        """
        from boot import plugblacklist
        if not paths: paths = plugin_packages
        imp = None
        for module in paths:
            try: imp = _import(module)
            except ImportError, ex:
                #handle_exception()
                logging.warn("no %s plugin package found - %s" % (module, str(ex)))
                continue
            except Exception, ex: handle_exception()
            logging.debug("got plugin package %s" % module)
            try:
                for plug in imp.__plugs__:
                    mod = "%s.%s" % (module, plug)
                    if mod in plugblacklist.data: logging.warn("%s is in blacklist .. not loading." % mod) ; continue
                    try: self.reload(mod, force=force, showerror=True)
                    except KeyError: logging.debug("failed to load plugin package %s" % module)
                    except Exception, ex: handle_exception()
            except AttributeError: logging.error("no plugins in %s .. define __plugs__ in __init__.py" % module)
Example #2
0
    def loadall(self, paths=[], force=True):
        """
            load all plugins from given paths, if force is true .. 
            otherwise load all plugins for default_plugins list.

        """
        if not paths: paths = plugin_packages
        imp = None
        old = self.keys()
        new = []
        logging.warn("loading all from paths %s" % paths)
        for module in paths:
            try: imp = _import(module)
            except ImportError, ex:
                logging.warn("no %s plugin package found - %s" % (module, str(ex)))
                continue
            except Exception, ex: handle_exception()
            logging.debug("got plugin package %s" % module)
            try:
                for plug in imp.__plugs__:
                    if "gae" in plug: continue
                    mod = "%s.%s" % (module, plug)
                    if not isenabled(mod): logging.warn("%s is not enabled. not loading" % mod) ; continue
                    try: self.reload(mod, force=force, showerror=True)
                    except RequireError, ex: logging.info(str(ex)) ; continue
                    except KeyError: logging.debug("failed to load plugin package %s" % module) ; continue
                    except Exception, ex: handle_exception() ; continue
                    new.append(mod)
Example #3
0
    def loadall(self, paths=[], force=True):
        """
            load all plugins from given paths, if force is true .. 
            otherwise load all plugins for default_plugins list.

        """
        if not paths: paths = plugin_packages
        imp = None
        old = self.keys()
        new = []
        logging.warn("loading all from paths %s" % paths)
        for module in paths:
            try: imp = _import(module)
            except ImportError, ex:
                #handle_exception()
                logging.warn("no %s plugin package found - %s" % (module, str(ex)))
                continue
            except Exception, ex: handle_exception()
            logging.debug("got plugin package %s" % module)
            try:
                for plug in imp.__plugs__:
                    if "gae" in plug: continue
                    mod = "%s.%s" % (module, plug)
                    if not isenabled(mod): logging.warn("%s is not enabled. not loading" % mod) ; continue
                    try: self.reload(mod, force=force, showerror=True)
                    except RequireError, ex: logging.info(str(ex)) ; continue
                    except KeyError: logging.debug("failed to load plugin package %s" % module) ; continue
                    except Exception, ex: handle_exception() ; continue
                    new.append(mod)
Example #4
0
 def load(self, modname, force=False, showerror=True, loaded=[]):
     """ load a plugin. """
     if not modname: raise NoSuchPlugin(modname)
     if not force and modname in loaded: logging.warn("skipping %s" % modname) ; return loaded
     if self.has_key(modname):
         try:
             logging.debug("%s already loaded" % modname)                
             if not force: return self[modname]
             self[modname] = reload(self[modname])
         except Exception, ex: raise
     else:
         logging.debug("trying %s" % modname)
         mod = _import(modname)
         if not mod: return None
         try: self[modname] = mod
         except KeyError:
             logging.info("failed to load %s" % modname)
             raise NoSuchPlugin(modname)
     try: init = getattr(self[modname], 'init')
     except AttributeError:
         logging.warn("%s loaded" % modname)
         return self[modname]
     try:
         init()
         logging.debug('%s init called' % modname)
     except Exception, ex: raise
     logging.warn("%s loaded" % modname)
     return self[modname]
Example #5
0
 def getmodule(self, plugname):
     for module in plugin_packages:
         try: imp = _import(module)
         except ImportError, ex:
             if "No module" in str(ex):
                 logging.info("no %s plugin package found" % module)
                 continue
             raise
         except Exception, ex: handle_exception() ; continue
         if plugname in imp.__plugs__: return "%s.%s" % (module, plugname)
Example #6
0
 def getmodule(self, plugname):
     for module in plugin_packages:
         try: imp = _import(module)
         except ImportError, ex:
             if "No module" in str(ex):
                 logging.info("no %s plugin package found" % module)
                 continue
             raise
         except Exception, ex: handle_exception() ; continue
         if plugname in imp.__plugs__: return "%s.%s" % (module, plugname)
Example #7
0
 def getmodule(self, plugname):
     for module in plugin_packages:
         try:
             imp = _import(module)
         except ImportError, ex:
             if "No module" in str(ex):
                 logging.info("plugins - no %s plugin package found" %
                              module)
                 continue
             raise
         except Exception, ex:
             handle_exception()
             continue
Example #8
0
    def loadall(self, paths=[], force=True):
        """
            load all plugins from given paths, if force is true .. 
            otherwise load all plugins for default_plugins list.

        """
        if not paths: paths = plugin_packages
        imp = None
        for module in paths:
            try:
                imp = _import(module)
            except ImportError, ex:
                #handle_exception()
                logging.warn("plugins - no %s plugin package found - %s" %
                             (module, str(ex)))
                continue
            except Exception, ex:
                handle_exception()
Example #9
0
 def load_mod(self, modname, force=False, showerror=True, loaded=[]):
     """ load a plugin. """
     if not modname: raise NoSuchPlugin(modname)
     if not isenabled(modname): logging.warn("%s is not enabled. not loading" % modname) ; return
     if not force and modname in loaded: logging.warn("skipping %s" % modname) ; return loaded
     from boot import plugblacklist
     if plugblacklist and modname in plugblacklist.data: logging.warn("%s is in blacklist .. not loading." % modname) ; return loaded
     if self.has_key(modname):
         try:
             logging.debug("%s already loaded" % modname)                
             if not force: return self[modname]
             self[modname] = reload(self[modname])
         except Exception, ex: raise
     else:
         logging.debug("trying %s" % modname)
         mod = _import(modname)
         if not mod: return None
         try: self[modname] = mod
         except KeyError:
             logging.info("failed to load %s" % modname)
             raise NoSuchPlugin(modname)
     try: init = getattr(self[modname], 'init')
     except AttributeError: init = None
     try: threaded_init = getattr(self[modname], 'init_threaded')
     except AttributeError: threaded_init = None
     try:
         init and init()
         logging.debug('%s init called' % modname)
     except RequireError, ex: logging.info(str(ex)) ; return
     except URLNotEnabled: logging.error("URL fetching is disabled")
     except Exception, ex: raise
     try:
         threaded_init and start_new_thread(threaded_init, ())
         logging.debug('%s threaded_init started' % modname)
     except Exception, ex: raise
     logging.warn("%s loaded" % modname)
     return self[modname]
Example #10
0
 def load_mod(self, modname, force=False, showerror=True, loaded=[]):
     """ load a plugin. """
     if not modname: raise NoSuchPlugin(modname)
     if not isenabled(modname): logging.warn("%s is not enabled. not loading" % modname) ; return
     if not force and modname in loaded: logging.warn("skipping %s" % modname) ; return loaded
     from boot import plugblacklist
     if plugblacklist and modname in plugblacklist.data: logging.warn("%s is in blacklist .. not loading." % modname) ; return loaded
     if self.has_key(modname):
         try:
             logging.debug("%s already loaded" % modname)                
             if not force: return self[modname]
             self[modname] = reload(self[modname])
         except Exception, ex: raise
     else:
         logging.debug("trying %s" % modname)
         mod = _import(modname)
         if not mod: return None
         try: self[modname] = mod
         except KeyError:
             logging.info("failed to load %s" % modname)
             raise NoSuchPlugin(modname)
     try: init = getattr(self[modname], 'init')
     except AttributeError: init = None
     try: threaded_init = getattr(self[modname], 'init_threaded')
     except AttributeError: threaded_init = None
     try:
         init and init()
         logging.debug('%s init called' % modname)
     except RequireError, ex: logging.info(str(ex)) ; return
     except URLNotEnabled: logging.error("URL fetching is disabled")
     except Exception, ex: raise
     try:
         threaded_init and start_new_thread(threaded_init, ())
         logging.debug('%s threaded_init started' % modname)
     except Exception, ex: raise
     logging.warn("%s loaded" % modname)
     return self[modname]
Example #11
0
     logging.warn("skipping %s" % modname)
     return loaded
 from boot import plugblacklist
 if plugblacklist and modname in plugblacklist.data:
     logging.warn("%s is in blacklist .. not loading." % modname)
     return loaded
 if self.has_key(modname):
     try:
         logging.debug("%s already loaded" % modname)
         if not force: return self[modname]
         self[modname] = reload(self[modname])
     except Exception, ex:
         raise
 else:
     logging.debug("trying %s" % modname)
     mod = _import(modname)
     if not mod: return None
     try:
         self[modname] = mod
     except KeyError:
         logging.info("failed to load %s" % modname)
         raise NoSuchPlugin(modname)
 try:
     init = getattr(self[modname], 'init')
 except AttributeError:
     init = None
 try:
     threaded_init = getattr(self[modname], 'init_threaded')
 except AttributeError:
     threaded_init = None
 try: