Vinzenz Feenstra has uploaded a new change for review.

Change subject: agent: Use python 2.4 syntax in GuestAgentLinux2
......................................................................

agent: Use python 2.4 syntax in GuestAgentLinux2

Change-Id: I37c570c2cca4a71f15173601aaed27522e01e895
Signed-off-by: Vinzenz Feenstra <vfeen...@redhat.com>
---
M ovirt-guest-agent/GuestAgentLinux2.py
1 file changed, 15 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-guest-agent 
refs/changes/45/14545/1

diff --git a/ovirt-guest-agent/GuestAgentLinux2.py 
b/ovirt-guest-agent/GuestAgentLinux2.py
index 9c5ec0e..6071327 100644
--- a/ovirt-guest-agent/GuestAgentLinux2.py
+++ b/ovirt-guest-agent/GuestAgentLinux2.py
@@ -237,7 +237,8 @@
 
     def getDisksUsage(self):
         usages = list()
-        with open('/proc/mounts') as mounts:
+        try:
+            mounts = open('/proc/mounts', 'r')
             for mount in mounts:
                 try:
                     (device, path, fs) = mount.split()[:3]
@@ -251,6 +252,12 @@
                                        'used': used})
                 except:
                     logging.exception("Error retrieving disks usages.")
+            mounts.close()
+        except Exception:
+            logging.execption("Error during reading mounted devices")
+            if mounts:
+                mounts.close()
+
         return usages
 
     def getMemoryStats(self):
@@ -328,7 +335,7 @@
 
 
 def test():
-    import pprint
+    from pprint import pprint
     dr = LinuxDataRetriver()
     dr.app_list = "kernel kernel-headers aspell"
     dr.ignored_fs = set("rootfs tmpfs autofs cgroup selinuxfs udev mqueue "
@@ -337,12 +344,15 @@
                         "fuse.gvfs-fuse-daemon fusectl usbfs".split())
     print "Machine Name:", dr.getMachineName()
     print "OS Version:", dr.getOsVersion()
-    print "Network Interfaces:", dr.getAllNetworkInterfaces()
-    print "Installed Applications:", dr.getApplications()
+    print "Network Interfaces:",
+    pprint(dr.getAllNetworkInterfaces())
+    print "Installed Applications:",
+    pprint(dr.getApplications())
     print "Available RAM:", dr.getAvailableRAM()
     print "Logged in Users:", dr.getUsers()
     print "Active User:", dr.getActiveUser()
-    print "Disks Usage:", pprint.pprint(dr.getDisksUsage())
+    print "Disks Usage:",
+    pprint(dr.getDisksUsage())
     print "Memory Stats:", dr.getMemoryStats()
 
 if __name__ == '__main__':


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I37c570c2cca4a71f15173601aaed27522e01e895
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-guest-agent
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeen...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to