def get_proxy(agentConfig):
    proxy_settings = {}

    # First we read the proxy configuration from config.cfg
    proxy_host = agentConfig.get('proxy_host')
    if proxy_host is not None:
        proxy_settings['host'] = proxy_host
        try:
            proxy_settings['port'] = int(agentConfig.get('proxy_port', 3128))
        except __HOLE__:
            log.error('Proxy port must be an Integer. Defaulting it to 3128')
            proxy_settings['port'] = 3128

        proxy_settings['user'] = agentConfig.get('proxy_user')
        proxy_settings['password'] = agentConfig.get('proxy_password')
        log.debug("Proxy Settings: %s:*****@%s:%s", proxy_settings['user'],
            proxy_settings['host'], proxy_settings['port'])
        return proxy_settings

    # If no proxy configuration was specified in config.cfg
    # We try to read it from the system settings
    try:
        proxy = getproxies().get('https')
        if proxy is not None:
            parse = urlparse(proxy)
            proxy_settings['host'] = parse.hostname
            proxy_settings['port'] = int(parse.port)
            proxy_settings['user'] = parse.username
            proxy_settings['password'] = parse.password

            log.debug("Proxy Settings: %s:*****@%s:%s", proxy_settings['user'],
                proxy_settings['host'], proxy_settings['port'])
            return proxy_settings

    except Exception, e:
        log.debug("Error while trying to fetch proxy settings using urllib %s."
            "Proxy is probably not set", str(e))

    log.debug("No proxy configured")

    return None
dataset/ETHPy150Open serverdensity/sd-agent/utils/proxy.py/get_proxy