Exemple #1
0
def setUpModule():
    plugins = []
    path = os.path.join(os.path.dirname(__file__),'plugins')
    path = os.path.normpath(os.path.abspath(path))
    assert os.path.exists(path)

    for (dirpath, dirnames, filenames) in os.walk(path):
        if '.svn' in dirpath: continue
        for name in dirnames:
            if name == '.svn': continue
            launchsh = os.path.join(dirpath, name, 'launch.sh')
            if os.path.exists(launchsh):
                log.info("Plugin [launch]: '%s'",launchsh)
                plugins.append( (name, launchsh) )
                continue
            # Find all instances of PluginName/PluginName.py
            plugindef = os.path.join(dirpath, name, name + '.py')
            if os.path.exists(plugindef):
                log.info("Plugin [class]: '%s'",plugindef)
                #sys.path.append(os.path.join(dirpath, name))
                plugins.append( (name, plugindef) )
                continue
            log.debug("Path (No Plugins): '%s/%s'",dirpath, name)

    assert plugins
    cache.set_installed_modules(plugins)

    for (name, script) in plugins:
        ret = cache.load_module(name, script)
        assert ret
    return True
Exemple #2
0
def setUpModule():
    plugins = []
    path = os.path.join(os.path.dirname(__file__), 'plugins')
    path = os.path.normpath(os.path.abspath(path))
    assert os.path.exists(path)

    for (dirpath, dirnames, filenames) in os.walk(path):
        if '.svn' in dirpath: continue
        for name in dirnames:
            if name == '.svn': continue
            launchsh = os.path.join(dirpath, name, 'launch.sh')
            if os.path.exists(launchsh):
                log.info("Plugin [launch]: '%s'", launchsh)
                plugins.append((name, launchsh))
                continue
            # Find all instances of PluginName/PluginName.py
            plugindef = os.path.join(dirpath, name, name + '.py')
            if os.path.exists(plugindef):
                log.info("Plugin [class]: '%s'", plugindef)
                #sys.path.append(os.path.join(dirpath, name))
                plugins.append((name, plugindef))
                continue
            log.debug("Path (No Plugins): '%s/%s'", dirpath, name)

    assert plugins
    cache.set_installed_modules(plugins)

    for (name, script) in plugins:
        ret = cache.load_module(name, script)
        assert ret
    return True
Exemple #3
0
def test_pluginscan():
    plugins = []
    d = os.path.dirname(__file__)
    for path in [
            os.path.join(d, '../../plugin'),
            os.path.join(d, '../../rndplugins')
    ]:
        path = os.path.normpath(os.path.abspath(path))
        if not os.path.exists(path):
            logger.debug("skipping '%s'", path)
            continue
        for (dirpath, dirnames, filenames) in os.walk(path):
            for name in dirnames:
                launchsh = os.path.join(dirpath, name, 'launch.sh')
                if os.path.exists(launchsh):
                    plugins.append((name, launchsh))
                    continue
                # Find all instances of PluginName/PluginName.py
                plugindef = os.path.join(dirpath, name, name + '.py')
                if os.path.exists(plugindef):
                    #sys.path.append(os.path.join(dirpath, name))
                    plugins.append((name, plugindef))

    logger.debug("Plugins: '%s'", plugins)

    cache.set_installed_modules(plugins)

    for (name, err) in cache.get_errors().iteritems():
        if err.__class__.__name__ == 'ImportError':
            logger.warn("Import Error [%s]: %s", name, err)
        else:
            logger.warn("Syntax Error [%s]: %s: %s", name,
                        err.__class__.__name__, err)

    for m in cache.get_plugins():
        cls = cache.get_plugin(m)
        if not cls:
            continue
        logger.info("Plugin Name: %s", m)
        yield check_plugin, cls
Exemple #4
0
def test_pluginscan():
    plugins = []
    d = os.path.dirname(__file__)
    for path in [os.path.join(d,'../../plugin'), os.path.join(d,'../../rndplugins') ]:
        path = os.path.normpath(os.path.abspath(path))
        if not os.path.exists(path):
            logger.debug("skipping '%s'", path)
            continue
        for (dirpath, dirnames, filenames) in os.walk(path):
            for name in dirnames:
                launchsh = os.path.join(dirpath, name, 'launch.sh')
                if os.path.exists(launchsh):
                    plugins.append( (name, launchsh) )
                    continue
                # Find all instances of PluginName/PluginName.py
                plugindef = os.path.join(dirpath, name, name + '.py')
                if os.path.exists(plugindef):
                    #sys.path.append(os.path.join(dirpath, name))
                    plugins.append( (name, plugindef) )

    logger.debug("Plugins: '%s'", plugins)

    cache.set_installed_modules(plugins)

    for (name, err) in cache.get_errors().iteritems():
        if err.__class__.__name__ == 'ImportError':
            logger.warn("Import Error [%s]: %s", name, err)
        else:
            logger.warn("Syntax Error [%s]: %s: %s", name, err.__class__.__name__, err)

    for m in cache.get_plugins():
        cls = cache.get_plugin(m)
        if not cls:
            continue
        logger.info("Plugin Name: %s", m)
        yield check_plugin, cls