예제 #1
0
def get_enabled_plugins():
    """
    Open plugin config files from plugin_config_dir and determine if they are
    enabled.  If so, append them to 'enabled_plugins' in the root config.
    Uses the namespaces['root'].config dictionary.
    
    """
    config = get_config()
    if config.has_key('enabled_plugins'):
        enabled_plugins = config['enabled_plugins']
    else:
        enabled_plugins = []

    # determine enabled plugins

    # first from config files
    for _file in config['config_files']:
        try:
            cnf = ConfigObj(_file)
        except IOError, error:
            log.warning("Unable to open config '%s': %s" % \
                (_file, error.args[1]))
            continue

        for sect in cnf.sections:
            if sect != 'root' and cnf[sect].has_key('enable_plugin') \
                              and t_f_pass(cnf[sect]['enable_plugin']) == True \
                              and not sect in enabled_plugins:
                if not cnf[sect].has_key('provider'):
                    provider = config['app_module']
                else:
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)
예제 #2
0
파일: plugin.py 프로젝트: derks/cement
def get_enabled_plugins():
    """
    Open plugin config files from plugin_config_dir and determine if they are
    enabled.  If so, append them to 'enabled_plugins' in the root config.
    Uses the namespaces['root'].config dictionary.
    
    """
    config = get_config()
    if config.has_key('enabled_plugins'):
        enabled_plugins = config['enabled_plugins']
    else:
        enabled_plugins = []
        
    # determine enabled plugins
    
    # first from config files
    for _file in config['config_files']:    
        try:
            cnf = ConfigObj(_file)
        except IOError, error:
            log.warning("Unable to open config '%s': %s" % \
                (_file, error.args[1]))
            continue
            
        for sect in cnf.sections:
            if sect != 'root' and cnf[sect].has_key('enable_plugin') \
                              and t_f_pass(cnf[sect]['enable_plugin']) == True \
                              and not sect in enabled_plugins:
                if not cnf[sect].has_key('provider'):
                    provider = config['app_module']
                else:
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)
예제 #3
0
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)

    # Then for plugin config files
    for _file in os.listdir(config['plugin_config_dir']):
        path = os.path.join(config['plugin_config_dir'], _file)
        if not path.endswith('.conf'):
            continue

        cnf = ConfigObj(path)
        for sect in cnf.sections:
            if sect != 'root' and cnf[sect].has_key('enable_plugin') \
                              and t_f_pass(cnf[sect]['enable_plugin']) == True \
                              and not sect in enabled_plugins:
                if not cnf[sect].has_key('provider'):
                    provider = config['app_module']
                else:
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)
    return enabled_plugins


def load_plugin(plugin):
    """
    Load a cement plugin.  
예제 #4
0
def check_pass(val):
    assert t_f_pass(val) == val
    
예제 #5
0
def check_false(val):
    assert t_f_pass(val) == False
예제 #6
0
def check_true(val):
    assert t_f_pass(val) == True
예제 #7
0
def check_pass(val):
    assert t_f_pass(val) == val
예제 #8
0
def check_false(val):
    assert t_f_pass(val) == False
예제 #9
0
def check_true(val):
    assert t_f_pass(val) == True
예제 #10
0
파일: plugin.py 프로젝트: derks/cement
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)

    # Then for plugin config files
    for _file in os.listdir(config['plugin_config_dir']):
        path = os.path.join(config['plugin_config_dir'], _file)
        if not path.endswith('.conf'):
            continue
            
        cnf = ConfigObj(path)
        for sect in cnf.sections:
            if sect != 'root' and cnf[sect].has_key('enable_plugin') \
                              and t_f_pass(cnf[sect]['enable_plugin']) == True \
                              and not sect in enabled_plugins:
                if not cnf[sect].has_key('provider'):
                    provider = config['app_module']
                else:
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)
    return enabled_plugins
    
def load_plugin(plugin):
    """
    Load a cement plugin.