From: Magnus Hagander Date: Fri, 28 Jun 2019 12:55:57 +0000 (+0200) Subject: Update exception handling for python 3 X-Git-Url: http://git.postgresql.org/gitweb/static/session/%7B%7Bsession.id%7D%7D-%7B%7Bsession.title%7Cslugify%7D%7D?a=commitdiff_plain;h=f3c0f6dbb0e16cfe2e93aec932d7436afda3fa9d;p=hamn.git Update exception handling for python 3 --- diff --git a/hamnadmin/hamnadmin/mailqueue/admin.py b/hamnadmin/hamnadmin/mailqueue/admin.py index 1f1d671..b63f317 100644 --- a/hamnadmin/hamnadmin/mailqueue/admin.py +++ b/hamnadmin/hamnadmin/mailqueue/admin.py @@ -22,7 +22,7 @@ class QueuedMailAdmin(admin.ModelAdmin): b = p.get_payload(decode=True) if b: return b return "Could not find body" - except Exception, e: + except Exception as e: return "Failed to get body: %s" % e parsed_content.short_description = 'Parsed mail' diff --git a/hamnadmin/hamnadmin/register/forms.py b/hamnadmin/hamnadmin/register/forms.py index da4cb2f..5330c97 100644 --- a/hamnadmin/hamnadmin/register/forms.py +++ b/hamnadmin/hamnadmin/register/forms.py @@ -43,7 +43,7 @@ class BlogEditForm(forms.ModelForm): entries = list(fetcher.parse()) except ParserGotRedirect: raise forms.ValidationError("This URL returns a permanent redirect") - except Exception, e: + except Exception as e: raise forms.ValidationError("Failed to retreive and parse feed: %s" % e) if len(entries) == 0: for m in tracemessages: diff --git a/hamnadmin/hamnadmin/register/management/commands/aggregate_feeds.py b/hamnadmin/hamnadmin/register/management/commands/aggregate_feeds.py index c692a34..ffb5440 100644 --- a/hamnadmin/hamnadmin/register/management/commands/aggregate_feeds.py +++ b/hamnadmin/hamnadmin/register/management/commands/aggregate_feeds.py @@ -224,9 +224,9 @@ class Command(BaseCommand): self.trace("Fetching %s since %s" % (fetcher.feed.feedurl, since)) try: entries = list(fetcher.parse(since)) - except ParserGotRedirect, e: + except ParserGotRedirect as e: return (fetcher.feed, e) - except Exception, e: + except Exception as e: self.stderr.write("Failed to fetch '%s': %s" % (fetcher.feed.feedurl, e)) return (fetcher.feed, e) return (fetcher.feed, entries) diff --git a/hamnadmin/hamnadmin/util/varnish.py b/hamnadmin/hamnadmin/util/varnish.py index e84e51f..c1cd6c1 100644 --- a/hamnadmin/hamnadmin/util/varnish.py +++ b/hamnadmin/hamnadmin/util/varnish.py @@ -13,7 +13,7 @@ def purge_url(url): response = urllib2.urlopen(request, timeout=2) if response.getcode() != 200: raise Exception("Invalid response code %s" % response.getcode()) - except Exception, e: + except Exception as e: raise Exception("Failed to purge '{0}': {1}'".format(url, e)) def purge_root_and_feeds():