Add nicer defaults to run_sync_command
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/fca61380 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/fca61380 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/fca61380 Branch: refs/heads/master Commit: fca61380f2a82874b2686c151b3ad94b49fe99dd Parents: 9362814 Author: Thomas Jackson <[email protected]> Authored: Thu Jan 22 17:11:08 2015 -0800 Committer: Thomas Jackson <[email protected]> Committed: Thu Jan 22 17:14:05 2015 -0800 ---------------------------------------------------------------------- tsqa/environment.py | 6 ++++-- tsqa/utils.py | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/fca61380/tsqa/environment.py ---------------------------------------------------------------------- diff --git a/tsqa/environment.py b/tsqa/environment.py index 8cf5291..0faad5e 100644 --- a/tsqa/environment.py +++ b/tsqa/environment.py @@ -210,8 +210,10 @@ class Layout: already have installed. """ layout = Layout(None) - proc = subprocess.Popen(path, shell=False, stderr=open('/dev/null'), stdout=subprocess.PIPE) - stdout, _ = proc.communicate() + stdout, _ = tsqa.utils.run_sync_command(path, + shell=False, + stdout=subprocess.PIPE, + ) for line in stdout.splitlines(): key, val = line.split(': ', 1) setattr(layout, key.lower(), val) http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/fca61380/tsqa/utils.py ---------------------------------------------------------------------- diff --git a/tsqa/utils.py b/tsqa/utils.py index 0baaca9..a12329a 100644 --- a/tsqa/utils.py +++ b/tsqa/utils.py @@ -87,6 +87,11 @@ def run_sync_command(*args, **kwargs): ''' Helper to run a command synchronously ''' + if 'stdout' not in kwargs: + kwargs['stdout'] = open(os.devnull, 'w') + if 'stderr' not in kwargs: + kwargs['stderr'] = open(os.devnull, 'w') + p = subprocess.Popen(*args, **kwargs) stdout, stderr = p.communicate() if p.returncode != 0:
