[PATCH v2 13/16] trivial: Resolve PEP8 issues with 'management'

Damien Lespiau damien.lespiau at intel.com
Sat Aug 29 00:26:08 AEST 2015


On Fri, Aug 21, 2015 at 03:32:17PM +0100, Stephen Finucane wrote:
> Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>

This is not just "trivial" PEP8 fixes. The usage of self.stdout/err
instead of sys.stdout/err probably worth mentioning.

I guess it depends on what Jeremy wants to do here, but in theory you
would need one separate patch for that change.

-- 
Damien

> ---
>  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 = '[<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')
> -- 
> 2.0.0
> 
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork


More information about the Patchwork mailing list