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

Damien Lespiau damien.lespiau at intel.com
Sun Nov 8 03:49:25 AEDT 2015


In:

    commit 544b8bbcc7ec80d94c96f181886c51b177530a95
    Author: Stephen Finucane <stephen.finucane at intel.com>
    Date:   Fri Aug 21 15:32:17 2015 +0100

        trivial: Resolve PEP8 issues with 'management'

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.

The stderr wrapper also colors the line in red. Changed the last message
to be printed on stdout, seems more logical.

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 patchwork/management/commands/retag.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/patchwork/management/commands/retag.py b/patchwork/management/commands/retag.py
index f92648b..e67d099 100644
--- a/patchwork/management/commands/retag.py
+++ b/patchwork/management/commands/retag.py
@@ -17,6 +17,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import sys
 from django.core.management.base import BaseCommand
 from patchwork.models import Patch
 
@@ -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')
-- 
2.4.3



More information about the Patchwork mailing list