Commit graph

19 commits

Author SHA1 Message Date
Hiroaki KAWAI
cb319e22f5 python: fix wrongly passing argument to function in ObjIterator.next()
self.__next__() bound method does not take an extra argument.

https://github.com/thom311/libnl/pull/57

Signed-off-by: Hiroaki KAWAI <kawai@stratosphere.co.jp>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-09 09:22:47 +02:00
Teto
a4e588d04a Fixed ObjIterator for python3, fixed output of _color and added missing parameter to nl_cache_resync
Here are a few things I fixed and that provoked a  python error.

I canno't answer to this thread but one solution I found while using
the python binding is to iterate over all and filter via python
http://list-archives.org/2013/09/09/libnl-lists-infradead-org/missing-feature-for-retrieving-cached-
address-objects/f/5031600704

Example:
cache = nlrta.AddressCache()
cache.resync()

for i in cache:
    print ("item", i ) # then you can filter here

Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-10-07 09:52:08 +02:00
Arend van Spriel
b9284bcded python: add send and receive functions to Socket class
Adding class methods send_auto_complete() and recvmsgs()
that call their swig capi equivalent function.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-09-05 17:46:00 +02:00
Arend van Spriel
6726895133 python: fix typo in Socket::__str__() function
The property name used in __str__ should be local_port
instead of localPort to get rid of the AttributeError.

>>> str(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../netlink/core.py", line 172, in __str__
    return 'nlsock<{0}>'.format(self.localPort)
AttributeError: 'Socket' object has no attribute 'localPort'

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-09-05 17:46:00 +02:00
Arend van Spriel
2d55872fb1 use Callback object constructing Socket
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-09-05 17:46:00 +02:00
Arend van Spriel
86207d47ab python: rework netlink callback handling
The initial commit adding netlink callback handling also introduced
memory leak issue. The python callback info was stored in an allocated
structure, but that was never freed.

Only exposing nl_cb_alloc() as is. nl_cb_get() is removed as it is
not very useful to use reference counting mechanism. Python uses
that itself internally. To deal properly with Python callback info
the function nl_cb_put() and nl_cb_clone() have a custom wrapper
taking care of Python reference counting.

This commit also adds a Callback python class using the netlink
callback functions.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-09-05 17:46:00 +02:00
Коренберг Марк
ffa461d37c Fixed memory leak in Cache destructor
destructor of Cache was missing due to typo
2012-06-08 22:26:35 +06:00
Коренберг Марк
87d370912c netlink.nlattr re-implemented in more pythonic way 2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
08e8b35d9f Remove unnecessary comments 2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
482c602b74 Refine some places
No real logick change
2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
454ea4a5b4 pylint's first review and trivial fixes 2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
8959d95e22 Using only single quotes now and multi-line lists
Nothing algorithmic changed really, just cosmetics
2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
83f06bfbb8 Fix indentation (spaces vs tabs)
Now, python files use pseudo-tab equal 4 spaces
2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
fb890a5b5e Code cleanups
1. unused "import struct" removed
2. AddressFamily.__len__ is defined, but why in so way? removed.
3. comparison against instancemethod type fixed
2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
38fefc5c1b Fixed various str-related logick 2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
b369d22f92 Fix whitespaces at EOL
Make git happy with that
2012-06-08 22:26:35 +06:00
Коренберг Марк (ноутбук дома)
4be1ae2ae2 Introduce Python's absolute_imports
Helps greatly when porting to Python 3
2012-06-08 22:26:35 +06:00
Thomas Graf
e56eb065b2 Work on libnl-python
Changes too numerous to describe them
2011-06-10 13:55:29 +02:00
Thomas Graf
f443be6e74 python interface to netlink protocols
currently includes experimental support for links, addresses
and some traffic control
2011-05-10 12:17:33 +02:00