avocado.plugins.htmlresult: Redirect browser stderr/stdout to /dev/null

Make sure all brower terminal output is suppressed. In order
to do that, eschew the use of the python module web browser
and use subprocess, executing the utility xdg-open in a subprocess
with stdout/err redirected to /dev/null.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 0bf5efe1
......@@ -19,7 +19,7 @@ import os
import shutil
import sys
import time
import webbrowser
import subprocess
import pystache
......@@ -248,7 +248,15 @@ class HTMLTestResult(TestResult):
if self.args is not None:
if getattr(self.args, 'open_browser'):
webbrowser.open(self.output)
# if possible, put browser in separate process group, so
# keyboard interrupts don't affect browser as well as Python
setsid = getattr(os, 'setsid', None)
if not setsid:
setsid = getattr(os, 'setpgrp', None)
inout = file(os.devnull, "r+")
cmd = ['xdg-open', self.output]
subprocess.Popen(cmd, close_fds=True, stdin=inout, stdout=inout,
stderr=inout, preexec_fn=setsid)
class HTML(plugin.Plugin):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册