summaryrefslogtreecommitdiff
path: root/pygerrit/stream.py
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Remove support for Gerrit over ssh"David Pursehouse2014-05-291-0/+77
| | | | | | | | | | | | | | | | | | | | | The ssh interface is still being used and patches are being contributed [1]. It's easier to revert the removal on master than attempt to keep the support in a separate branch. This reverts commit f0b77968389966cd7bad0cac1fe7f04526eafde1. [1] https://github.com/sonyxperiadev/pygerrit/pull/21 Conflicts: README.rst example.py requirements.txt setup.py unittests.py Change-Id: I9e02208c57cb2022ff39cff6650101ed40c0519d
* Remove support for Gerrit over sshDavid Pursehouse2014-04-281-77/+0
| | | | | | | | | From now only the REST API is supported. This makes installation of the package a bit lighter as we no longer depend on paramiko and pycrypto Change-Id: Ieda773d596fd43047c05895f3304690ddf709094
* Fix for hanging connectionsJohannes Richter2014-04-031-0/+4
| | | | | | * client.stop_event_stream() was not closing Change-Id: Idf38565332a7865063caf614992ba376804da1a7
* Suppress pylint warning about catching too general exceptionDavid Pursehouse2013-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | | Commit 06c88c8 (merged with pull request #13) added exception handling: except Exception as e: which causes a pylint warning: W0703: Catching too general exception Exception However in this case we actually do want to catch all types of exception because the intention is to make sure pygerrit doesn't fall over when something unexpected happens. Add a suppression of this warning. The suppression is only effective on this particular line; the warning will be raised again if we do the same thing again somewhere else. Change-Id: If812d441c1dc625651db34c6d3763cedc98b68a9
* Ensure errors in json parsing doesn't leave everything in a broken stateJens Andersen2013-10-171-8/+12
|
* Avoid busy loop when receiving incoming stream data.Jens Andersen2013-10-161-1/+1
| | | | | Checking whether bytes are available is a non-blocking operation, causing the receive loop to become a busy loop.
* Completely refactor the stream event handlingDavid Pursehouse2013-09-121-20/+16
| | | | | | | | | | | | | Instead of using select.select() to wait for input, use the methods provided by paramiko's client channel object. Read from both stdout and stderr, and send ErrorEvent if anything is received on stderr. Ref #1 Fix #12 Change-Id: Ic67392cb9d689a1f457f5d02eb17a5432112a0c0
* Fix #5: Move json parsing and error handling into the event factoryDavid Pursehouse2013-09-111-21/+6
| | | | | | | | | | Pass the raw string into the event factory and parse it to a json object there. If the string is not valid json, generate an error event. Add a unit test for handling of invalid json on the event stream. Change-Id: I209a89fd28c3a594b71443fc106e25d58c5cc1ea
* Fix #1: Use select.select() instead of select.poll()David Pursehouse2013-09-101-14/+12
| | | | | | | | select.poll() does not work on all platforms. Replace it with select.select(). Change-Id: Iadd09127c99b5b47ebc28f6f4e57fcc1eb4c8710
* Don't put copyright and license headers in Python module docstringsDavid Pursehouse2013-08-071-22/+22
| | | | | | | | | | | | | | If the copyright and license headers are in module docstrings, they appear in the generated API documentation pages and it looks crappy. Instead, put the headers in regular Python comments. Thus each file still has the required copyright and license notice, but it is not included everywhere in the generated documentation. The documentation still includes an automatically generated copyright notice at the bottom of each page. Change-Id: Ibc5f4ca221c0a6de26f04f3b4511d8991e28b663
* Fix relative importsDavid Pursehouse2013-08-061-3/+2
| | | | Change-Id: I6bc8d92ed1055959f1c24128b8beace814eaf998
* Fix UnboundLocalError when stream-event connection failsDavid Pursehouse2013-08-051-16/+16
| | | | | | | | When the stream-event command fails, for example due to bad host name, the result is not initialised. However the code was accessing the result variable which caused an exception. Change-Id: I6c649dba447e33733dfaea6e742152277fa7374f
* Python 2.6 style exception handlingDavid Pursehouse2012-10-251-3/+3
| | | | | | | | | | | | Handle exceptions with the syntax: except Exception as e rather than: except Exception, e Change-Id: I883fdc1db541b9d2699712bfd2bd328261635005
* Encapsulate the SSH command results in a classDavid Pursehouse2012-10-241-2/+2
| | | | | | | | Add a new class GerritSSHCommandResult to encapsulate the stdin, stdout, and stderr streams that are returned from running a command over SSH. Change-Id: Ic851c195ac63e530e62198eb7e0af62c2fbd73d5
* Update pylint config to work with version 0.26David Pursehouse2012-10-241-3/+0
| | | | | | | | | In version 0.26 of pylint the message enable/disable options are changed. Update the configuration to reflect this. Also remove redundant suppressions. Change-Id: Ia6e4c6c79cd573dfc91aec53b32c58930fbbde55
* Reduce nested `if` blocks in stream handlingDavid Pursehouse2012-10-231-10/+9
| | | | Change-Id: I283773fb6b68da1878ede9001d18b5b7d0aff569
* More error handling improvements in streamDavid Pursehouse2012-10-231-11/+22
| | | | | | | | | | | | | | Handle IOError and ValueError separately from GerritError when processing the steam. In this case GerritError is raised if there is a problem adding an event to the queue; it makes no sense to then try to add an error event on the same queue. Add separate handling of GerritError when running the gerrit stream-events command. Move the creation of the error event out to a utility method. Change-Id: Iac5aa8db5ad1a444fd0e6217c32d1800f727276e
* Fix pylint warnings in stream.pyDavid Pursehouse2012-10-231-6/+10
| | | | Change-Id: I7ad27a83d5af3eaca7a188e01cbef392c9ff1b6b
* More exception handling in streamDavid Pursehouse2012-10-231-1/+1
| | | | | | | Handle IOError that can occur when reading from the stream, and ValueError that can be raised by the JSON parser. Change-Id: Ic9dc60e048f0f747daf8b34c7b6d8d90c11bb1e0
* Move SSH client from stream class to main client classDavid Pursehouse2012-10-161-5/+4
| | | | | | | So it can be reused in query functionality that will be added later. Change-Id: I361aaf8fe8aa9107a94757606a3a1837b6a448ab
* Add license informationDavid Pursehouse2012-09-201-1/+23
| | | | Change-Id: I25ce3fafe7a51d0221f66fe30b2fb7cc8115c4aa
* Handle errors when reading event streamDavid Pursehouse2012-09-121-12/+29
| | | | | | | | When setting up and reading the gerrit event stream, catch errors and dispatch them to the gerrit client as a new error event type, `GerritStreamErrorEvent`. Change-Id: Ide51dc4882450dca67ee419f3702aa4fb415cf09
* Refactor event stream handling to use SSH clientDavid Pursehouse2012-09-111-66/+29
| | | | Change-Id: I4953be92719fddeb7c23c2559ffe954c452cc131
* Pass input stream in the constructor of GerritStreamDavid Pursehouse2012-08-031-6/+7
| | | | | | | | | | | Refactor so that the input stream is passed into the constructor, instead of as a parameter to the "stream" method. Rename the "stream" method to "read". Add a check that the given input stream has a read() method and raise exception if not. Change-Id: I5ff917847a6abde124f64cc808a68ec05e5a1c2b
* Add event factory and refactor event dispatchingDavid Pursehouse2012-08-021-50/+19
| | | | | | | | | | | | | | | Add a new static class GerritEventFactory which provides: - Decorator method to register event names to classes - Method to instantiate an event class based on event name The stream implementation is refactored to use the factory to generate the events. With this change it will be possible to add new event classes without having to modify the stream handler implementation. Change-Id: If1fd0b4f77ead320e98a56301d8266d66dcc8aca
* Tidy up docstrings to follow the PEP-257 docstring convention0.0.2David Pursehouse2012-07-311-18/+19
| | | | | | http://www.python.org/dev/peps/pep-0257/ Change-Id: I1469a94f01660ef00aac196a5ca8995b3803a4bd
* Refactor into submodulesDavid Pursehouse2012-07-311-0/+108
Data models, events, errors, and stream handler are split from the single module into submodules. Change-Id: I03537c5e268135966c6b6e77ecaca1cb579a5fde