How to use the check50.__main__.RemoteCheckError function in check50

To help you get started, we’ve selected a few check50 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 cs50 / check50 / check50 / __main__.py View on Github external
if res.status_code == 200 and results["received_at"] is not None:
            break
        time.sleep(sleep)
    else:
        # Terminate if no response
        raise internal.Error(
            _("check50 is taking longer than normal!\n"
              "See https://submit.cs50.io/check50/{} for more detail").format(commit_hash))


    if not results["check50"]:
        raise RemoteCheckError(results)

    if "error" in results["check50"]:
        raise RemoteCheckError(results["check50"])


    # TODO: Should probably check payload["version"] here to make sure major version is same as __version__
    # (otherwise we may not be able to parse results)
    return results["tag_hash"], {
        "slug": results["check50"]["slug"],
        "results": results["check50"]["results"],
        "version": results["check50"]["version"]
    }
github cs50 / check50 / check50 / __main__.py View on Github external
def await_results(commit_hash, slug, pings=45, sleep=2):
    """
    Ping {url} until it returns a results payload, timing out after
    {pings} pings and waiting {sleep} seconds between pings.
    """

    for _i in range(pings):
        # Query for check results.
        res = requests.get(f"https://submit.cs50.io/api/results/check50", params={"commit_hash": commit_hash, "slug": slug})
        results = res.json()

        if res.status_code not in [404, 200]:
            raise RemoteCheckError(results)

        if res.status_code == 200 and results["received_at"] is not None:
            break
        time.sleep(sleep)
    else:
        # Terminate if no response
        raise internal.Error(
            _("check50 is taking longer than normal!\n"
              "See https://submit.cs50.io/check50/{} for more detail").format(commit_hash))


    if not results["check50"]:
        raise RemoteCheckError(results)

    if "error" in results["check50"]:
        raise RemoteCheckError(results["check50"])