On 04/10/2014 11:54 AM, Ramon Medeiros wrote:
Support psutil > 2.0 changes in kvmusertests. The main change is
that a
variable becomes a method. So, a check was added, to use the method on
psutil 2.0 version and high.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
src/kimchi/kvmusertests.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/kimchi/kvmusertests.py b/src/kimchi/kvmusertests.py
index 1914a94..07ba263 100644
--- a/src/kimchi/kvmusertests.py
+++ b/src/kimchi/kvmusertests.py
@@ -55,7 +55,13 @@ class UserTests(object):
with open('/var/run/libvirt/qemu/%s.pid' % self.vm_name) as f:
pidStr = f.read()
p = psutil.Process(int(pidStr))
+
+ # bug fix #357
+ # in psutil 2.0 and above versions, username will be a method,
+ # not a string
user = p.username
+ if psutil.version_info[0] >= 2:
+ user = p.username()
I don't think compare version is a good solution.
What about?
if callable(p.username):
user = p.username()
else:
user = p.username
return user