# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1207740687 -28800
# Node ID 74f907a44c1d7d764aa06a388ae40b5d078c2b6a
# Parent 262153788503c8b10c76c77719bba081df9a7b88
[TEST] .#3 add a try..except to get_value_xpath()
A 'None' return is more elegant than a pure exception error.
Changed to use logger.info
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 262153788503 -r 74f907a44c1d suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Apr 08 17:58:44 2008 +0530
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 19:31:27 2008 +0800
@@ -115,7 +115,12 @@ class XMLClass:
return self.xdoc.toprettyxml()
def get_value_xpath(self, xpathStr):
- node = self.get_node(xpathStr)
+ try:
+ node = self.get_node(xpathStr)
+ except Exception:
+ logger.info('Zero or multiple node found')
+ return None
+
if node.nodeType == Node.ATTRIBUTE_NODE:
return node.value
if node.nodeType == Node.TEXT_NODE: