Esempio n. 1
0
def initialize(config_file = None):
    """
    Initialize logging module. If _HOME environment variable is set, logging home directory will be _HOME/logs.
    Otherwise, logging home directory will be CurrentDir/logs.
    """
    if not config_file:
        config_file = 'logging.conf'
    logging_paths = get_filepaths_from_pythonpath(config_file)
    flames_home = get_home()
    
    for logging_path in logging_paths:
        logging.config.fileConfig(logging_path, {'flames_home': flames_home})
Esempio n. 2
0
def get_config_parser(conf_name):
    """
    Get U{ConfigParser<http://docs.python.org/2/library/configparser.html>} object by the relative configuration file name.
    The method will search PYTHONPATH to find out where the file is, 
    and create ConfigParser by the absolute file path.
    @param conf_name: A relative configuration file name.
    @type conf_name: C{string}
    @return: A configuration parser.
    @rtype: U{ConfigParser<http://docs.python.org/2/library/configparser.html>}
    """
    flames_home = get_home()

    conf_paths = get_filepaths_from_pythonpath(conf_name)
    parser = SafeConfigParser({"flames_home": flames_home})
    parser.read(conf_paths)

    return parser