def post_to_server(post_data, config, auth=None):
    """Send the given post_data to the pypi server.

    Parameters
    ----------
    post_data: dict
        Usually the dict returned by build_post_data
    config: object
        A PyPIConfig instance
    auth: object or None
        HTTP authentification object.

    Returns
    -------
    code: int
        HTTP status code
    msg: str
        Message received back from the server
    """
    content_type, body = encode_multipart(post_data.items(), [])

    # build the Request
    headers = {
        'Content-type': content_type,
        'Content-length': str(len(body))
    }
    req = Request(config.repository, body, headers)

    # handle HTTP and include the Basic Auth handler
    opener = build_opener(HTTPBasicAuthHandler(password_mgr=auth))
    try:
        opener.open(req)
    except __HOLE__:
        e = extract_exception()
        code, msg = e.code, e.msg
    except URLError:
        e = extract_exception()
        code, msg = 500, str(e)
    else:
        code, msg = 200, 'OK'

    return code, msg
dataset/ETHPy150Open cournape/Bento/bento/pypi/register_utils.py/post_to_server