]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
common: catch stderr output into the stdout pipe
authorPaul Cuzner <pcuzner@redhat.com>
Wed, 23 Aug 2017 02:52:33 +0000 (14:52 +1200)
committerPaul Cuzner <pcuzner@redhat.com>
Wed, 23 Aug 2017 02:52:33 +0000 (14:52 +1200)
Ensure stdout and stderr output is returned to the caller

collectors/common.py

index 5f35915aaf263a138070ecbf5d3dad5f3f9c432d..60b62bff22c77552cc16eb1c2828481290dda57d 100644 (file)
@@ -18,11 +18,12 @@ def os_cmd(command):
     Issue a command to the OS and return the output. NB. check_output default
     is shell=False
     :param command: (str) OS command
-    :return: (list) command response
+    :return: (str) command response (lines terminated with \n)
     """
     cmd_list = command.split(' ')
     if cmd_exists(cmd_list[0]):
-        cmd_output = subprocess.check_output(cmd_list).rstrip()
+        cmd_output = subprocess.check_output(cmd_list,
+                                             stderr=subprocess.STDOUT).rstrip()
         return cmd_output
     else:
         return ''