On Wed, Jun 15, 2011 at 09:23:13PM -0400, Cole Robinson wrote:
The return values for the python version are different that the C
version
of virStreamSend: on success we return a string, an error raises an exception,
and if the stream would block we return int(-2). We need to do this
since strings aren't passed by reference in python.
I find this a bit bizarre, either we return a string or we return an
integer, but if we don't have any other way to provide the information
Since we provide the wrapper what about returning
(code#, "string value")
allowing to have only one type on return instead (i.e. just change
recv() in the override below)
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
python/generator.py | 9 +++--
python/libvirt-override-virStream.py | 35 +++++++++++++++++++
python/libvirt-override.c | 62 ++++++++++++++++++++++++++++++++++
python/typewrappers.c | 14 ++++++++
python/typewrappers.h | 1 +
5 files changed, 117 insertions(+), 4 deletions(-)
+
+ def recv(self, nbytes):
+ """Write a series of bytes to the stream. This method may
+ block the calling application for an arbitrary amount
+ of time.
+
+ Errors are not guaranteed to be reported synchronously
+ with the call, but may instead be delayed until a
+ subsequent call.
+
+ On success, the received data is returned. On failure, an
+ exception is raised. If the stream is a NONBLOCK stream and
+ the request would block, integer -2 is returned.
+ """
+ ret = libvirtmod.virStreamRecv(self._o, nbytes)
+ if ret == None: raise libvirtError ('virStreamRecv() failed')
+ return ret
otherwise looks fine to me,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/