{ "info": { "author": "Blackout Technologies", "author_email": "dev@blackout.ai", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# Blackout Nexus Node for Python\n\n![Blackout logo](https://www.blackout.ai/wp-content/uploads/2018/08/logo.png)\n\n|||\n|---|---|\n|Author|Adrian Lubitz|\n|Author|Marc Fiedler|\n|Email|dev@blackout.ai|\n|Latest stable version|3.2|\n|Required Axon versions| >= 3.0.0|\n|Runs on|Python 3.6+|\n|State|`Stable`|\n\n# Known Issues\nSince Version 3.1 Node automatically reconnect on an Error. That means any occurring error causes a reconnect. **KeyboardInterupt is an Error. If you want to terminate your script use `ctrl + Alt Gr + \\`**\n\n# Introduction\n\nThe `nexus` by Blackout Technologies is a platform to create Digital Assistants and to connect them via the internet to multiple platforms. Those platforms can be websites, apps or even robots. The `nexus` consists of two major parts, first being the `btNexus` and second the nexusUi. The `btNexus` is the network that connects the A.I. with the nexusUi and the chosen interfaces. The nexusUi is the user interface, that allows the user to create their own A.I.-based Digital Assistant. Those Digital Assistants can be anything, support chatbots or even robot personalities. \nEvery user has one or multiple nexusUi instances or short nexus instances, which means, it's their workspace. One nexusUi / nexus instance can host multiple personalities.\n\nEvery part of the `btNexus` is a Node. These Nodes can react on messages and send messages through the `btNexus`. To understand how Nodes work the following key concepts need to be clear.\n\n## Nodes\nNodes are essentially little programs. It is not important in which language these programs are implemented.\nMore important is that they share `Messages` between them in certain `Groups` and `Topics`.\nSo every node has its very unique purpose. It reacts on `Messages` with a `Callback` which is subscribed to a `Group` and a `Topic`\nand also sends `Messages` to the same and/or other `Group` and `Topic` to inform other `Nodes`, what is happening.\n\n## Messages\n`Messages` are the media of communication between `Nodes`.\nA `Message` contains a name for a `Callback` and the corresponding parameters.\nA `Message` is send on a specific `Group` and `Topic`, so only `Callbacks` that subscribed to this `Group` and `Topic` will react.\n\n## Callbacks\n`Callbacks` are functions which serves as the reaction to a `Message` on a specific `Topic` in a specific `Group`.\nEvery `Callback` returns a `Message` to the `btNexus` with the name of the origin `Callback` + `_response`. So a `Node` can also subscribe to the response of the `Message` send out.\n\n## Topics & Groups\n`Topics` and `Groups` help to organize `Messages`. A `Callback` can only be mapped to one `Group` and `Topic`.\n\n\n# Prerequisites\n\n* Python installed (either 2.7+ or Python 3)\n* Owner of a btNexus instance or a btNexus account\n\n# Install btnexus-node-python\n## easiest solution\nWith pip you can install the repository directly.\nWe recommend using Anaconda (https://www.anaconda.com/), because you wont need `sudo` and you can simply use virtual environments.\nIf you are using Anaconda or any other virtual environments(**recommended**) or your systems pip(**not recommended**) you can simply\n```\npip install git+https://github.com/Blackout-Technologies/btnexus-node-python\n```\n*to install a specific version add @version*\n\n## workaround\nIf you don't use an environment and cannot use the system pip(no sudo) just add the `--user` option:\n\n```\npip install --user git+https://github.com/Blackout-Technologies/btnexus-node-python\n```\n\nIf you cannot use pip for any reason, do the following:\n\nInstall the Python modules with\n```\nsudo easy_install .\n```\n\nIf you are not `sudo` and have no pip use the install.sh to install the modules to your home directory\n```\n./install.sh\n```\n\nIf you can not use pip you also have to install six and pyyaml manually.\n\n# Example Nodes\nFollowing you will see an example of a Node which sends out the current minute\nand second every five seconds.\n\n```python\n\"\"\"Example for a Node that sends out messages\"\"\"\n# System imports\nfrom threading import Thread\nimport datetime\nimport time\nimport os\n# 3rd party imports\nfrom btNode import Node\n\n# local imports\n\nclass SendingNode(Node):\n \"\"\"\n This Node shows how to implement an active Node which sends different Messages\n \"\"\"\n def onConnected(self):\n \"\"\"\n This will be executed after a the Node is succesfully connected to the btNexus\n Here you need to subscribe and set everything else up.\n\n :returns: None\n \"\"\"\n self.shouldRun = True\n self.subscribe(group=\"exampleGroup\",topic=\"example\", callback=self.fuseTime_response) # Here we subscribe to the response of messages we send out to fuseTime\n self.thread = Thread(target=self.mainLoop)\n self.thread.start() # You want to leave this method so better start everything which is actively doing something in a thread.\n def fuseTime_response(self, orignCall ,originParams, returnValue):\n \"\"\"\n Reacting to the fused Time with a print in a specific shape.\n responseCallbacks always have the following parameters.\n\n :param orignCall: The name of the orignCall\n :type orignCall: String\n :param originParams: The parameters given to the orignCall\n :type originParams: List or keywordDict\n :param returnValue: The returned Value from the orignCall\n :type returnValue: any\n :returns: None\n \"\"\"\n print(\"[{}]: {}\".format(self.__class__.__name__, returnValue))\n\n def mainLoop(self):\n \"\"\"\n Sending currenct minute and second to the ListeningNode on the printMsg and fuse callback.\n\n :returns: Never\n \"\"\"\n #Make sure the thread terminates, when reconnecting\n #otherwise onConnected will spawn another\n #and you will end up with n threads, where n is the number of connects\n while(self.shouldRun):\n now = datetime.datetime.now()\n self.publish(group=\"exampleGroup\", topic=\"example\", funcName=\"printTime\", params=[now.minute, now.second])\n self.publish(group=\"exampleGroup\", topic=\"example\", funcName=\"fuseTime\", params={\"min\":now.minute, \"sec\":now.second})\n time.sleep(5)\n\n def cleanUp(self):\n \"\"\"\n Make sure the thread terminates, when reconnecting\n otherwise onConnected will spawn another\n and you will end up with n threads, where n is the number of connects\n \"\"\"\n super(SendingNode, self).cleanUp()\n self.shouldRun = False\n self.thread.join()\n\nif( __name__ == \"__main__\" ):\n #Here you initialize your Node and run it.\n token = os.environ[\"TOKEN\"]\n axon = os.environ[\"AXON_HOST\"]\n debug = \"NEXUS_DEBUG\" in os.environ\n sendingNode = SendingNode(token, axon, debug)\n sendingNode.connect() # This call is blocking\n\n```\nThe ListeningNode and all further examples can be seen in the examples folder.\n\n\n# Implement your own Node\nFirst you need know the purpose of your Node.\nNodes should be small and serve only one purpose.\nTo implement your own Node you need to inherit from the Node class,\nimplement your callbacks and if you are actively doing something implement your\nThreads, that for example read in sensor data. See the examples to get started ;)\nKeep in mind, that you need to set the environment variables `AXON_HOST`, `TOKEN` and if you want `NEXUS_DEBUG` for the examples. If you are using Anaconda you can integrate those into your virtual environment(https://conda.io/docs/user-guide/tasks/manage-environments.html#saving-environment-variables).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Blackout-Technologies/btnexus-node-python", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "btnexus-node-python", "package_url": "https://pypi.org/project/btnexus-node-python/", "platform": "", "project_url": "https://pypi.org/project/btnexus-node-python/", "project_urls": { "Homepage": "https://github.com/Blackout-Technologies/btnexus-node-python" }, "release_url": "https://pypi.org/project/btnexus-node-python/3.2.7/", "requires_dist": null, "requires_python": "", "summary": "Provides Node, Hook and PostRequests that follow the btProtocol.", "version": "3.2.7" }, "last_serial": 5960426, "releases": { "3.2.5": [ { "comment_text": "", "digests": { "md5": "3c95e9cacc3c74f33f3374b8c9c0867c", "sha256": "a5f0ea449c5747949ba79c6c8bc593b5accc768907f162006374d5d17e1c7d22" }, "downloads": -1, "filename": "btnexus-node-python-3.2.5.tar.gz", "has_sig": false, "md5_digest": "3c95e9cacc3c74f33f3374b8c9c0867c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8848, "upload_time": "2019-10-11T09:12:12", "url": "https://files.pythonhosted.org/packages/e6/c4/9dd8b8c982955dd37b457198651a8241fb59b91c8b161fda30fdf8ea1441/btnexus-node-python-3.2.5.tar.gz" } ], "3.2.7": [ { "comment_text": "", "digests": { "md5": "a9b64e9268f9182e73c38b8b7749d102", "sha256": "b83ce91a2af8056b292f49aa33314bc974af6618c70a9c66b7b6ee81a1b1278e" }, "downloads": -1, "filename": "btnexus-node-python-3.2.7.tar.gz", "has_sig": false, "md5_digest": "a9b64e9268f9182e73c38b8b7749d102", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 39176, "upload_time": "2019-10-11T13:51:56", "url": "https://files.pythonhosted.org/packages/19/91/a9471e9180224859bf16bb268d01b9c9e0ad3d8539882450fa9669cbc253/btnexus-node-python-3.2.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a9b64e9268f9182e73c38b8b7749d102", "sha256": "b83ce91a2af8056b292f49aa33314bc974af6618c70a9c66b7b6ee81a1b1278e" }, "downloads": -1, "filename": "btnexus-node-python-3.2.7.tar.gz", "has_sig": false, "md5_digest": "a9b64e9268f9182e73c38b8b7749d102", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 39176, "upload_time": "2019-10-11T13:51:56", "url": "https://files.pythonhosted.org/packages/19/91/a9471e9180224859bf16bb268d01b9c9e0ad3d8539882450fa9669cbc253/btnexus-node-python-3.2.7.tar.gz" } ] }