def GetAutoUpdatingConfigFile(conf_file):
  """Get the latest copy of the config file"""

  local_config = _ReadConfigFile(conf_file)
  download_latest = int(local_config.get('config', 'download_latest'))
  local_version = int(local_config.get('config', 'version'))

  if download_latest == 0:
    return _ExpandConfigSections(local_config)

  h = httplib2.Http(tempfile.gettempdir(), timeout=10)
  url = '%s/%s' % (TRUNK_URL, conf_file)
  content = None
  try:
    _, content = h.request(url, 'GET')
    remote_config = ConfigParser.ConfigParser()
  except:
    print '* Unable to fetch remote %s: %s' % (conf_file, util.GetLastExceptionString())
    return _ExpandConfigSections(local_config)

  if content and '[config]' in content:
    fp = StringIO.StringIO(content)
    try:
      remote_config.readfp(fp)
    except:
      print '* Unable to read remote %s: %s' % (conf_file, util.GetLastExceptionString())
      return _ExpandConfigSections(local_config)

  if remote_config and remote_config.has_section('config') and int(remote_config.get('config', 'version')) > local_version:
    print '- Using %s' % url
    return _ExpandConfigSections(remote_config)
  else:
    return _ExpandConfigSections(local_config)
dataset/ETHPy150Open catap/namebench/libnamebench/config.py/GetAutoUpdatingConfigFile/original