[PATCH 1/2] retag: Don't use BaseCommand's stdin/stdout wrappers

Damien Lespiau damien.lespiau at intel.com
Mon Nov 9 21:54:00 AEDT 2015


On Mon, Nov 09, 2015 at 02:29:57AM +0000, Finucane, Stephen wrote:
> > @@ -38,6 +39,6 @@ class Command(BaseCommand):
> >          for i, patch in enumerate(query.iterator()):
> >              patch.refresh_tag_counts()
> >              if (i % 10) == 0 or i == count:
> > -                self.stdout.write('%06d/%06d\r' % (i, count))
> > -                self.stdout.flush()
> > -        self.stderr.write('\ndone\n')
> > +                sys.stdout.write('%06d/%06d\r' % (i, count))
> > +                sys.stdout.flush()
> > +        sys.stdout.write('\ndone\n')
> 
> Agree on stderr - > stdout, however Django documentation advises we
> use the BaseCommand versions hence my original change:
> 
>   https://docs.djangoproject.com/en/1.8/howto/custom-management-commands/#management-commands-output
> 
> Can you just drop the trailing newline instead?

You're missing the point:

> > I noted that it wasn't all trivial changes. And indeed using the
> > stdin/stdout wrappers change the intended behaviour by adding a new
> > line.

	self.stdout.write('%06d/%06d\r' % (i, count))

That will append a new line, where the intention was to have a progress
indicator on one line ('\r').

-- 
Damien


More information about the Patchwork mailing list