]> git.ozlabs.org Git - patchwork/commitdiff
trivial: Resolve PEP8 issues with 'management'
authorStephen Finucane <stephen.finucane@intel.com>
Fri, 21 Aug 2015 14:32:17 +0000 (15:32 +0100)
committerDamien Lespiau <damien.lespiau@intel.com>
Thu, 17 Sep 2015 16:58:10 +0000 (17:58 +0100)
(Added by Damien) This also moves from sys.stdout/sys.stderr to
self.stdout/self.stderr as adviced by the Django documentation.

Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
patchwork/management/commands/cron.py
patchwork/management/commands/retag.py

index 308b4b26ea7b6229d1de3fad510b19053f9a8323..7c00ea36d72018e2e1dae69f918e83adf03c26d6 100755 (executable)
@@ -1,14 +1,15 @@
-from django.core.management.base import BaseCommand, CommandError
+from django.core.management.base import BaseCommand
 from patchwork.utils import send_notifications, do_expiry
 
+
 class Command(BaseCommand):
-    help = ('Run periodic patchwork functions: send notifications and ' 
+    help = ('Run periodic patchwork functions: send notifications and '
             'expire unused users')
 
     def handle(self, *args, **kwargs):
         errors = send_notifications()
         for (recipient, error) in errors:
             self.stderr.write("Failed sending to %s: %s" %
-                                (recipient.email, error))
+                              (recipient.email, error))
 
         do_expiry()
index 677d1d6532855be629043e553d3478bf199275e3..96b16207b22493f6ddfd898d3718b1cc76ec9b92 100644 (file)
@@ -1,28 +1,24 @@
-
-from django.core.management.base import BaseCommand, CommandError
+from django.core.management.base import BaseCommand
 from patchwork.models import Patch
-import sys
+
 
 class Command(BaseCommand):
     help = 'Update the tag (Ack/Review/Test) counts on existing patches'
     args = '[<patch_id>...]'
 
     def handle(self, *args, **options):
-
-        qs = Patch.objects
+        query = Patch.objects
 
         if args:
-            qs = qs.filter(id__in=args)
+            query = query.filter(id__in=args)
         else:
-            qs = qs.all()
+            query = query.all()
 
-        count = qs.count()
-        i = 0
+        count = query.count()
 
-        for patch in qs.iterator():
+        for i, patch in enumerate(query.iterator()):
             patch.refresh_tag_counts()
-            i += 1
             if (i % 10) == 0 or i == count:
-                sys.stdout.write('%06d/%06d\r' % (i, count))
-                sys.stdout.flush()
-        sys.stderr.write('\ndone\n')
+                self.stdout.write('%06d/%06d\r' % (i, count))
+                self.stdout.flush()
+        self.stderr.write('\ndone\n')