#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright (c) 2012, <NAME>
Description: Shared configuration data
License: MIT (see LICENSE.md for details)
"""

import os, sys, platform, logging.config
from utils import get_config, path_for, tb

try:
    settings
except NameError:
    for host in [platform.node(), 'default']:
        try:
            settings = get_config(path_for(os.path.join('etc','%s.json' % host)))
        except IOError:
            continue
        except Exception as e:
            if sys.stderr.isatty():
                tb = tb()
                print >> sys.stderr, ("Error while loading %(host)s.json: %(tb)s" % locals())
            else:
                log.error("Error while loading %(host)s.json: %(tb)s" % locals())
            sys.exit(2)
        logging.config.dictConfig(dict(settings.logging))
        log = logging.getLogger()
        log.info("Configuration for %s loaded." % host)
        break
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright (c) 2012, <NAME>
Description: Shared configuration data
License: MIT (see LICENSE.md for details)
"""

import os, sys, platform, logging.config
from utils import get_config, path_for, tb

try:
    settings
except NameError:
    for host in [platform.node(), 'default']:
        try:
            settings = get_config(path_for(os.path.join('etc','%s.json' % host)))
        except IOError:
            continue
        except Exception as e:
            if sys.stderr.isatty():
                tb = tb()
                print >> sys.stderr, ("Error while loading %(host)s.json: %(tb)s" % locals())
            else:
                log.error("Error while loading %(host)s.json: %(tb)s" % locals())
            sys.exit(2)
        logging.config.dictConfig(dict(settings.logging))
        log = logging.getLogger()
        log.info("Configuration for %s loaded." % host)
        break
#!/usr/bin/env python # -*- coding: utf-8 -*- Copyright (c) 2012, <NAME> Description: Shared configuration data License: MIT (see LICENSE.md for details)