summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2006-03-28 14:41:04 +0000
committerDaniel Veillard <veillard@redhat.com>2006-03-28 14:41:04 +0000
commit1027aa871cf478a54d77088199da8caabacbe3a0 (patch)
treeefdb320396183d0cb7fd81f38e2f3ca110cef1f7
parent86dda3bcc733bd0cbb1b0c50417d677fe9ad2a98 (diff)
downloadlibvirt-python-v6-1027aa871cf478a54d77088199da8caabacbe3a0.tar.gz
libvirt-python-v6-1027aa871cf478a54d77088199da8caabacbe3a0.tar.xz
libvirt-python-v6-1027aa871cf478a54d77088199da8caabacbe3a0.zip
* python/libvir.c: call the initialize entry point
* src/libvirt_sym.version: add initialize entry point * src/libvirt.c: make sure we always initialize the lib * python/tests/*.py: start updating exemple for exception handling as pointed by Jim Meyering Daniel
-rw-r--r--libvir.c2
-rwxr-xr-xtests/basic.py5
-rwxr-xr-xtests/create.py9
-rwxr-xr-xtests/uuid.py10
4 files changed, 19 insertions, 7 deletions
diff --git a/libvir.c b/libvir.c
index 47da369..1d97037 100644
--- a/libvir.c
+++ b/libvir.c
@@ -269,6 +269,8 @@ initlibvirtmod(void)
if (initialized != 0)
return;
+ virInitialize();
+
/* intialize the python extension module */
Py_InitModule((char *) "libvirtmod", libvirtMethods);
diff --git a/tests/basic.py b/tests/basic.py
index b6f8831..c6dec81 100755
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -14,8 +14,9 @@ if conn == None:
# print conn
-dom0 = conn.lookupByName("Domain-0")
-if dom0 == None:
+try:
+ dom0 = conn.lookupByName("Domain-0")
+except:
print 'Failed to find the main domain'
sys.exit(1)
diff --git a/tests/create.py b/tests/create.py
index c897741..b717db1 100755
--- a/tests/create.py
+++ b/tests/create.py
@@ -115,13 +115,20 @@ time.sleep(10)
print "shutdown of test domain"
if dom.shutdown() != 0:
+ okay = 0
print 'Failed to shutdown domain test'
i = 0
while i < 30:
time.sleep(1)
i = i + 1
- t = dom.info()[4]
+ try:
+ t = dom.info()[4]
+ except:
+ okay = 0
+ t = -1
+ break;
+
if t == 0:
break
diff --git a/tests/uuid.py b/tests/uuid.py
index d71d420..605b759 100755
--- a/tests/uuid.py
+++ b/tests/uuid.py
@@ -19,16 +19,18 @@ if ids == None or len(ids) == 0:
id = ids[-1]
-dom = conn.lookupByID(id)
-if dom == None:
+try:
+ dom = conn.lookupByID(id)
+except:
print 'Failed to find the domain %d'
sys.exit(1)
name0 = dom.name()
uuid = dom.UUID()
print "Using domain %s" % (name0)
-dom2 = conn.lookupByUUID(uuid)
-if dom2 == None:
+try:
+ dom2 = conn.lookupByUUID(uuid)
+except:
print 'Failed to lookup domain %d based on its UUID'
sys.exit(1)
if dom2.name() != name0: