app/grandchallenge/challenges/tasks.py
def check_external_challenge_urls():
    """
    Checks that all external challenge urls are reachable.

    Emails the managers if any of the challenges are not.
    """
    challenges = ExternalChallenge.objects.filter(hidden=False)
    errors = []

    for challenge in challenges:
        try:
            url = challenge.homepage
            if not url.startswith("http"):
                url = "http://" + url
            r = get(url, timeout=60)
            # raise an exception when we receive a http error (e.g., 404)
            r.raise_for_status()
        except exceptions.RequestException as err:
            update_url = reverse(
                "challenges:external-update",
                kwargs={"short_name": challenge.short_name},
            )
            errors.append(
                f"Error when trying to access '{challenge}': {err}. You can "
                f"update it here: {update_url}"
            )

    if errors:
        mail_managers(
            subject=f"Unreachable external challenges ({len(errors)})",
            message="\n\n".join(errors),
        )

    Checks that all external challenge urls are reachable.

    Emails the managers if any of the challenges are not.
    
Checks that all external challenge urls are reachable.
Emails the managers if any of the challenges are not.
Checks that all external challenge urls are reachable . Emails the managers if any of the challenges are not .
def check_external_challenge_urls():
    challenges = ExternalChallenge.objects.filter(hidden=False)
    errors = []
    for challenge in challenges:
        try:
            url = challenge.homepage
            if not url.startswith("http"):
                url = "http://" + url
            r = get(url, timeout=60)
            r.raise_for_status()
        except exceptions.RequestException as err:
            update_url = reverse(
                "challenges:external-update",
                kwargs={"short_name": challenge.short_name},
            )
            errors.append(
                f"Error when trying to access '{challenge}': {err}. You can "
                f"update it here: {update_url}"
            )
    if errors:
        mail_managers(
            subject=f"Unreachable external challenges ({len(errors)})",
            message="\n\n".join(errors),
        )
def check_external_challenge_urls ( ) : challenges = ExternalChallenge . objects . filter ( hidden = False ) errors = [ ] for challenge in challenges : try : url = challenge . homepage if not url . startswith ( "http" ) : url = "http://" + url r = get ( url , timeout = 60 ) r . raise_for_status ( ) except exceptions . RequestException as err : update_url = reverse ( "challenges:external-update" , kwargs = { "short_name" : challenge . short_name } , ) errors . append ( f"Error when trying to access '{challenge}': {err}. You can " f"update it here: {update_url}" ) if errors : mail_managers ( subject = f"Unreachable external challenges ({len(errors)})" , message = "\n\n" . join ( errors ) , )
Checks that all external challenge urls are reachable.
Checks that all external challenge urls are reachable .
"""
    Checks that all external challenge urls are reachable.

    Emails the managers if any of the challenges are not.
    """ # raise an exception when we receive a http error (e.g., 404)