[diffoscope] 06/08: comparators: utils: command: adds STDERR_MAX_LINES back

Juliana Oliveira jwnx-guest at moszumanska.debian.org
Wed Jan 31 16:51:32 CET 2018


This is an automated email from the git hooks/post-receive script.

jwnx-guest pushed a commit to branch jwnx_subprocess_merge
in repository diffoscope.

commit 467df402444762cfc746a77344e4bb31dab48a74
Author: Juliana Oliveira <juliana.orod at gmail.com>
Date:   Wed Jan 24 09:44:04 2018 -0200

    comparators: utils: command: adds STDERR_MAX_LINES back
    
    Signed-off-by: Juliana Oliveira <juliana.orod at gmail.com>
---
 diffoscope/comparators/utils/command.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/diffoscope/comparators/utils/command.py b/diffoscope/comparators/utils/command.py
index f2c8b5a..e639df1 100644
--- a/diffoscope/comparators/utils/command.py
+++ b/diffoscope/comparators/utils/command.py
@@ -49,6 +49,8 @@ class Command(object, metaclass=abc.ABCMeta):
                                        stderr=subprocess.PIPE)
 
 
+        self.stderr = self._read_stderr()
+
     @property
     def path(self):
         return self._path
@@ -81,20 +83,21 @@ class Command(object, metaclass=abc.ABCMeta):
 
     MAX_STDERR_LINES = 50
 
-    # TODO: Implement MAX_STDERR_LINES somewhere
     def _read_stderr(self):
-        pass
+        buf = ""
+        line_counter = 0
+        for line in self._process.stderr.splitlines(True):
+          line_counter += 1
+          if line_counter <= Command.MAX_STDERR_LINES:
+              buf += line.decode('utf-8', errors='replace')
+        if line_counter > Command.MAX_STDERR_LINES:
+          buf += '[ {} lines ignored ]\n'.format(line_counter - Command.MAX_STDERR_LINES)
 
-    def _stderr_reader(self):
-        pass
+        return buf
 
     @property
     def stderr_content(self):
-        return self._process.stderr.decode('utf-8', errors='replace')
-
-    @property
-    def stderr(self):
-        return self._process.stderr
+        return self.stderr
 
     @property
     def returncode(self):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list