mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-03 08:21:58 +03:00
sanitytest.py parameters are now optional
When called without parameters, sanitytest.py doesn't touch sys.path and locates itself the patch to the libvirt-api.xml file using pkg-config. This change makes possible to run sanitytest.py from tox.
This commit is contained in:
committed by
Daniel P. Berrange
parent
cd2d02ab0d
commit
4e7a8bd3b3
@ -5,18 +5,31 @@ import lxml
|
||||
import lxml.etree
|
||||
import string
|
||||
|
||||
# Munge import path to insert build location for libvirt mod
|
||||
sys.path.insert(0, sys.argv[1])
|
||||
if len(sys.argv) >= 2:
|
||||
# Munge import path to insert build location for libvirt mod
|
||||
sys.path.insert(0, sys.argv[1])
|
||||
import libvirt
|
||||
|
||||
if sys.version > '3':
|
||||
long = int
|
||||
|
||||
# Path to the libvirt API XML file
|
||||
xml = sys.argv[2]
|
||||
def get_libvirt_api_xml_path():
|
||||
import subprocess
|
||||
args = ["pkg-config", "--variable", "libvirt_api", "libvirt"]
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
stdout, _ = proc.communicate()
|
||||
if proc.returncode:
|
||||
sys.exit(proc.returncode)
|
||||
return stdout.splitlines()[0]
|
||||
|
||||
f = open(xml, "r")
|
||||
tree = lxml.etree.parse(f)
|
||||
# Path to the libvirt API XML file
|
||||
if len(sys.argv) >= 3:
|
||||
xml = sys.argv[2]
|
||||
else:
|
||||
xml = get_libvirt_api_xml_path()
|
||||
|
||||
with open(xml, "r") as fp:
|
||||
tree = lxml.etree.parse(fp)
|
||||
|
||||
verbose = False
|
||||
fail = False
|
||||
|
Reference in New Issue
Block a user