Exemplo n.º 1
0
def _check_response_code(response, codes):
    """
    Throws an exception if the http response is not expected. Can check single
    integer or list of valid responses.

    Example usage:
        >>> r = api.get_workspace("broad-firecloud-testing", "Fake-Bucket")
        >>> _check_response_code(r, 200)
         ... FireCloudServerError ...
    """
    if type(codes) == int:
        codes = [codes]
    if response.status_code not in codes:
        raise FireCloudServerError(response.status_code, response.content)
Exemplo n.º 2
0
def check_fapi_response(response, success_code):
    if response.status_code != success_code:
        print(response.content)
        raise FireCloudServerError(response.status_code, response.content)