[PATCH 10/11] management: Resolve some issues with the commands
Damien Lespiau
damien.lespiau at intel.com
Wed Aug 19 23:56:08 AEST 2015
On Tue, Jun 30, 2015 at 09:52:08AM +0100, Stephen Finucane wrote:
> There were a number of bugs in the two commands, due to things like
> missing imports. Remove unused code and fix the remaining bugs.
>
> In addition, add license headers.
All that sounds like like it should have been multiple patches, esp.
explaining the bugs it fixes.
--
Damien
> Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
> ---
> patchwork/management/commands/cron.py | 30 ++++++++++++++++++-------
> patchwork/management/commands/retag.py | 40 ++++++++++++++++++++++++----------
> 2 files changed, 51 insertions(+), 19 deletions(-)
>
> diff --git a/patchwork/management/commands/cron.py b/patchwork/management/commands/cron.py
> index 6217e75..0367945 100755
> --- a/patchwork/management/commands/cron.py
> +++ b/patchwork/management/commands/cron.py
> @@ -1,20 +1,34 @@
> -#!/usr/bin/env python
> +# Patchwork - automated patch tracking system
> +# Copyright (C) 2015 Jeremy Kerr <jk at ozlabs.org>
> +#
> +# This file is part of the Patchwork package.
> +#
> +# Patchwork is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# Patchwork is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with Patchwork; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>
> -from django.core.management.base import BaseCommand, CommandError
> +from django.core.management.base import BaseCommand
> from patchwork.utils import send_notifications, do_expiry
>
> +
Why this new line addition? That's typically the things people don't
want to see when reviewing diffs.
> 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, ex))
> + (recipient.email, error))
>
> do_expiry()
> -
> -if __name__ == '__main__':
> - sys.exit(main(sys.argv))
> -
> diff --git a/patchwork/management/commands/retag.py b/patchwork/management/commands/retag.py
> index e07594a..683f9c5 100644
> --- a/patchwork/management/commands/retag.py
> +++ b/patchwork/management/commands/retag.py
> @@ -1,7 +1,25 @@
> +# Patchwork - automated patch tracking system
> +# Copyright (C) 2015 Jeremy Kerr <jk at ozlabs.org>
> +#
> +# This file is part of the Patchwork package.
> +#
> +# Patchwork is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# Patchwork is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with Patchwork; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>
> -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'
> @@ -9,18 +27,18 @@ class Command(BaseCommand):
>
> 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:
> + 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