Ejemplo n.º 1
0
 def initConfig(self, filename="vb2py.ini", path=None):
     """Read the values"""
     if path is None:
         path = rootPath()
     self._config = ConfigParser.ConfigParser()
     self._config.read(os.path.join(path, filename))
     self._local_overide = {}
Ejemplo n.º 2
0
def loadAllPlugins():
    """Load all plug-ins from the plug-in directory and return a list of all the classes"""
    import plugins
    mods = []
    for mod in plugins.mods:
        log.info("Checking '%s' for plugins" % mod)
        #
        f = open(os.path.join(rootPath(), "plugins", "%s.py" % mod), "r")
        try:
            try:
                m = imp.load_module(mod, f, "Plugin-%s" % mod, ('*.py', 'r', 1))
            finally:
                f.close()
        except Exception, err:
            log.warn("Error importing '%s' (%s). Module skipped" % (mod, err))
            continue
        #
        for name in dir(m):
            cls = getattr(m, name)
            #import pdb; pdb.set_trace()
            try:
                is_plugin = cls.__is_plugin__
            except AttributeError:
                is_plugin = 0
            if is_plugin:
                try:
                    p = cls()               
                    log.info("Added new plug-in: '%s" % p.name)
                    mods.append(p)
                except Exception, err:
                    log.warn("Error creating plugin '%s' (%s). Class skipped" % (cls, err))
Ejemplo n.º 3
0
 def initConfig(self, filename="vb2py.ini", path=None):
     """Read the values"""
     if path is None:
         path = rootPath()
     self._config = ConfigParser.ConfigParser()
     self._config.read(os.path.join(path, filename))
     self._local_overide = {}	
Ejemplo n.º 4
0
def loadAllPlugins():
    """Load all plug-ins from the plug-in directory and return a list of all the classes"""
    import plugins
    mods = []
    for mod in plugins.mods:
        log.info("Checking '%s' for plugins" % mod)
        #
        f = open(os.path.join(rootPath(), "plugins", "%s.py" % mod), "r")
        try:
            try:
                m = imp.load_module(mod, f, "Plugin-%s" % mod,
                                    ('*.py', 'r', 1))
            finally:
                f.close()
        except Exception, err:
            log.warn("Error importing '%s' (%s). Module skipped" % (mod, err))
            continue
        #
        for name in dir(m):
            cls = getattr(m, name)
            #import pdb; pdb.set_trace()
            try:
                is_plugin = cls.__is_plugin__
            except AttributeError:
                is_plugin = 0
            if is_plugin:
                try:
                    p = cls()
                    log.info("Added new plug-in: '%s" % p.name)
                    mods.append(p)
                except Exception, err:
                    log.warn("Error creating plugin '%s' (%s). Class skipped" %
                             (cls, err))
Ejemplo n.º 5
0
 def __init__(self, basesourcefile=None):
     """Initialize the resource"""
     if basesourcefile is None:
         self.basesourcefile = os.path.join(rootPath(), "targets",
                                            self.target_name, "basesource")
     else:
         self.basesourcefile = basesourcefile
     #
     # Apply default resource
     self._rsc = {}
     self._code = ""
     #
     log.info("BaseResource init")
Ejemplo n.º 6
0
 def __init__(self, basesourcefile=None):
     """Initialize the resource"""
     if basesourcefile is None:
         self.basesourcefile = os.path.join(
                     rootPath(), "targets", self.target_name, "basesource")
     else:
         self.basesourcefile = basesourcefile
     #
     # Apply default resource
     self._rsc = {}
     self._code = ""
     #
     log.debug("BaseResource init")