Пример #1
0
def load_conf_from_file(conf_file_path, conf=__conf__):
    """
    Load conf file from: conf_file_path
    """
    if os.path.isfile(conf_file_path) == False:
        raise AgentConfigError(("Missing configuration in {0}"
                                "").format(conf_file_path))
    try:
        content = fileutil.read_file(conf_file_path)
        conf.load(content)
    except IOError as err:
        raise AgentConfigError(("Failed to load conf file:{0}, {1}"
                                "").format(conf_file_path, err))
Пример #2
0
 def load(self, content):
     if not content:
         raise AgentConfigError("Can't not parse empty configuration")
     for line in content.split('\n'):
         if not line.startswith("#") and "=" in line:
             parts = line.split('=')
             if len(parts) < 2:
                 continue
             key = parts[0].strip()
             value = parts[1].split('#')[0].strip("\" ")
             self.values[key] = value if value != "None" else None
Пример #3
0
 def load(self, content):
     if not content:
         raise AgentConfigError("Can't not parse empty configuration")
     for line in content.split('\n'):
         if not line.startswith("#") and "=" in line:
             parts = line.split()[0].split('=')
             value = parts[1].strip("\" ")
             if value != "None":
                 self.values[parts[0]] = value
             else:
                 self.values[parts[0]] = None