Exemplo n.º 1
0
def setconfpath(confpath):
    """Set the directory of the conf file."""
    global CONF_PATH
    CONF_PATH = confpath
    config.set_option('CONF_PATH', confpath)
Exemplo n.º 2
0
except:
    pass

# set options
if conf.has_section('SYS'):
    # get user defined values for timeouts
    URLOPEN_TIMEOUT = float(conf.get('SYS', 'URLOPEN_TIMEOUT'))
    THREADS_TIMEOUT = float(conf.get('SYS', 'THREADS_TIMEOUT'))
    # URLOPEN_TIMEOUT is used by webservice.py and is a number
    config.seturlopentimeout(URLOPEN_TIMEOUT)
    # THREADS_TIMEOUT is used by vias.py and is a number
    config.setthreadstimeout(THREADS_TIMEOUT)
    # LOAD_METADATA_PLUGINS
    LOAD_METADATA_PLUGINS = bool(
        conf.get('SYS', 'LOAD_METADATA_PLUGINS') == 'True')
    config.set_option('LOAD_METADATA_PLUGINS', LOAD_METADATA_PLUGINS)
    # LOAD_FORMATTER_PLUGINS
    LOAD_FORMATTER_PLUGINS = bool(
        conf.get('SYS', 'LOAD_FORMATTER_PLUGINS') == 'True')
    config.set_option('LOAD_FORMATTER_PLUGINS', LOAD_FORMATTER_PLUGINS)

# only now we can import registry!
# pylint: disable=wrong-import-position
from isbnlib import registry

if conf.has_section('SERVICES'):
    for o, v in conf.items('SERVICES'):
        if o.upper() == 'DEFAULT_SERVICE':
            registry.setdefaultservice(v)
            continue
        if 'api_key' in o:  # pragma: no cover
Exemplo n.º 3
0
def setconfpath(confpath):
    """Set the directory of the conf file."""
    global CONF_PATH
    CONF_PATH = confpath
    config.set_option('CONF_PATH', confpath)
Exemplo n.º 4
0
# set options
if conf.has_section('SYS'):
    # get user defined values for timeouts
    URLOPEN_TIMEOUT = float(conf.get('SYS', 'URLOPEN_TIMEOUT'))
    THREADS_TIMEOUT = float(conf.get('SYS', 'THREADS_TIMEOUT'))

if conf.has_section('SERVICES'):
    for o, v in conf.items('SERVICES'):
        if o.upper() == 'DEFAULT_SERVICE':
            registry.setdefaultservice(v)
            continue
        if 'api_key' in o:  # pragma: no cover
            name = o[:-8]
            config.add_apikey(name, v)
        else:
            config.set_option(o.upper(), v)

if conf.has_section('MISC'):  # pragma: no cover
    for o, v in conf.items('MISC'):
        config.set_option(o.upper(), v)

if conf.has_section('MODULES'):  # pragma: no cover
    for o, v in conf.items('MODULES'):
        config.set_option(o.upper(), v)

# URLOPEN_TIMEOUT is used by webservice.py
config.seturlopentimeout(URLOPEN_TIMEOUT)

# THREADS_TIMEOUT is used by vias.py
config.setthreadstimeout(THREADS_TIMEOUT)
Exemplo n.º 5
0
# set options
if conf.has_section('SYS'):
    # get user defined values for timeouts
    SOCKETS_TIMEOUT = float(conf.get('SYS', 'SOCKETS_TIMEOUT'))
    THREADS_TIMEOUT = float(conf.get('SYS', 'THREADS_TIMEOUT'))

if conf.has_section('SERVICES'):
    for o, v in conf.items('SERVICES'):
        if o.upper() == 'DEFAULT_SERVICE':
            registry.setdefaultservice(v)
            continue
        if 'api_key' in o:       # pragma: no cover
            name = o[:-8]
            config.add_apikey(name, v)
        else:
            config.set_option(o.upper(), v)

if conf.has_section('MISC'):     # pragma: no cover
    for o, v in conf.items('MISC'):
        config.set_option(o.upper(), v)

if conf.has_section('MODULES'):  # pragma: no cover
    for o, v in conf.items('MODULES'):
        config.set_option(o.upper(), v)

if conf.has_section('PLUGINS'):  # pragma: no cover
    for o, v in conf.items('PLUGINS'):
        path = v if '/' in v or '\\' in v else plugins_path
        try:
            plugin = registry.load_plugin(v, path)
            if plugin: