[node-patches] Change in ovirt-node[master]: Hide _flush() output on the remote_storage page

fabiand at fedoraproject.org fabiand at fedoraproject.org
Thu Mar 27 19:53:43 UTC 2014


Hello Ryan Barry,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/26183

to review the following change.

Change subject: Hide _flush() output on the remote_storage page
......................................................................

Hide _flush() output on the remote_storage page

Redirect stderr and stdout to /dev/null so the screen doesn't get
cluttered.

Change-Id: I7ba2797b43455ac621f780963bf5eaf7a24a1219
Signed-off-by: Ryan Barry <rbarry at redhat.com>
Signed-off-by: Fabian Deutsch <fabiand at redhat.com>
---
M src/ovirt/node/utils/system.py
1 file changed, 13 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/83/26183/1

diff --git a/src/ovirt/node/utils/system.py b/src/ovirt/node/utils/system.py
index 0baf800..17b8696 100644
--- a/src/ovirt/node/utils/system.py
+++ b/src/ovirt/node/utils/system.py
@@ -645,27 +645,30 @@
 
         pipe() is used to capture the output of the calls
         """
-        process.pipe(["partprobe"] + [x for x in glob.glob("/dev/mapper/*")
-                                      if not re.match(r'.*\/control$', x)],
-                     stderr=process.STDOUT, check=False)
-        process.pipe(["udevadm", "settle"],
-                     stderr=process.STDOUT, check=False)
+        # Don't litter the screen with output, so get a handle to /dev/null
+        with open(os.devnull, 'wb') as DEVNULL:
+            process.call(["partprobe"] + [x for x in glob.glob("/dev/mapper/*")
+                                          if not re.match(r'.*\/control$', x)],
+                         stdout=DEVNULL, stderr=DEVNULL)
+            process.call(["udevadm", "settle"], stdout=DEVNULL, stderr=DEVNULL)
 
     @staticmethod
     def by_label(label):
         """Determines whether a filesystem with a given label is present on
         this system
         """
+        fs = None
         try:
             Filesystem._flush()
-            device = process.check_output(["blkid", "-c", "/dev/null",
-                                           "-L", label])
+            with open(os.devnull, 'wb') as DEVNULL:
+                device = process.check_output(["blkid", "-c", "/dev/null",
+                                               "-L", label], stderr=DEVNULL)
 
-            return Filesystem(label, device)
+            fs = Filesystem(label, device)
 
         except process.CalledProcessError as e:
-            self.logger.exception("Failed to resolve disks: %s" % e.cmd)
-            return None
+            LOGGER.debug("Failed to resolve disks: %s" % e.cmd, exc_info=True)
+        return fs
 
     def _tokens(self):
         tokens = process.check_output(["blkid", "-o", "export", self.device])


-- 
To view, visit http://gerrit.ovirt.org/26183
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ba2797b43455ac621f780963bf5eaf7a24a1219
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
Gerrit-Reviewer: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list