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!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
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>
In python3 if we use 'list' as a variable name it causes it
to hide the corresponding 'list()' function from the entire
function that holds the variable.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The event handler code currently invokes PyImport_ImportModule
which is very heavyweight. This is not in fact required, since
we know the libvirt module has already been imported. We can
thus use PyImport_ImportModuleNoBlock and do away with the
global variables caching the imported module reference.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
If an app used the virDomainEventRegister binding instead
of the virDomainEventRegisterAny binding, it would never
have its callback invoked. This is because the code for
dispatching from the C libvirt_virConnectDomainEventCallback
method was totally fubar.
If DEBUG macro was set in the python build the error would
become visible
"libvirt_virConnectDomainEventCallback dom_class is not a class!"
The code in libvirt_virConnectDomainEventCallback was
inexplicably complex and has apparently never worked. The
fix is to write it the same way as the other callback handlers.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
When setup.py is kicked off with a python interpreter other than the
system 'python', (e.g. python2.7 setup.py build) the build process would
switch to 'python' and not use python2.7 as requested by the user. We
should always respect the user requested python interpreter and use it.
Validate that every public API method is mapped into the python
and that every python method has a sane C API.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
If the libvirt-override-virXXXX.py file has methods which call
C APIs that don't exist in the version of libvirt built against
we need to skip copying their code.
eg for 0.9.13 libvirt we should not copy the 'listAllDomains'
method.
The way this works is that it breaks the override file into
individual methods by looking for ' def '. It then collects
the contents until the next method start, whereupon it looks
for a libvirtmod.XXXXXX API call. It checks if the XXXXX part
is present in the XML description we have, and if not, it
discards the entire method.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Fix the RPM summary line, add placeholder %changelog tag,
make %setup quiet, add Url: tag and filter out bogus
provides and add example programs as docs.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
When reading/writing a global variable from inside a method
it must be declared as a global, otherwise a local variable
by the same name will be used.
Special case the virConnectListDomainsID method which is
bizarrely renamed for no obvious reason.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Older libvirt has files named 'events' and 'virterror'
rather than 'virevent' and 'virerror'. This is visible
in the API XML files. We must look for both names to
ensure we don't lose generation of methods with older
versions of libvirt.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The virNodeGetSecurityModel, virDomainGetSecurityLabel and
virDomainGetSecurityLabelList methods were disabled in the
python binding for inexplicable reasons.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The python code generator tries to figure out what class a
method should be in by looking at the list of arguments for
any which are object types. Unfortunately missing break
statements meant that methods which have multiple object
arguments (eg migrate as a virDomainPtr followed by a
virConnectPtr) got added to multiple classes.
The following incorrect methods are removed by this change
virStream.download (dup of virStorageVol.download)
virStream.screenshot (dup of virDomain.screenshot)
virStream.upload (dup of virStorageVol.upload)
virConnect.migrate (dup of virDomain.migrate)
virConnect.migrate2 (dup of virDomain.migrate2)
virConnect.migrate3 (dup of virDomain.migrate3)
virConnect.migrateToURI3 (dup of virDomain.migrateToURI3)
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The method dispatchDomainEventBlockPullCallback which is
used internally to dispatch block pull events to the python
application code was missing the leading '_', to denote that
it was private. All other event callback helpers have a
leading '_'. No application should have been using this so
it is justifiable to rename it.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
The reference counting API is for internal use only. Attempts
to use it from python application code will cause havoc.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This Python interface code is returning a -1 on errors for the
`baselineCPU' API. Since this API is supposed to return a pointer
the error return value should really be VIR_PY_NONE.
Signed-off-by: Don Dugger <donald.d.dugger@intel.com>
The previous README file from the python code is more like a
HACKING file. Rename it and update the content. Then add a
basic README file
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>