def deserialize_response(msg):
    """
    Deserialize a MyProxy server response

    Returns: integer response, errortext (if any)
    """

    lines = msg.split('\n')

    # get response value
    responselines = [x for x in lines if x.startswith('RESPONSE')]
    responseline = responselines[0]
    response = int(responseline.split('=')[1])

    # get error text
    errortext = ""
    errorlines = [x for x in lines if x.startswith('ERROR')]
    for e in errorlines:
        etext = e.split('=')[1]
        errortext += etext

    return response, errortext