Browse files

Fixed mark_defunct_feeds management command.

  • Loading branch information...
1 parent 7d25af4 commit 9a68d1584bceaca1893011bc5a22905b50996653 @jacobian jacobian committed Jun 27, 2011
Showing with 7 additions and 11 deletions.
  1. +7 −11 django_website/aggregator/management/commands/mark_defunct_feeds.py
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()

0 comments on commit 9a68d15

Please sign in to comment.