IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
Add a test setting scheduler parameters to validate the
previous bugfix to strncpy of field names.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Make the 'python setup.py test' able to run unit tests
found under tests/ through the 'nosetests' command
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The @ret value is built in a loop. However, if in one iteration
there's an error, we should free all the fields built so far. For
instance, if there's an error and the previous item was
type of VIR_TYPED_PARAM_STRING we definitely must free it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
In the setPyVirTypedParameter we try to produce virTypedParameter
array from a python dictionary. However, when copying field name into
item in returned array, we use strncpy() as the field name is fixed
length array. To determine its size we use sizeof() but mistakenly
dereference it resulting in sizeof(char) which equals to 1 byte.
Moreover, there's no need for using sizeof() when we have a global
macro to tell us the length of the field name:
VIR_TYPED_PARAM_FIELD_LENGTH.
And since array is allocated using VIR_ALLOC() we are sure the memory
is initially filled with zeros. Hence, there's no need to terminate
string we've just copied into field name with '\0' character. It's
there for sure too as we copy up to field length - 1.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
When enum type has '_LAST' in its name, but is not the last type in
that enum, it's skipped even though it shouldn't be. Currently, this
is the case for only VIR_NETWORK_UPDATE_COMMAND_ADD_LAST inside an
enum virNetworkUpdateCommand.
Also, since _LAST types can have other enums instead of values, that
needs to be filtered out using a try-except when converting the value.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Commit 6ea5be0 added network event callback support, so we might
as well demonstrate that it works by updating our example.
* examples/event-test.py: Add network event, fix typos.
Signed-off-by: Eric Blake <eblake@redhat.com>
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>
We brought over use of the __GNUC_PREREQ macro from libvirt but didn't
bring over the definition of it. This brings over the macro from libvirt
sources.
The PyUnicode_AsUTF8 method doesn't exist prior to Python 3.3.
It is also somewhat inefficient, so rewrite it to use an
intermediate PyBytes object.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This updates autobuild.sh to test the python3 build process.
The RPM specfile is changed to build a libvirt-python3 RPM
on Fedora > 18
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Instead of using a 'z#i' format string to receive byte array,
use 'O' and then libvirt_charPtrSizeUnwrap. This lets us hide
the Python 3 vs 2 differences in typewrappers.c
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The PyString and PyInt classes are gone in Python 3, so we must
conditionalize their use to be Python 2 only.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
In Python3 the PyInt / PyLong types have merged into a single
PyLong type. Conditionalize the use of PyInt to Python 2 only
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Replace use of PyString with either PyBytes or PyUnicode.
The former is used for buffers with explicit sizes, which
are used by APIs processing raw bytes.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Replace use of the PyInt_AsLong libvirt_intUnwrap helper.
This isolates the need for Python3 specific code in one
place
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Replace use of the PyInt_FromLong and PyLong_FromLongLong
with libvirt_{int,uint,longlong,ulonglong}Wrap helpers.
This isolates the need for Python3 specific code in one
place.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Replace calls to PyString_AsString with the helper method
libvirt_charPtrUnwrap. This isolates the code that will
change in Python3.
In making this change, all callers now have responsibility
for free'ing the string.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Make use of libvirt_constcharPtrWrap in all override code,
to match generated code. This will isolate Python3 specific
changes in one place.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The Exception class hiearchy in Python 2.4 reports different
data types than in later Python versions. As a result the
type(libvirt.libvirtError) does not return 'type'. We just
special case handling of this class.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The way native modules are registered has completely
changed, so the code must be #ifdef'd for Python2 & 3
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Strings in python3 default to unicode, so when writing to
the self-pipe we must be sure to use bytes by calling the
encode() method.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The 'print' statement no longer exists in Python 3 and now must be
called as a function. This is compatible down to Python 2.4 as we are
not using any special syntax of the function.
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.
To assist in diff comparisons between code generated with
different versions of Python, do an explicit sort of all
functions and enums.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Call the 'replace' and 'find' functions directly on the
string variables, instead of via the 'string' module.
Python3 only accepts the latter syntax
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The sort() method previously took either a comparator function
or a key function. Only the latter is supported in Python3.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The code 'XXX.has_key(YYYY)' must be changed to be of
the form 'YYY in XXXX' which works in Python2 and 3
As an added complication, if 'YYY in XXX' is used against
an object overriding the '__getitem__' method it does not
work in Python 2.4. Instead we must use 'YYY in XXX.keys()'
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Use a syntax for exception handling that works in both Python 2 and
Python 3. The new syntax is 'except Exception as e:' but this does not
work in older Pythons so we use the most compatible way by just catching
the exception and getting the type and the exception value after the
fact.
In python3 various methods list 'dict.keys()' do not
return a list, so we must explicitly cast the result.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This reverts commit 084729e269.
The PyImport_ImportModuleNoBlock method does not exist in
python 2.4
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The previous commit changed the exception handling syntax to
use 'as' instead of a ','. This doesn't work with python 2.4
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
In python3 the string.lower() method doesn't exist, the
lower() function can only be executed against a string
variable directly. Python2 supported both approaches so
this change is compatible
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>