Beispiel #1
0
def validate_config(config):
    if not config.has_section('general'):
        die("No [general] section found.")

    twiggy.quickSetup(
        name2level(config.get('general', 'log.level')),
        config.get('general', 'log.file')
    )

    if not config.has_option('general', 'targets'):
        die("No targets= item in [general] found.")

    targets = config.get('general', 'targets')
    targets = [t.strip() for t in targets.split(",")]

    for target in targets:
        if target not in config.sections():
            die("No [%s] section found." % target)

    # Validate each target one by one.
    for target in targets:
        service = config.get(target, 'service')
        if not service:
            die("No 'service' in [%s]" % target)

        if service not in SERVICES:
            die("'%s' in [%s] is not a valid service." % (service, target))

        # Call the service-specific validator
        SERVICES[service].validate_config(config, target)
Beispiel #2
0
def validate_config(config, main_section):
    if not config.has_section(main_section):
        die("No [%s] section found." % main_section)

    twiggy.quickSetup(
        name2level(config.get(main_section, 'log.level')),
        config.get(main_section, 'log.file')
    )

    if not config.has_option(main_section, 'targets'):
        die("No targets= item in [%s] found." % main_section)

    targets = config.get(main_section, 'targets')
    targets = filter(lambda t: len(t), [t.strip() for t in targets.split(",")])

    if not targets:
        die("Empty targets= item in [%s]." % main_section)

    for target in targets:
        if target not in config.sections():
            die("No [%s] section found." % target)

    # Validate each target one by one.
    for target in targets:
        service = config.get(target, 'service')
        if not service:
            die("No 'service' in [%s]" % target)

        if service not in SERVICES:
            die("'%s' in [%s] is not a valid service." % (service, target))

        # Call the service-specific validator
        SERVICES[service].validate_config(config, target)
Beispiel #3
0
def validate_config(config):
    if not config.has_section('general'):
        die("No [general] section found.")

    twiggy.quickSetup(name2level(config.get('general', 'log.level')),
                      config.get('general', 'log.file'))

    if not config.has_option('general', 'targets'):
        die("No targets= item in [general] found.")

    targets = config.get('general', 'targets')
    targets = [t.strip() for t in targets.split(",")]

    for target in targets:
        if target not in config.sections():
            die("No [%s] section found." % target)

    for option in ['bitly.api_user', 'bitly.api_key']:
        if not config.has_option('general', option):
            log.name('config').warning(
                "URLs will not be shortened with bit.ly")

    # Validate each target one by one.
    for target in targets:
        service = config.get(target, 'service')
        if not service:
            die("No 'service' in [%s]" % target)

        if service not in SERVICES:
            die("'%s' in [%s] is not a valid service." % (service, target))

        # Call the service-specific validator
        SERVICES[service].validate_config(config, target)
Beispiel #4
0
def validate_config(config):
    if not config.has_section("general"):
        die("No [general] section found.")

    twiggy.quickSetup(name2level(config.get("general", "log.level")), config.get("general", "log.file"))

    if not config.has_option("general", "targets"):
        die("No targets= item in [general] found.")

    targets = config.get("general", "targets")
    targets = [t.strip() for t in targets.split(",")]

    for target in targets:
        if target not in config.sections():
            die("No [%s] section found." % target)

    for option in ["bitly.api_user", "bitly.api_key"]:
        if not config.has_option("general", option):
            log.name("config").warning("URLs will not be shortened with bit.ly")

    # Validate each target one by one.
    for target in targets:
        service = config.get(target, "service")
        if not service:
            die("No 'service' in [%s]" % target)

        if service not in SERVICES:
            die("'%s' in [%s] is not a valid service." % (service, target))

        # Call the service-specific validator
        SERVICES[service].validate_config(config, target)
 def test_name2level(self):
     assert levels.name2level('debug') is levels.DEBUG
     assert levels.name2level('Debug') is levels.DEBUG
Beispiel #6
0
def test_name2level():
    assert levels.name2level('debug') is levels.DEBUG
    assert levels.name2level('Debug') is levels.DEBUG