From patchwork Fri Aug 21 14:32:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 509507 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2E77C1402A9 for ; Sat, 22 Aug 2015 00:34:47 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 125901A0228 for ; Sat, 22 Aug 2015 00:34:47 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lists.ozlabs.org (Postfix) with ESMTP id D6D481A0102 for ; Sat, 22 Aug 2015 00:32:35 +1000 (AEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 21 Aug 2015 07:32:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,722,1432623600"; d="scan'208";a="752918541" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 21 Aug 2015 07:32:30 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t7LEWUTf007174; Fri, 21 Aug 2015 15:32:30 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t7LEWUoB010857; Fri, 21 Aug 2015 15:32:30 +0100 Received: (from sfinucan@localhost) by sivswdev01.ir.intel.com with id t7LEWUQS010851; Fri, 21 Aug 2015 15:32:30 +0100 From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v2 13/16] trivial: Resolve PEP8 issues with 'management' Date: Fri, 21 Aug 2015 15:32:17 +0100 Message-Id: <1440167540-8751-14-git-send-email-stephen.finucane@intel.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1440167540-8751-1-git-send-email-stephen.finucane@intel.com> References: <1440167540-8751-1-git-send-email-stephen.finucane@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Signed-off-by: Stephen Finucane --- patchwork/management/commands/cron.py | 7 ++++--- patchwork/management/commands/retag.py | 24 ++++++++++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/patchwork/management/commands/cron.py b/patchwork/management/commands/cron.py index 308b4b2..7c00ea3 100755 --- a/patchwork/management/commands/cron.py +++ b/patchwork/management/commands/cron.py @@ -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() diff --git a/patchwork/management/commands/retag.py b/patchwork/management/commands/retag.py index 677d1d6..96b1620 100644 --- a/patchwork/management/commands/retag.py +++ b/patchwork/management/commands/retag.py @@ -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 = '[...]' 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')