Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed mark_defunct_feeds management command.

  • Loading branch information...
commit 9a68d1584bceaca1893011bc5a22905b50996653 1 parent 7d25af4
@jacobian jacobian authored
View
18 django_website/aggregator/management/commands/mark_defunct_feeds.py
@@ -1,21 +1,17 @@
+import socket
import urllib2
from django.core.management.base import BaseCommand
-from django_website.apps.aggregator.models import Feed
+from django_website.aggregator.models import Feed
class Command(BaseCommand):
"""
Mark people with 404'ing feeds as defunct.
"""
def handle(self, *args, **kwargs):
- verbose = kwargs.get('verbosity')
- for f in Feed.objects.all():
+ for f in Feed.objects.filter(is_defunct=False):
try:
r = urllib2.urlopen(f.feed_url, timeout=15)
- except urllib2.HTTPError, e:
- if e.code == 404 or e.code == 500:
- if verbose:
- print "%s on %s; marking defunct" % (e.code, f)
- f.is_defunct = True
- f.save()
- else:
- raise
+ except (urllib2.HTTPError, urllib2.URLError, socket.timeout), e:
+ print "%s on '%s'; marking defunct" % (e, f)
+ f.is_defunct = True
+ f.save()
Please sign in to comment.
Something went wrong with that request. Please try again.