summaryrefslogtreecommitdiff
path: root/libvirt-override-virStream.py
Commit message (Collapse)AuthorAgeFilesLines
* stream: Convert type() to isinstance()Philipp Hahn2020-08-181-4/+4
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* stream: no type changePhilipp Hahn2020-08-181-6/+6
| | | | | | | static typing forbids re-declaring a variable with different types. Rename the variable. Signed-off-by: Philipp Hahn <hahn@univention.de>
* stream: Simplify boolean conditionPhilipp Hahn2020-08-181-1/+1
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* stream: Fix exception traceback handlingPhilipp Hahn2020-08-181-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | sys.exc_info() returns a 3-tuple (type, value, traceback). Raising just `value` again looses the traceback information as this creates a new exception. Just use `raise` which re-raises the previous exception including the original traceback. FYI: There is a subtile difference between Python 2 and Python 3: > try: > raise ValueError() > except ValueError: > try: > raise TypeError() > except TypeError: > pass > raise With Python 3 the exception environment is dropped after the exception has been handled - as such Python 3 re-raises the outer ValueError. With Python 2 the last (inner) exception is raised: TypeError Signed-off-by: Philipp Hahn <hahn@univention.de>
* stream: Do not use bare exceptPhilipp Hahn2020-08-181-4/+4
| | | | | | as it also catches SystemExit, InterruptedError, SyntaxError and such. Signed-off-by: Philipp Hahn <hahn@univention.de>
* override: Catch type errorPhilipp Hahn2020-08-181-1/+5
| | | | | | | handler() should either return bytes or -2 or -3. Explicitly raise ValueError or TypeError to silence mypy. Signed-off-by: Philipp Hahn <hahn@univention.de>
* override: Add manual PEP 484 type annotationsPhilipp Hahn2020-08-181-12/+13
| | | | Signed-off-by: Philipp Hahn <hahn@univention.de>
* Normalize white spacePhilipp Hahn2020-08-061-11/+17
| | | | | | | indent by 4 spaces one spaces around assignments Signed-off-by: Philipp Hahn <hahn@univention.de>
* virStream: Use larger buffer for sendAll/recvAll methodsMichal Privoznik2020-07-031-4/+4
| | | | | | | | | | | | | | | | | | | | There are four methods which receive/send entire stream (sendAll(), recvAll(), sparseSendAll() and sparseRecvAll()). All these have an intermediary buffer which is either filled by incoming stream and passed to a user provided callback to handle the data, or the other way round - user fills it with data they want to send and the buffer is handed over to virStream. But the buffer is incredibly small which leads to smaller packets being sent and thus increased overhead. What we can do is to use the same buffer as their C counterparts do (e.g. virStreamSendAll()) - they all use VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX long buffer (which is the maximum size of a stream packet we send) - this is almost exactly 256KiB (it's 256KiB - 24B for the header). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* libvirt-override.py: fix sparseSendAllBoris Fiuczynski2018-05-161-1/+1
| | | | | | | Variable ret is used before assignment. Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
* virStream: Introduce virStreamSparse{Recv,Send}AllMichal Privoznik2017-05-241-0/+103
| | | | | | | Yet again, our parser is not capable of generating proper wrapper. To be fair, this one wold be really tough anyway. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* virStream: Introduce virStreamRecvFlagsMichal Privoznik2017-05-231-0/+18
| | | | | | | Yet again, we need a custom wrapper over virStreamRecvFlags because our generator is not capable of generating it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Implement virStreamSendHole/virStreamRecvHoleMichal Privoznik2017-05-231-0/+21
| | | | | | | | The return value for virStreamRecvHole is slightly different to its C counterpart. In python, either it returns the hole size or None if C API fails. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Use better comparison in virStream.sendAll for Python 3Xavier Fernandez2017-05-171-1/+1
| | | | | In Python 3, if the file is open in binary mode, @got will end up being equal to b"" and b"" != "" in Python 3.
* Fix stream related spelling mistakesPhilipp Hahn2014-02-131-2/+2
| | | | | | Consistent spelling of all-uppercase I/O. Signed-off-by: Philipp Hahn <hahn@univention.de>
* Fix calling of virStreamSend methodRobie Basak2014-01-231-1/+1
| | | | | | | | | Change d40861 removed the 'len' argument from the virStreamSend C level wrapper, but forgot to remove it from the python level wrapper. Reported-by: Robie Basak <robie.basak@canonical.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* virStream.sendAll() fix raising an undeclared varv1.2.1-rc2Doug Goldstein2014-01-101-0/+1
| | | | | | The exception is raised from the variable 'e', which was undeclared in this context. Used code that is compatible with old and new Python versions.
* override: Fix exception handling syntaxDoug Goldstein2013-12-091-1/+2
| | | | | | Python 3 no longer accepts 'except Exception, e:' as valid while Python 2.4 does not accept the new syntax 'except Exception as e:' so this uses a fall back method that is compatible with both.
* Test for object identity when checking for None in PythonClaudio Bley2013-08-231-2/+2
| | | | | | | | | Consistently use "is" or "is not" to compare variables to None, because doing so is preferrable, as per PEP 8 (http://www.python.org/dev/peps/pep-0008/#programming-recommendations): > Comparisons to singletons like None should always be done with is or > is not, never the equality operators.
* python: correct a copy-paste errorAlex Jia2012-02-011-1/+1
| | | | | | * python/libvirt-override-virStream.py: fix a copy-paste error in sendAll(). Signed-off-by: Alex Jia <ajia@redhat.com>
* python: Fix documentation of virStream recvv0.9.7Matthias Bolte2011-10-311-1/+1
| | | | This was fixed in be757a3f7baf93b for libvirt.c.
* python: Mark event callback wrappers as privateCole Robinson2011-06-211-1/+1
| | | | | | | | These functions aren't intended to be called directly by users, so mark them as private. While we're at it, remove unneeded exception handling, and break some long lines.
* python: Implement virStreamSend/RecvAll helpersCole Robinson2011-06-211-0/+64
| | | | | | | | Pure python implementation. The handler callbacks have been altered a bit compared to the C API: RecvAll doesn't pass length of the data read since that can be trivially obtained from python string objects, and SendAll requires the handler to return the string data to send rather than store the data in a string pointer.
* python: Implement virStreamSend/RecvCole Robinson2011-06-211-0/+35
| | | | | | | 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.
* python: Implement bindings for virStreamEventAddCallbackCole Robinson2011-06-201-9/+15
| | | | | v2: Don't generate virStreamFree
* Add public API definition for data stream handlingDaniel P. Berrange2009-09-291-0/+20
* include/libvirt/libvirt.h.in: Public API contract for virStreamPtr object * src/libvirt_public.syms: Export data stream APIs * src/libvirt_private.syms: Export internal helper APIs * src/libvirt.c: Data stream API driver dispatch * src/datatypes.h, src/datatypes.c: Internal helpers for virStreamPtr object * src/driver.h: Define internal driver API for streams * .x-sc_avoid_write: Ignore src/libvirt.c because it trips up on comments including write() * python/Makefile.am: Add libvirt-override-virStream.py * python/generator.py: Add rules for virStreamPtr class * python/typewrappers.h, python/typewrappers.c: Wrapper for virStreamPtr * docs/libvirt-api.xml, docs/libvirt-refs.xml: Regenerate with new APIs