Exemplo n.º 1
0
            if not value:
                config[env_key] = environ[env_key]

    except KeyError as e:
        """ Throw an error if a setting is missing """
        print "ERR MSG: {}".format(e.message)
        print ("Some of your settings aren't in the environment."
               "You probably need to run:"
               "\n\n\tsource config/<your settings file>")
        exit(1)

else:  # use consul
    kv = Consul().kv  # initalize client to KV store

    for consul_key, config_key in consul_configurations:
        _, tmp = kv.get("density/{}".format(consul_key))
        val = tmp.get('Value')
        config[config_key] = val
        if not val:
            raise Exception(("no value found in Consul for key "
                             "density/{}").format(consul_key))

    # mail settings
    config.update({
        'MAIL_SERVER': 'smtp.googlemail.com',
        'MAIL_PORT': 465,
        'MAIL_USE_SSL': True,
        'MAIL_USE_TLS': False,
        'MAIL_DEFAULT_SENDER': '*****@*****.**',
        'MAIL_USERNAME': '******',
        'MAIL_PASSWORD': kv.get('density/mail_password')[1]
Exemplo n.º 2
0
    'MONGO_DATABASE': 'eventum',

    # Logging configurations
    'LOG_FILE_MAX_SIZE': '256',
    'APP_LOG_NAME': 'app.log',
    'WERKZEUG_LOG_NAME': 'werkzeug.log',
}

from consul import Consul
kv = Consul().kv  # initalize client to KV store

# get values from Consul and set the corresponding config variable to the
# value retrieved from Consul.
for key, value in config.iteritems():
    try:
        _, consul_value = kv.get(("adi-website/{}").format(key.lower()))
    except requests.ConnectionError:
        raise Exception('Failed to connect to Consul.  You probably need to '
                        'run: \n\n\t./config/run_consul.sh')

    # We have a good value in Consul
    if consul_value and consul_value.get('Value'):
        config[key] = consul_value.get('Value')
        continue

    # We can use the default value if it's not None
    if value is not None:
        continue

    # Fail if there is value cannot be found or it is an empty string
    raise Exception(("No default value found in Consul for key "
Exemplo n.º 3
0
            if not value:
                config[env_key] = environ[env_key]

    except KeyError as e:
        """ Throw an error if a setting is missing """
        print "ERR MSG: {}".format(e.message)
        print ("Some of your settings aren't in the environment."
               "You probably need to run:"
               "\n\n\tsource config/<your settings file>")
        exit(1)

else:  # use consul
    kv = Consul().kv  # initalize client to KV store

    for consul_key, config_key in consul_configurations:
        _, tmp = kv.get("density/{}".format(consul_key))
        val = tmp.get('Value')
        config[config_key] = val
        if not val:
            raise Exception(("no value found in Consul for key "
                             "density/{}").format(consul_key))

    # mail settings
    MAIL_SERVER = 'smtp.gmail.com'
    MAIL_PORT = 465
    MAIL_USE_SSL = True
    MAIL_USE_TLS = False
    MAIL_DEFAULT_SENDER = '*****@*****.**'
    MAIL_USERNAME = '******'
    _, MAIL_PASSWORD = kv.get('density/mail_password')
    if not MAIL_PASSWORD:
Exemplo n.º 4
0
    'MONGO_DATABASE': 'eventum',

    # Logging configurations
    'LOG_FILE_MAX_SIZE': '256',
    'APP_LOG_NAME': 'app.log',
    'WERKZEUG_LOG_NAME': 'werkzeug.log',
}

from consul import Consul
kv = Consul().kv  # initalize client to KV store

# get values from Consul and set the corresponding config variable to the
# value retrieved from Consul.
for key, value in config.iteritems():
    try:
        _, consul_value = kv.get(("adi-website/{}").format(key.lower()))
    except requests.ConnectionError:
        raise Exception('Failed to connect to Consul.  You probably need to '
                        'run: \n\n\t./config/run_consul.sh')

    # We have a good value in Consul
    if consul_value and consul_value.get('Value'):
        config[key] = consul_value.get('Value')
        continue

    # We can use the default value if it's not None
    if value is not None:
        continue

    # Fail if there is value cannot be found or it is an empty string
    raise Exception(("No default value found in Consul for key "
Exemplo n.º 5
0
                config[env_key] = environ[env_key]

    except KeyError as e:
        """ Throw an error if a setting is missing """
        print "ERR MSG: {}".format(e.message)
        print(
            "Some of your settings aren't in the environment."
            "You probably need to run:"
            "\n\n\tsource config/<your settings file>")
        exit(1)

else:  # use consul
    kv = Consul().kv  # initalize client to KV store

    for consul_key, config_key in consul_configurations:
        _, tmp = kv.get("density/{}".format(consul_key))
        val = tmp.get('Value')
        config[config_key] = val
        if not val:
            raise Exception(("no value found in Consul for key "
                             "density/{}").format(consul_key))

    # mail settings
    config['MAIL_SERVER'] = 'smtp.gmail.com'
    config['MAIL_PORT'] = 465
    config['MAIL_USE_SSL'] = True
    config['MAIL_USE_TLS'] = False
    config['MAIL_DEFAULT_SENDER'] = '*****@*****.**'
    config['MAIL_USERNAME'] = '******'

    # Get mail password
Exemplo n.º 6
0
            if not value:
                config[env_key] = environ[env_key]

    except KeyError as e:
        """ Throw an error if a setting is missing """
        print "ERR MSG: {}".format(e.message)
        print ("Some of your settings aren't in the environment."
               "You probably need to run:"
               "\n\n\tsource config/<your settings file>")
        exit(1)

else:  # use consul
    kv = Consul().kv  # initalize client to KV store

    for consul_key, config_key in consul_configurations:
        _, tmp = kv.get("density/{}".format(consul_key))
        val = tmp.get('Value')
        config[config_key] = val
        if not val:
            raise Exception(("no value found in Consul for key "
                             "density/{}").format(consul_key))

    # mail settings
    config['MAIL_SERVER'] = 'smtp.gmail.com'
    config['MAIL_PORT'] = 465
    config['MAIL_USE_SSL'] = True
    config['MAIL_USE_TLS'] = False
    config['MAIL_DEFAULT_SENDER'] = '*****@*****.**'
    config['MAIL_USERNAME'] = '******'

    # Get mail password