python-ubus issueshttps://gitlab.nic.cz/turris/python-ubus/-/issues2023-08-16T10:49:31+02:00https://gitlab.nic.cz/turris/python-ubus/-/issues/5Switch away from pytest-runner2023-08-16T10:49:31+02:00Jeffery ToSwitch away from pytest-runnerpytest-runner is deprecated, see https://github.com/pytest-dev/pytest-runner/#deprecation-notice
It is also the reason why the python-ubus package in the OpenWrt packages feed still uses the older setup.py-based build process: https://g...pytest-runner is deprecated, see https://github.com/pytest-dev/pytest-runner/#deprecation-notice
It is also the reason why the python-ubus package in the OpenWrt packages feed still uses the older setup.py-based build process: https://github.com/openwrt/packages/commit/4a7173d27d7969b95efac18eb34402c5fa69e3a1https://gitlab.nic.cz/turris/python-ubus/-/issues/4ubus loop blocks all threads2023-12-18T15:00:35+01:00phpaivaubus loop blocks all threadsI am developing a multi threaded application, I was launching 4 parallel threads without issues but when I added an ubus object all the application is blocked (with exception of the ubus loop). I launch this:
```
ubus_service_thread...I am developing a multi threaded application, I was launching 4 parallel threads without issues but when I added an ubus object all the application is blocked (with exception of the ubus loop). I launch this:
```
ubus_service_thread = threading.Thread(target=ubus_service, args=(Controller,))
Unix_Receiver_thread = threading.Thread(target=ct_cmdu_receiver, args=(Controller, ieee1905_port, controller_port_access, rec_to_send, rec_to_coord,log_fname,))
Unix_Sender_thread = threading.Thread(target=ct_cmdu_sender, args=(ieee1905_port, controller_port_access, rec_to_send, coord_to_send, algorithm_to_send,log_fname,))
Coordinator_thread = threading.Thread(target=controller_coordinator, args=(rec_to_coord, coord_to_send, coord_to_algorithm, Controller,log_fname,))
Algorithm_thread = threading.Thread(target=controller_algorithm, args=(algorithm_to_send, Controller,log_fname,))
threads = []
threads.append(ubus_service_thread)
threads.append(Unix_Receiver_thread)
threads.append(Unix_Sender_thread)
threads.append(Coordinator_thread)
threads.append(Algorithm_thread)
for thread in threads:
thread.start()
```
The ubus thread is just:
```
def ubus_service(Controller):
Controller.ubus_init() # adds an object
ubus.loop()
```
Also I find that "ubus.connect" is global (goes over "ubus" module, not a class from which one can create multiple instances). This seems to be a problem, for example I have two threads which some of them can be the one who attends the calls, and another one which does calls and listens to events from other ubus objects (of other applications)... so I will be launching two ubus.loop() reffering to the same connection... this could be a problem? If it is, can I create two different connections?
Thanks in advance.
Pablo.https://gitlab.nic.cz/turris/python-ubus/-/issues/3RPC Ubus Session ID2023-08-16T10:49:29+02:00Jonny TischbeinRPC Ubus Session IDWhen calling a ubus function via the package `uhttpd-mod-ubus` I will always get a result 2 / [invalid argument](https://lxr.openwrt.org/source/ubus/ubusmsg.h#L118).
The problem is that the rpc call will unconditionally sent the ubus se...When calling a ubus function via the package `uhttpd-mod-ubus` I will always get a result 2 / [invalid argument](https://lxr.openwrt.org/source/ubus/ubusmsg.h#L118).
The problem is that the rpc call will unconditionally sent the ubus session ID to verify the authorization.
Looking at `ubus -v monitor` I get:
```
-> c15a547b #751d66fa invoke: {"objid":-1920601747,"method":"access","data":{"ubus_rpc_session":"xxxx","object":"avarangedcd","function":"test"},"user":"root","group":"root"
```
My function is :
```
ubus.add("avarangedcd", {
"test": {"method": self.callback_test, "signature": {} }
})
```
And my remote call conatains of:
```
URL: /ubus
POST DATA: {'jsonrpc': '2.0', 'id': 1, 'method': 'call', 'params': ['xxxx', 'avarangedcd', 'test', {}]}
RESPONSE: 200 {'jsonrpc': '2.0', 'id': 1, 'result': [2]}
```
As a workaround I change my function to:
```
ubus.add("avarangedcd", {
"test": {"method": self.callback_test, "signature": {"ubus_rpc_session": ubus.BLOBMSG
_TYPE_STRING}}
})
```
The correct solution would be here to make an exception for `ubus_rpc_session`: https://gitlab.nic.cz/turris/python-ubus/-/blob/master/ubus_python.c#L789
E.g. something like this:
```
blob_for_each_attr(cur, args, idx) {
const char *name = blobmsg_name(cur);
int type = blobmsg_type(cur);
int pol_idx;
// Skip comparision if RPC session ID is given
if (!strcmp("ubus_rpc_session", name)) {
continue;
}
// Iterate through policies
for (pol_idx = 0; pol_idx < n_policies; pol_idx++) {
// Skip ubus_rpc_session
if (!strcmp(name, policies[pol_idx].name)) {
passed_count += 1;
int pol_type = policies[pol_idx].type;
if (pol_type != BLOBMSG_TYPE_UNSPEC && pol_type != type) {
return false;
}
break;
}
}
``Štěpán HenekŠtěpán Henekhttps://gitlab.nic.cz/turris/python-ubus/-/issues/1optional functions to be wrapped2019-07-08T11:01:55+02:00Štěpán Henekoptional functions to be wrappedBased on lua bindings try to implement following functions:
* [ ] notify (optional)
* [ ] defer_request (optional)
* [ ] complete_defer_request (optional)
* [ ] subscribe (optional)
And implement an extra functions:
* [ ] call_async (op...Based on lua bindings try to implement following functions:
* [ ] notify (optional)
* [ ] defer_request (optional)
* [ ] complete_defer_request (optional)
* [ ] subscribe (optional)
And implement an extra functions:
* [ ] call_async (optional)
* [ ] **unlisten** - deregister a listenerŠtěpán HenekŠtěpán Henek