| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
| |
by using ''.join() instead of concatenating string fragments in a loop,
which is slower as it required re-hashing the string multiple times.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit ca394b9f "generator: Fix parent type" fixed the case for creating
`virStorage*` instances, which require a reference to `virConnect`, so
the special handling for `._conn` is no longer needed.
Commit ee5c856a "Remove legacy libvirtError arguments" removed the
different arguments, so all cases are the same now.
Signed-off-by: Philipp Hahn <hahn@univention.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
|
|
|
| |
to return a negative value instead of None for consistency.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
tuples are sorted by first component anyway.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
Unused.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
"\(" is not a valid escape sequence for a Python string, but currently
is passed on unmodified. This might breaks in the future when new escape
sequences are introduced.
> generator.py:1001:7: W605 invalid escape sequence '\('
> generator.py:1001:18: W605 invalid escape sequence '\)'
Use raw python string instead.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
as recommended by pep8
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
Use `bool` instead of `int`.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
sys.exc_info() returns a 3-tuple (type, value, traceback), where `value`
is the instance captured by `except type as value`.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
| |
Move imports to top
Remove unused import string
Remove duplicate import os
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
as it also catches SystemExit, InterruptedError, SyntaxError and such.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit f4be03b330125ab1e5a2bb10b4f12674aeff4691.
While object.__init__() does not expect any additional arguments, this
construct is required for Pythons multiple inheritance implementation.
The original author Wojtek Porczyk <woju@invisiblethingslab.com>
explained is this way:
> I'm sorry I didn't notice this earlier, but the commit f4be03b3 dated
> 2020-04-20 [0] is wrong. The super().__init__(*args, **kwargs) in
> Callback.__init__ was there on purpose, because of how Python's inheritance in
> new-style classes works.
>
> Let me explain this a bit, because it is not obvious.
>
> Suppose you had diamond inheritance like this:
>
> class A(object): pass
> class B(A): pass
> class C(A): pass
> class D(B,C): pass
>
> And those classes needed a common function with varying arguments:
>
> class A(object):
> def spam(self, a): print(f'A: {a}')
> class B(A):
> def spam(self, b): print(f'B: {b}')
> class C(A):
> def spam(self, c): print(f'C: {c}')
> class D(B,C):
> def spam(self, d): print(f'D: {d}')
>
> The way to call all parent's functions exactly once (as per MRO) and accept
> all arguments and also forbid unknown arguments is to accept **kwargs
> everywhere and pass them to super().spam():
>
> class A:
> def spam(self, a):
> print(f'A: {a}')
> class B(A):
> def spam(self, b, **kwargs):
> print(f'B: {b}')
> super().spam(**kwargs)
> class C(A):
> def spam(self, c, **kwargs):
> print(f'C: {c}')
> super().spam(**kwargs)
> class D(B, C):
> def spam(self, d, **kwargs):
> print(f'D: {d}')
> super().spam(**kwargs)
>
> Let's run this:
>
> >>> B().spam(a=1, b=2)
> B: 2
> A: 1
> >>> D().spam(a=1, b=2, c=3, d=4)
> D: 4
> B: 2
> C: 3
> A: 1
>
> You may notice that super() in B.spam refers to two different classes, either
> A or C, depending on inheritance order in yet undefined classes (as of B's
> definition).
>
> That's why the conclusion that super() in Callback.__init__ refers to object
> is wrong. In this example, spam=__init__, A=object, B=Callback and C and D are
> not yet written, but theoretically possible classes that could be written by
> someone else. Why would they be needed, I don't know, but if someone writes
> them, s/he would be out of options to invent new arguments to C.__init__.
>
> Note that super().__init__(*args, **kwargs) when super() refers to object
> isn't harmful, and just ensures that args and kwargs are empty (i.e. no
> unknown arguments were passed). In fact, this is exactly why object.__init__()
> takes no arguments since Python 2.6 [1][2], as you correctly point out in the
> commit message.
>
> I don't think this breaks anything (I very much doubt anyone would need to
> write code that would trigger this), nevertheless, as the commit is both
> pointless and wrong, and as the original author of libvirtaio I'd like to ask
> for this commit to be reverted. If this breaks some static analysis tool,
> could you just suppress it for this particular line?
>
>
> [0] https://gitlab.com/libvirt/libvirt-python/-/commit/f4be03b330125ab1e5a2bb10b4f12674aeff4691
> [1] https://bugs.python.org/issue1683368
> [2] https://docs.python.org/3/whatsnew/2.6.html#porting-to-python-2-6
> (fourth point)
>
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
None should be compared with "is None" instead of "== None", as the
later would invoke a "__cmp__()" method.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
nobody evaluates the return value.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
static typing forbids re-declaring a variable with different types.
Rename the variable.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
as it also catches SystemExit, InterruptedError, SyntaxError and such.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
:%s/retlist = list()\n\s*\(for \w\+ in ret\):\n\s*retlist.append(\(.*\))\n\n\s*return retlist/return [\2 \1]/
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
static typing forbids re-declaring a variable with different types.
Rename the variable.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
sys.exc_info() returns a 3-tuple (type, value, traceback), where `value`
is the instance captured by `except type as value`.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
| |
libvirt-qemu-override.py was introduced in e3da8f17 but never added to
MANIFEST.in. It was therefore not contained in the official releases on
libvirt.org.
Signed-off-by: Vincent Vanlaer <vincent.vanlaer@skynet.be>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
self.callbacks contains a mix of FDCallback and TimeoutCallback, while
the update code does not explicitly check for.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
libvirtaio.py:364: error: "virEventInvokeFreeCallback" does not return a value
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
object.__init__() does not expect those parameters.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
Move imports to top
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
static typing forbids re-declaring a variable with different types.
Rename the variable.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
Python 3 only has int, remove the Python 2 long type
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
useless
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
is a built-in python type
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
Teach sanitytest to ignore typing imports
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The fields have been deprecated in C with
git:f60dc0bc09f09c6817d6706a9edb1579a3e2b2b8
They are only passed to the libvirtError constructor, but not stored for
later or used anywhere else.
sed -ri '/raise libvirtError/s/, \w+=self(\._dom)?//' *.py
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
indent by 4 spaces
one spaces around assignments
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
The remove function are supposed to return 0 on success and -1 on failure.
<https://libvirt.org/html/libvirt-libvirt-event.html#virEventRemoveTimeoutFunc>
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
indent by 4 spaces
one spaces around assignments
Signed-off-by: Philipp Hahn <hahn@univention.de>
|