{ "info": { "author": "Stepan Henek", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries", "Topic :: System :: Systems Administration" ], "description": "Python bindings for ubus\n========================\nCode in this directory enables a subset of libubus functions to be used directly from python.\n\nInstallation\n------------\n\nTo install these bidning you need to have the following libraries and headers installed:\n\n* libubox\n* libubus\n* python/python3\n\n\nExamples\n########\n\nconnect and disconnect\n----------------------\nTo connect you need to::\n\n import ubus\n ubus.connect(\"/var/run/ubus.sock\")\n\nTo disconnect you can simply::\n\n ubus.disconnect()\n\nNote that calling connect()/disconnect() on opened/closed connection will throw an exception.\n\nadd\n---\nTo add an object to ubus you can (you need to become root first)::\n\n def callback(handler, data):\n handler.reply(data) # this should return exactly the same data to the caller\n\n ubus.add(\n \"my_object\", {\n \"my_method\": {\"method\": callback, \"signature\": {\n \"first\": ubus.BLOBMSG_TYPE_STRING,\n \"second\": ubus.BLOBMSG_TYPE_BOOL,\n \"third\": ubus.BLOBMSG_TYPE_INT32,\n }},\n },\n )\n\nYou need to enter the loop to serve the object methods afterwards::\n\n ubus.loop()\n\n\nNote that it might not be a good idea to call the callback function recursively.\n\n\nobjects\n-------\nTo list the objects which are currently connected to ubus you can call::\n\n ubus.objects()\n\n ->\n\n {u'my_object': {u'my_method': {u'first': 3, u'second': 7, u'third': 5}}}\n\n\n\ncall\n----\nTo call an actual method on an object you can use::\n\n ubus.call(\"my_object\", \"my_method\", {\"first\": \"my_string\", \"second\": True, \"third\": 42})\n\n ->\n\n [{\"first\": \"my_string\", \"second\": True, \"third\": 42}]\n\n\nlisten\n------\nTo listen for an event you can::\n\n def callback(event, data):\n print(event, data) # just print event name and data to stdout\n\n ubus.listen((\"my_event\", callback))\n\nAnd you need to enter the loop to start to listen::\n\n ubus.loop()\n\nNote that it might not be a good idea to call the callback function recursively.\n\nsend\n----\nThis will send an event to ubus::\n\n ubus.send(\"my_event\", {\"some\": \"data\"})\n\n\nNotes\n#####\n\nThere are some tests present ('tests/' directory). So feel free to check it for some more complex examples.\nTo run the tests you need to have ubus installed and become root::\n\n sudo python setup.py test", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.labs.nic.cz/turris/python-ubus", "keywords": "", "license": "LGPL 2.1", "maintainer": "", "maintainer_email": "", "name": "ubus", "package_url": "https://pypi.org/project/ubus/", "platform": "", "project_url": "https://pypi.org/project/ubus/", "project_urls": { "Homepage": "https://gitlab.labs.nic.cz/turris/python-ubus" }, "release_url": "https://pypi.org/project/ubus/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Python bindings for libubus", "version": "0.1.1" }, "last_serial": 4546463, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "76eafe297ce04b133652f15f27e201f9", "sha256": "7e57bda989bc35b48c7075d03ec2818226e722bbf1bde138d7e7ea26d462682a" }, "downloads": -1, "filename": "ubus-0.1.1.tar.gz", "has_sig": false, "md5_digest": "76eafe297ce04b133652f15f27e201f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11871, "upload_time": "2018-11-30T09:56:09", "url": "https://files.pythonhosted.org/packages/a4/42/6d098fe93dd3ec6632cc6efb4d16a6ff870727ac7de24c6f3c7ab73ea878/ubus-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "76eafe297ce04b133652f15f27e201f9", "sha256": "7e57bda989bc35b48c7075d03ec2818226e722bbf1bde138d7e7ea26d462682a" }, "downloads": -1, "filename": "ubus-0.1.1.tar.gz", "has_sig": false, "md5_digest": "76eafe297ce04b133652f15f27e201f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11871, "upload_time": "2018-11-30T09:56:09", "url": "https://files.pythonhosted.org/packages/a4/42/6d098fe93dd3ec6632cc6efb4d16a6ff870727ac7de24c6f3c7ab73ea878/ubus-0.1.1.tar.gz" } ] }