#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.core.management.base import BaseCommand

from planet.management.commands import process_feed
from planet.models import Feed
from planet.signals import feeds_updated


class Command(BaseCommand):
    """
    Command to add a complete blog feed to our db.

    Usage:

    ./manage.py add_feed <feed_url>
    """
    def handle(self, *args, **options):
        for feed_url in Feed.site_objects.all().values_list("url", flat=True):
            # process feed in create-mode
            process_feed(feed_url, create=False)
        feeds_updated.send(sender=self, instance=self)
                
@@ -39,17 +39,46 @@
 f-8 -*-%0A
+from datetime import datetime
 %0A
-
 from dja
@@ -432,16 +432,75 @@
 tions):%0A
+        new_posts_count = 0%0A        start = datetime.now()%0A
         
@@ -623,16 +623,35 @@
         
+ new_posts_count +=
  process
@@ -680,16 +680,135 @@
 =False)%0A
+        delta = datetime.now() - start%0A        print %22Added %25s posts in %25d seconds%22 %25 (new_posts_count, delta.seconds)%0A
         
@@ -858,20 +858,5 @@
 lf)%0A
-                
+%0A

Print total number of posts added and total elapsed time