summaryrefslogtreecommitdiffstats
path: root/generator.py
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2006-02-28 12:17:00 +0000
committerDaniel Veillard <veillard@redhat.com>2006-02-28 12:17:00 +0000
commit9600409e58e3580ccd0e46c1da2c6a019a01ec02 (patch)
tree4a67bb2fcd028692ae616461145c0c19382f08d8 /generator.py
parent8a85b2bf232d251c5c688721b68145fc21bf3581 (diff)
downloadlibvirt-python-v6-9600409e58e3580ccd0e46c1da2c6a019a01ec02.tar.gz
libvirt-python-v6-9600409e58e3580ccd0e46c1da2c6a019a01ec02.tar.xz
libvirt-python-v6-9600409e58e3580ccd0e46c1da2c6a019a01ec02.zip
* TODO: updated
* python/Makefile.am python/generator.py python/libvir.c python/libvir.py: improved python binding, raise exception when an instance creation or lookup fails, and add support for the global error handler, per conn handler still needed * python/tests/error.py python/tests/Makefile.am: adding a regression test Daniel
Diffstat (limited to 'generator.py')
-rwxr-xr-xgenerator.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/generator.py b/generator.py
index 005ac07..af44cae 100755
--- a/generator.py
+++ b/generator.py
@@ -251,7 +251,7 @@ foreign_encoding_args = (
#######################################################################
#
-# This part writes the C <-> Python stubs libxml2-py.[ch] and
+# This part writes the C <-> Python stubs libvirt2-py.[ch] and
# the table libxml2-export.c to add when registrering the Python module
#
#######################################################################
@@ -691,17 +691,7 @@ def buildWrappers():
info = (0, func, name, ret, args, file)
function_classes['None'].append(info)
- classes = open("libvirt.py", "w")
- classes.write("""#!/usr/bin/python -u
-#
-# Those are the autogenerated Python bindings for libvirt.
-# Check python/generator.py in the source distribution of libvirt
-# to find out more about the generation process
-#
-""")
-
- classes.write("import libvirtmod\n")
- classes.write("import types\n\n")
+ classes = open("libvirtclass.py", "w")
txt = open("libvirtclass.txt", "w")
txt.write(" Generated Classes for libvir-python\n\n")
@@ -754,7 +744,12 @@ def buildWrappers():
# Raise an exception
#
if functions_noexcept.has_key(name):
- classes.write(" if ret is None:return None\n");
+ classes.write(" if ret is None:return None\n");
+ else:
+ classes.write(
+ " if ret is None:raise libvirtError('%s() failed')\n" %
+ (name))
+
classes.write(" return ");
classes.write(classes_type[ret[0]][1] % ("ret"));
classes.write("\n");
@@ -867,6 +862,10 @@ def buildWrappers():
if functions_noexcept.has_key(name):
classes.write(
" if ret is None:return None\n");
+ else:
+ classes.write(
+ " if ret is None:raise libvirtError('%s() failed')\n" %
+ (name))
#
# generate the returned class wrapper for the object