
libvirt_ver = virsh_ver.splitlines()[0].split()[4]
if virsh_ver.splitlines()[3].find("hypervisor"): - hyp_ver = virsh_ver.splitlines()[3].split("hypervisor")[1] - hyp_ver = hyp_ver.split(": ")[1] + tok = virsh_ver.splitlines()[3].split("hypervisor") + if len(tok) > 1: + tok = tok[1].split(": ") + if len(tok) > 1: + hyp_ver = tok[1]
Using splitlines() so many times and then subscripting it is a little confusing.
Agreed - it is confusing.
Any specific reason for using it like this ?
Here is an alternative for above:
if virsh_ver != "Unknown": libvirt, l2, l3, hyper = virsh_ver.splitlines() if libvirt.find("libvir"): libvirt_ver = libvirt.split()[4] if hyper.find("hypervisor"): tok1 = hyper.split(":") hyp_ver = tok1[1]
This approach is much cleaner. Will update the patch and resend. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com