How to use the flowclient.errors function in flowclient

To help you get started, we’ve selected a few flowclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Flowminder / FlowKit / flowclient / flowclient / async_client.py View on Github external
Returns
    -------
    pandas.DataFrame
        Dataframe containing the result

    """

    response = await connection.get_url(route=location)
    if response.status_code != 200:
        try:
            msg = response.json()["msg"]
            more_info = f" Reason: {msg}"
        except KeyError:
            more_info = ""
        raise flowclient.errors.FlowclientConnectionError(
            f"Could not get result. API returned with status code: {response.status_code}.{more_info}"
        )
    result = response.json()
    logger.info(f"Got {connection.url}/api/{connection.api_version}/{location}")
    return pd.DataFrame.from_records(result["query_result"])
github Flowminder / FlowKit / flowclient / flowclient / async_client.py View on Github external
if response does not contain the query status
    """
    try:
        ready, reply = await query_is_ready(connection=connection, query_id=query_id)
    except FileNotFoundError:
        # Can't distinguish 'known', 'cancelled', 'resetting' and 'awol' from the error,
        # so return generic 'not_running' status.
        return "not_running"

    if ready:
        return "completed"
    else:
        try:
            return reply.json()["status"]
        except (KeyError, TypeError):
            raise flowclient.errors.FlowclientConnectionError(f"No status reported.")