Beispiel #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.

        """
        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)
Beispiel #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:
                #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)
Beispiel #3
0
 def reloadfile(self, filename, force=True):
     mlist = filename.split(os.sep)
     mod = []
     for m in mlist[::-1]:
         mod.insert(0, m)
         if m == "myplugs": break 
     modname = ".".join(mod)[:-3]
     if not isenabled(modname): logging.warn("%s is not enabled. not loading" % modname) ; return
     from boot import plugblacklist
     if modname in plugblacklist.data: logging.warn("%s is in blacklist .. not loading." % modname) ; return
     logging.debug("using %s" % modname)
     logging.info("reloading %s" % filename)
     try: self.reload(modname, force)
     except RequireError, ex: logging.info(str(ex))
Beispiel #4
0
 def reloadfile(self, filename, force=True):
     mlist = filename.split(os.sep)
     mod = []
     for m in mlist[::-1]:
         mod.insert(0, m)
         if m == "myplugs": break 
     modname = ".".join(mod)[:-3]
     if not isenabled(modname): logging.warn("%s is not enabled. not loading" % modname) ; return
     from boot import plugblacklist
     if modname in plugblacklist.data: logging.warn("%s is in blacklist .. not loading." % modname) ; return
     logging.debug("using %s" % modname)
     logging.info("reloading %s" % filename)
     try: self.reload(modname, force)
     except RequireError, ex: logging.info(str(ex))
Beispiel #5
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
Beispiel #6
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]
Beispiel #7
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]
Beispiel #8
0
 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)