From 9600409e58e3580ccd0e46c1da2c6a019a01ec02 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Tue, 28 Feb 2006 12:17:00 +0000 Subject: * 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 --- generator.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'generator.py') 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 -- cgit