def get_proxy_handler(proxyhost, proxyport, proxyuser, proxypass):
    """
    Get a configured handler for a proxy

    :param proxyhost: proxy hostname, str
    :param proxyport: proxy port, int
    :param proxyuser: proxy username, str
    :param proxypass: proxy password, str
    :return: list of handlers
    """
    for param in proxyhost, proxyport, proxyuser, proxypass:
        if param is None:
            return []
    assert type( proxyport ) == int, "Proxy port should be an int, got %s" % repr( proxyport )
    assert type( proxypass ) == str, "Proxy password should be a sting, got %s" % repr( proxypass )
    assert type( proxyuser ) == str, "Proxy username should be a string, got %s" % repr( proxyuser )

    proxy_spec = { 'http': 'http://%s:%i/' % (proxyhost, proxyport),
                   'https': 'http://%s:%i/' % (proxyhost, proxyport) }

    proxy_handler = urllib2.ProxyHandler( proxy_spec )
    proxy_auth_handler = urllib2.HTTPBasicAuthHandler()
    proxy_auth_handler.add_password( None, proxyhost, proxyuser, proxypass )
    return [proxy_handler, proxy_auth_handler]
dataset/ETHPy150Open ramonvanalteren/jenkinsapi/jenkinsapi/utils/urlopener.py/get_proxy_handler/original