{ "info": { "author": "Bernard Pratz", "author_email": "guyzmo@hackable-devices.org", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Utilities" ], "description": "README: Event Source Library for Python\n=======================================\n\nThis library implements W3C Draft's on event-source:\n - http://dev.w3.org/html5/eventsource/\n\nIt enables a halfduplex communication from server to client, but initiated\nby the client, through standard HTTP(S) communication.\n\nDependances\n-----------\n\n - Fairly recent python (tested with 2.7)\n - Fairly recent tornado (tested with 2.2.1)\n\nUsage\n-----\n\n 1. Launch the server:\n \n eventsource_listener -P 8888 -i -k 50000\n\n 2. Launch the client:\n\n eventsource_client 42:42:42:42:42:42 -r 5000\n\n 3. Send requests:\n\n eventsource_request 42:42:42:42:42:42 ping \"42\"\n eventsource_request 42:42:42:42:42:42 close\n\nCommand Line arguments\n----------------------\n\n - `eventsource/listener.py` or `eventsource_server`:\n\n usage: eventsource/listener.py [-h] [-H HOST] [-P PORT] [-d]\n [-j] [-k KEEPALIVE] [-i]\n\n Event Source Listener\n\n optional arguments:\n -h, --help show this help message and exit\n -H HOST, --host HOST Host to bind on\n -P PORT, --port PORT Port to bind on\n -d, --debug enables debug output\n -j, --json to enable JSON Event\n -k KEEPALIVE, --keepalive KEEPALIVE\n Keepalive timeout\n -i, --id to generate identifiers\n\n - `eventsource/client.py` or `eventsource_client`:\n\n usage: eventsource/client.py [-h] [-H HOST] [-P PORT] [-d]\n [-r RETRY]\n token\n\n Event Source Client\n\n positional arguments:\n token Token to be used for connection\n\n optional arguments:\n -h, --help show this help message and exit\n -H HOST, --host HOST Host to connect to\n -P PORT, --port PORT Port to be used connection\n -d, --debug enables debug output\n -r RETRY, --retry RETRY\n Reconnection timeout\n\n - `eventsource/send_request.py` or `eventsource_request`:\n\n usage: eventsource/send_request.py [-h] [-H HOST] [-P PORT] [-j]\n token action [data]\n\n Generates event for Event Source Library\n\n positional arguments:\n token Token to be used for connection\n action Action to send\n data Data to be sent\n\n optional arguments:\n -h, --help show this help message and exit\n -H HOST, --host HOST Host to connect to\n -P PORT, --port PORT Port to be used connection\n -j, --json Treat data as JSON\n\n\nIntegrate\n---------\n\nOn the server side, basically all you have to do is to add the following to your code:\n\n from eventsource import listener\n\n application = tornado.web.Application([\n (r\"/(.*)/(.*)\", listener.EventSourceHandler, \n dict(event_class=EVENT,\n keepalive=KEEPALIVE)),\n ])\n\n application.listen(PORT)\n tornado.ioloop.IOLoop.instance().start()\n\nwhere:\n - PORT is an integer for the port to bind to\n - KEEPALIVE is an integer for the timeout between two keepalive messages (to protect from disconnections)\n - EVENT is a eventsource.listener.Event based class, either one you made or \n - eventsource.listener.StringEvent : Each event gets and resends multiline strings\n - eventsource.listener.StringIdEvent : Each event gets and resends multiline strings, with an unique id for each event\n - eventsource.listener.JSONEvent : Each event gets and resends JSON valid strings\n - eventsource.listener.JSONIdEvent : Each event gets and resends JSON valid string, with an unique id for each event\n\nExtend\n------\n\nTo extend the behaviour of the event source library, without breaking eventsource\ndefinition, the Event based classes implements all processing elements that shall\nbe done on events. \n\nThere is two abstract classes that defines Event:\n - eventsource.listener.Event : defines the constructor of an Event\n - eventsource.listener.EventId : defines an always incrementing id handler\n\nhere is an example to create a new Event that takes multiline data and join it in a one\nline string seperated with semi-colons.\n\n class OneLineEvent(Event):\n ACTIONS = [\"ping\",Event.FINISH]\n\n \"\"\"Property to enable multiline output of the value\"\"\"\n def get_value(self):\n # replace carriage returns by semi-colons\n # this method shall always return a list (even if one value)\n return [\";\".join([line for line in self._value.split('\\n')])]\n\n value = property(get_value,set_value)\n\nAnd now, I want to add basic id support to OneLineEvent, in OneLineIdEvent, \nnothing is easier :\n\n class OneLineIdEvent(OneLineEvent,IdEvent):\n id = property(IdEvent.get_value)\n\nOr if I want the id to be a timestamp:\n\n import time\n class OneLineTimeStampEvent(OneLineEvent):\n id = property(lambda s: \"%f\" % (time.time(),))\n\nYou can change the behaviour of a few things in a Event-based class:\n - Event.LISTEN contains the GET action to open a connection (per default \"poll\")\n - Event.FINISH contains the POST action to close a connection (per default \"close\")\n - Event.RETRY contains the POST action to define the timeout after reconnecting on network disconnection (per default \"0\", which means disabled)\n - in the Event.ACTIONS list, you define what POST actions are allowed, per default, only Event.FINISH is allowed. \n - Event.content_type contains the \"content_type\" that will be asked for every form (it is not enforced).\n\nTo change the way events are generated, you can directly call EventSourceHandler.buffer_event()\nto create a new event to be sent. But the post action is best, at least while WSGI can't handle\ncorrectly long polling connections.\n\nLicensing\n---------\n\nPython Event Source Library\n\n(c) 2012 Bernard Pratz\nPatches by Ian Whyman and \u041a\u043e\u0440\u0435\u043d\u0431\u0435\u0440\u0433 \u041c\u0430\u0440\u043a\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.\n\nEOF\n\n\nSee http://packages.python.org/eventsource/ for the full documentation\nSee https://github.com/guyzmo/event-source-library for latest sources and for patches\n\nNews\n====\n\nversion 1.1.0:\n * syntax clean up\n * in listener:\n * removed events buffering as a deque\n * added toro dependency\n * added toro.asyncresult to replace event's deque buffer\n * used toro.asyncresult to block and call the event loop\n * in client:\n * added keep alive parameter\n\nversion 1.0.5:\n * moved event_loop callback rearming away\n * changed events buffer from list to deque\n\nversion 1.0.4:\n * added invalid SSL certificates support\n * integrated patches from Ian Whyman: \n * support of bad HTTP services implementations (be compatible with '\\n' and '\\r\\n')\n * added user/password support for connections in client\n * integrated patches from \u041a\u043e\u0440\u0435\u043d\u0431\u0435\u0440\u0433 \u041c\u0430\u0440\u043a:\n * use of json module of tornado\n * cosmetic changes\n\nversion 1.0.3:\n * added support for SSL connections", "description_content_type": null, "docs_url": "https://pythonhosted.org/eventsource/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://packages.python.org/eventsource/", "keywords": null, "license": "GPLv3", "maintainer": null, "maintainer_email": null, "name": "eventsource", "package_url": "https://pypi.org/project/eventsource/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/eventsource/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://packages.python.org/eventsource/" }, "release_url": "https://pypi.org/project/eventsource/1.1.1/", "requires_dist": null, "requires_python": null, "summary": "Event Source Library", "version": "1.1.1" }, "last_serial": 791761, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "c6e31d77cbc0e893444e5c072734944e", "sha256": "e9eaa6db4b19dddcad6ab3efdf542d4fe91fd09b373335b73e78d3710810278d" }, "downloads": -1, "filename": "eventsource-1.0-py2.7.egg", "has_sig": false, "md5_digest": "c6e31d77cbc0e893444e5c072734944e", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 22097, "upload_time": "2012-05-28T02:48:27", "url": "https://files.pythonhosted.org/packages/53/25/cda87cf369cbcd08a4912f3972c741b08fc424cffb26a2f70f7ba2bdffa3/eventsource-1.0-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "4e766b0518bcaad0a606e56787b1ca7f", "sha256": "75f5c36941ebf9cd2ae85daed0b7dbf6bb2994f9c44b5fe393df8bb6cc7e3459" }, "downloads": -1, "filename": "eventsource-1.0.tar.gz", "has_sig": false, "md5_digest": "4e766b0518bcaad0a606e56787b1ca7f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9299, "upload_time": "2012-05-28T02:42:40", "url": "https://files.pythonhosted.org/packages/21/19/6bdd24f6ecfe72c17645469ed7d7a086c3e9e56fd80306a6463dcc0f4feb/eventsource-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "c04c7e68e057ea452bdf80323ddf8a5b", "sha256": "e98176c37f1d5485ca516035e365db51ec3c2646d99f5d8ca3df5759445e4506" }, "downloads": -1, "filename": "eventsource-1.0.1-py2.7.egg", "has_sig": false, "md5_digest": "c04c7e68e057ea452bdf80323ddf8a5b", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 22056, "upload_time": "2012-05-30T12:52:45", "url": "https://files.pythonhosted.org/packages/49/ea/c216b52c9e815074a93f3660f5f0ca00f44e42f1a22b1eef2e2fe4e7e444/eventsource-1.0.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "e9fbf91659a9e4c417b5ead5a5e51471", "sha256": "f63c3d8816e38d39fdae868ff37564469c48fd38cbfa11abf27119b12bf24910" }, "downloads": -1, "filename": "eventsource-1.0.1.tar.gz", "has_sig": false, "md5_digest": "e9fbf91659a9e4c417b5ead5a5e51471", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9314, "upload_time": "2012-05-30T12:52:44", "url": "https://files.pythonhosted.org/packages/51/33/36ad4cb5058b43c510f789b6e7a2674e36a70ee6a3c487c1d5f1868856cd/eventsource-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "59484b0167bd930eafa0dce93b9ce03e", "sha256": "9365161feab1a747ce5ea13ce8c65d65d0b132c9bfd434ba793f6ce5e8690b37" }, "downloads": -1, "filename": "eventsource-1.0.2-py2.7.egg", "has_sig": false, "md5_digest": "59484b0167bd930eafa0dce93b9ce03e", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 22244, "upload_time": "2012-05-31T18:26:58", "url": "https://files.pythonhosted.org/packages/7b/a4/ca31b154baa52edb6654f5077052e6541db59e6b9c5da2b89c56386ca81b/eventsource-1.0.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "890c83c8860c85a415c0f932e8dd2ca2", "sha256": "9d2a0b7026f4402b76534258d54c35841e14e30d633bc743dd9b72588005d1a0" }, "downloads": -1, "filename": "eventsource-1.0.2.tar.gz", "has_sig": false, "md5_digest": "890c83c8860c85a415c0f932e8dd2ca2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9385, "upload_time": "2012-05-31T18:26:57", "url": "https://files.pythonhosted.org/packages/4c/49/686b64c4588d8eec3a4080637b4a4a87592e1785048ceba83d3f6844bc1b/eventsource-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "3e725b129fddf4f26746e9aeea13f31e", "sha256": "93bcc2055322c97610621bff6e2bf84c6db56881572347f7cb04ef71b16f589f" }, "downloads": -1, "filename": "eventsource-1.0.3-py2.7.egg", "has_sig": false, "md5_digest": "3e725b129fddf4f26746e9aeea13f31e", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 22950, "upload_time": "2012-07-02T20:10:57", "url": "https://files.pythonhosted.org/packages/97/07/d37dc66f4d73e949a8e447f022e4e943236b987b99a984bf64a4ba4179ff/eventsource-1.0.3-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "13b7ed6faee62f53b73bb40c2590f77a", "sha256": "b0d296aef89ae5cc90db4629803d60079fba5201870079224ab01d4534ab67bc" }, "downloads": -1, "filename": "eventsource-1.0.3.tar.gz", "has_sig": false, "md5_digest": "13b7ed6faee62f53b73bb40c2590f77a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10206, "upload_time": "2012-07-02T20:10:59", "url": "https://files.pythonhosted.org/packages/3e/72/e03013c93a1f90fdf83f8ee6069d15280f65fcbcca84db9d345c478aa4fa/eventsource-1.0.3.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "fe3d271b39132117e4cc048ca1c7052f", "sha256": "3f4973d94826ee504e0177db21d95828d2466c54b1bb2980ccfb9478265c39ae" }, "downloads": -1, "filename": "eventsource-1.0.5-py2.7.egg", "has_sig": false, "md5_digest": "fe3d271b39132117e4cc048ca1c7052f", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 23479, "upload_time": "2013-01-03T16:23:23", "url": "https://files.pythonhosted.org/packages/66/eb/916c9f8003e8b1be262e7dfa4999c87089b28b8b3e974103a739330a83c2/eventsource-1.0.5-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "c6966c37f9a629debb0b81f7d79b8ab7", "sha256": "a384e3c4a6891f47fd3aa043221ae3df7c79c8c082597395fde311ea910ea34b" }, "downloads": -1, "filename": "eventsource-1.0.5.tar.gz", "has_sig": false, "md5_digest": "c6966c37f9a629debb0b81f7d79b8ab7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10440, "upload_time": "2013-01-03T16:23:26", "url": "https://files.pythonhosted.org/packages/b0/4e/5b99fe6f5ef8969a75a1b6ddd5de8b36ba82e0475b31bffb84ac290d1cf9/eventsource-1.0.5.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "4bb3ca2883d53bdaade97f53605e8dab", "sha256": "b504cea5e972727305a14c5ca9e7279dc33ebb0c723f089d52efdfeafd2f8176" }, "downloads": -1, "filename": "eventsource-1.1.1-py2.6.egg", "has_sig": false, "md5_digest": "4bb3ca2883d53bdaade97f53605e8dab", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 24976, "upload_time": "2013-05-24T14:01:27", "url": "https://files.pythonhosted.org/packages/b9/d8/11c896f173c5119a2f2cdc9d290278a9318c141b8276b829d2c29c9edfa0/eventsource-1.1.1-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "de348367582da8fc8f7699d159fd6655", "sha256": "d18715ac4e38fa6f1d88b6ce717332630e1a5ca2c9787587353831f0d6aeb2ef" }, "downloads": -1, "filename": "eventsource-1.1.1.tar.gz", "has_sig": false, "md5_digest": "de348367582da8fc8f7699d159fd6655", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10582, "upload_time": "2013-05-24T14:01:22", "url": "https://files.pythonhosted.org/packages/03/b8/137d9a7358b69052a54f2adccf2087be789ece2082b35a0e5d432ef33891/eventsource-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4bb3ca2883d53bdaade97f53605e8dab", "sha256": "b504cea5e972727305a14c5ca9e7279dc33ebb0c723f089d52efdfeafd2f8176" }, "downloads": -1, "filename": "eventsource-1.1.1-py2.6.egg", "has_sig": false, "md5_digest": "4bb3ca2883d53bdaade97f53605e8dab", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 24976, "upload_time": "2013-05-24T14:01:27", "url": "https://files.pythonhosted.org/packages/b9/d8/11c896f173c5119a2f2cdc9d290278a9318c141b8276b829d2c29c9edfa0/eventsource-1.1.1-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "de348367582da8fc8f7699d159fd6655", "sha256": "d18715ac4e38fa6f1d88b6ce717332630e1a5ca2c9787587353831f0d6aeb2ef" }, "downloads": -1, "filename": "eventsource-1.1.1.tar.gz", "has_sig": false, "md5_digest": "de348367582da8fc8f7699d159fd6655", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10582, "upload_time": "2013-05-24T14:01:22", "url": "https://files.pythonhosted.org/packages/03/b8/137d9a7358b69052a54f2adccf2087be789ece2082b35a0e5d432ef33891/eventsource-1.1.1.tar.gz" } ] }