Le lundi 27 août 2018 à 21:24:59+0200, Mattia Rizzolo a écrit : > [nm/keyring crashes on 504]
Hey, Here is a rough skeleton of patch. Don't use it as its, it's not tested yet. I'd just like to hear if the idea seems fine with you. It's supposed to rely on django.contrib.messages that seems implemented in deblayout/templates/debian-base.html. Cheers! -- Pierre-Elliott Bécue GPG: 9AE0 4D98 6400 E3B6 7528 F493 0D44 2664 1949 74E2 It's far easier to fight for one's principles than to live up to them.
diff --git a/keyring/models.py b/keyring/models.py index e1ceced..f450fff 100644 --- a/keyring/models.py +++ b/keyring/models.py @@ -63,6 +63,8 @@ class KeyManager(models.Manager): res = requests.get(url) try: res.raise_for_status() + except requests.HTTPError as e: + raise except Exception as e: raise RuntimeError("GET {} failed: {}".format(url, e)) keytext = [] diff --git a/process/views.py b/process/views.py index e27e9ee..f608e2f 100644 --- a/process/views.py +++ b/process/views.py @@ -7,6 +7,7 @@ from django.db import transaction from django import forms, http from django.core.exceptions import PermissionDenied from django.conf import settings +from django.contrib import messages as django_messages from django.urls import reverse, reverse_lazy from collections import OrderedDict from rest_framework import viewsets @@ -414,10 +415,20 @@ class UpdateKeycheck(RequirementMixin, View): key = Key.objects.get_or_download(self.person.fpr) except RuntimeError as e: key = None + + ret_dest = self.requirement.get_absolute_url() if key is not None: - key.update_key() + try: + key.update_key() + except requests.HTTPError as e: + django_messages.add_message( + request, + messages.ERROR, + _("The server met an arror: {}".format(e)), + ) + return redirect(ret_dest) key.update_check_sigs() - return redirect(self.requirement.get_absolute_url()) + return redirect(ret_dest) class DownloadStatements(VisitProcessMixin, View):
signature.asc
Description: PGP signature