[Piglit] [PATCH 1/4] framework: hide stderr messages from xz binary

Dylan Baker baker.dylan.c at gmail.com
Wed Jul 22 18:11:20 PDT 2015


When compressing, if there is an error it will be caught and handled by
the framework, with a nice error message. Don't allow xz to spam stderr
as well.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/backends/compression.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/framework/backends/compression.py b/framework/backends/compression.py
index b26c4d7..6f867be 100644
--- a/framework/backends/compression.py
+++ b/framework/backends/compression.py
@@ -125,7 +125,10 @@ except ImportError:
                     yield f
 
                 try:
-                    subprocess.check_call(['xz', '--compress', '-9', filename])
+                    with open(os.devnull, 'w') as null:
+                        subprocess.check_call(
+                            ['xz', '--compress', '-9', filename],
+                            stderr=null)
                 except OSError as e:
                     if e.errno == errno.ENOENT:
                         raise exceptions.PiglitFatalError(
@@ -146,8 +149,10 @@ except ImportError:
                     filename = '{}.xz'.format(filename)
 
                 try:
-                    string = subprocess.check_output(
-                        ['xz', '--decompress', '--stdout', filename])
+                    with open(os.devnull, 'w') as null:
+                        string = subprocess.check_output(
+                            ['xz', '--decompress', '--stdout', filename],
+                            stderr=null)
                 except OSError as e:
                     if e.errno == errno.ENOENT:
                         raise exceptions.PiglitFatalError(
-- 
2.4.6



More information about the Piglit mailing list