summaryrefslogtreecommitdiff
path: root/pygerrit
Commit message (Collapse)AuthorAgeFilesLines
...
* | Initial implementation of Gerrit REST API interfaceDavid Pursehouse2013-08-261-0/+110
|/ | | | | | | | | | | | | | This initial version implements wrappers for GET, PUT, POST and DELETE requests. Authentication is not implemented. All requests are sent anonymously. Handling of error responses is not implemented. This change introduces a dependency on python-requests. Change-Id: I579f9f02be8afbb4e720daf97ca873d77cd54a77
* Bump version to 0.1.00.1.0David Pursehouse2013-08-091-1/+1
| | | | Change-Id: I09fcd52a9eb0f7aab7fa82f276187af6704af899
* Don't put copyright and license headers in Python module docstringsDavid Pursehouse2013-08-077-175/+163
| | | | | | | | | | | | | | 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
* Add generation of package documentationDavid Pursehouse2013-08-071-1/+1
| | | | | | | | | | Documentation is generated in html format into the docs folder. The idea is that with further commits we can automatically generate and package the documentation into a zip file that can be published to the package index. Change-Id: Ia5719bda59b6224fc05e2021e9054e29990ad22a
* Fix pylint warningsDavid Pursehouse2013-08-062-3/+6
| | | | | | | | | | | | | | | - Add missing docstrings that the PEP-257 checker did not report. - Add explicit parameters on `GerritSSHClient.exec_command` method overridden from `paramiko.SSHClient.exec_command`. - Disable warning that the `GerritEvent` class does not have a member named `name`. This member is initialised by the event factory when a derived class is instantiated. - Capitalise constant `REQUIRES`. Change-Id: I8880e061b51e12145ee55e0cd86dab930970cde5
* Fix relative importsDavid Pursehouse2013-08-065-13/+12
| | | | Change-Id: I6bc8d92ed1055959f1c24128b8beace814eaf998
* Fix one more PEP-257 violationDavid Pursehouse2013-08-061-0/+2
| | | | Change-Id: Ie595ac7125323677ad478655c33b21a00302007c
* Only allow strings as query terms and commandsDavid Pursehouse2013-08-052-13/+15
| | | | Change-Id: I850978039ca10162a5ae2ab0a4f79374183107ba
* Don't hard code version in setup.pyDavid Pursehouse2013-08-051-0/+3
| | | | | | | | | | We're currently only using the version number in the setup script, but in future we might need it in other places too. Define the version number in the module itself and import it in setup. Change-Id: Idbf246d3a9777f6de710cb01fa05f8fbf031d192
* Include command in GerritCommandResultDavid Pursehouse2013-08-051-3/+8
| | | | | | | Include the name of the command that was run in the result object. Change-Id: I93c27ed937d27942428f561dc50d84b5ea25591a
* Don't open ssh connection until neededDavid Pursehouse2013-08-051-17/+31
| | | | | | | | | | Instead of opening the ssh connection in the constructor, only connect when actually needed. This improves performance of the unit tests. Running the test suite now takes less than 1 second rather than 22 seconds. Change-Id: I03a49d74db8c045740a85201c02c492d175e0d6c
* 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
* Add missing docstrings to conform to PEP-257David Pursehouse2013-08-043-5/+10
| | | | Change-Id: If06f1ea17740a796142db63e7086f80445f4c6e1
* Handle socket connection error in SSH clientDavid Pursehouse2012-12-141-4/+8
| | | | | | | Catch socket error raised when connecting to the server over SSH and raise a GerritError. Change-Id: I140a26be4bc04ec229d95faaa80b94477cf96645
* Python 2.6 style exception handlingDavid Pursehouse2012-10-254-12/+12
| | | | | | | | | | | | Handle exceptions with the syntax: except Exception as e rather than: except Exception, e Change-Id: I883fdc1db541b9d2699712bfd2bd328261635005
* Revert "Basic thread-safeness in the SSH client"David Pursehouse2012-10-241-5/+0
| | | | | | This reverts commit 42272ffdb1541cf96f13466446e07c24d8e7febb. Change-Id: Ie00d75579231873db98bc3a84caef408152f3d81
* Encapsulate the SSH command results in a classDavid Pursehouse2012-10-243-7/+17
| | | | | | | | 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
* Only add query result lines to returned dataDavid Pursehouse2012-10-241-4/+3
| | | | | | | | Only add JSON lines in the results if they contain "project". Otherwise the "rowCount" line, and anything else, will be included in the results as an empty Change object. Change-Id: Ia4de4ed7970c8f5ba87f5e12dd42ff45b459b047
* Handle JSON errors in query resultsDavid Pursehouse2012-10-241-1/+4
| | | | Change-Id: Iadced9142673f1a5f277462bc6d9027db4a53e2d
* Refactor getting the Gerrit versionDavid Pursehouse2012-10-242-16/+34
| | | | | | | | | | | | | Move the functionality to get the Gerrit version from the main client into the SSH client and reimplement it. First attempt to get the version from the underlying Paramiko SSH client. If that fails, fall back to using the `gerrit version` command as before. Get and print the version in the example script. Change-Id: Ia79853f80f898b43c301fcecee61fdfdb75e9811
* 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
* Handle exception when running ssh commandDavid Pursehouse2012-10-231-2/+7
| | | | | | | Also make sure the lock is released when an exception occurs. Change-Id: Id4af1d4950f604f47b11fdd7d84f94f769aecd4d
* Fix pylint warnings in stream.pyDavid Pursehouse2012-10-231-6/+10
| | | | Change-Id: I7ad27a83d5af3eaca7a188e01cbef392c9ff1b6b
* Basic thread-safeness in the SSH clientDavid Pursehouse2012-10-231-1/+6
| | | | | | Add a lock around calls to the run_gerrit_command method. Change-Id: I9429ed880e14a4248b08937969f8faebc2240f79
* 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
* Get Gerrit version during client initialisationDavid Pursehouse2012-10-171-0/+17
| | | | | | | | Later the client might have functionality that only works on certain versions of Gerrit. Store the Gerrit version during initialisation. Change-Id: Idcd35baf00d6cd583f6f85b68c4b0a0c3653344b
* Add query functionalityDavid Pursehouse2012-10-172-0/+49
| | | | | | | Add a method that calls `gerrit query` and returns the results as a list of Change objects. Change-Id: Ie58a61e569d457c56109e34041e9db95147de91c
* Add __str__ on event base classDavid Pursehouse2012-10-161-0/+3
| | | | Change-Id: I26f1c11223b4271c3e5a74c9333a1f7513c5acab
* Move SSH client from stream class to main client classDavid Pursehouse2012-10-162-7/+7
| | | | | | | So it can be reused in query functionality that will be added later. Change-Id: I361aaf8fe8aa9107a94757606a3a1837b6a448ab
* Add license informationDavid Pursehouse2012-09-207-7/+176
| | | | Change-Id: I25ce3fafe7a51d0221f66fe30b2fb7cc8115c4aa
* Wait for thread to complete when stopping streamDavid Pursehouse2012-09-121-0/+1
| | | | Change-Id: I19eac2b83fc0fd6771c703de087b94de372f45af
* 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
* Fix event registration from other moduleDavid Pursehouse2012-09-121-3/+7
| | | | | | | | | | | | | | | | | | | The purpose of the `register` decorator in the event factory is to allow client scripts to define their own event classes and have them dispatched when monitoring the event stream. The current implementation does not work when an event class is registered from another module, because it uses globals() which only returns the symbols defined in the event module, so trying to instantiate the object causes an exception. Change the implementation to also store the module name when registering, and then use that when instantiating the event object. Add unit tests to cover the event registration functionality. Change-Id: I1af901621b07fc9236bc95a81956269507994871
* Refactor event stream handling to use SSH clientDavid Pursehouse2012-09-112-68/+47
| | | | Change-Id: I4953be92719fddeb7c23c2559ffe954c452cc131
* Handle invalid port in ssh configDavid Pursehouse2012-09-041-1/+5
| | | | | | | Raise an exception if the ssh config specifies an invalid ssh port number. Change-Id: I64fae04c91838a0f9c478ac9de19973e1499ed7e
* Add GerritSSHClientDavid Pursehouse2012-09-031-0/+53
| | | | | | | | | | Add initial version of GerritSSHClient, which is a wrapper for paramiko's SSHClient. The class derives from SSHClient and configures the ssh connection from the user's ssh config file. Change-Id: I54a193e41356de272c95c5288ed2c9e50a776cdf
* Add initial stub of GerritClient classDavid Pursehouse2012-08-241-0/+43
| | | | | | | | | | | The Gerrit client class will be used as an interface to the Gerrit events stream and query functionality. This is the intial stub. More functionality will be added, and existing stream functionality refactored, in later commits. Change-Id: If4ef838c2d3f3e5afaad2a553af49b1c66ad4278
* Inject event name into event classes with decoratorDavid Pursehouse2012-08-221-0/+1
| | | | | | | Use the event factory's register decorator to inject the name of the event into the event class. Change-Id: Ia40568bc3dd226f4fe250dccd394a79334255319
* Revert "GerritEventFactory should be a singleton"David Pursehouse2012-08-221-8/+0
| | | | | | Actually, no, it shouldn't. This reverts commit 66c505985742d8472d236f493ac1139a9ae287ca.
* GerritEventFactory should be a singletonDavid Pursehouse2012-08-081-0/+8
| | | | | | | Make the event factory a singleton, and add unit tests to verify that it is. Change-Id: Ieee026b9f7e1d408ade47106b71c352e7bfabdd4
* 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 support for topic name in change attributeDavid Pursehouse2012-08-021-0/+1
| | | | | | | Change attributes can include a "topic" field. Add support for this in the Change model. Change-Id: I31f0c19f92505bf4976f6d0008a94e06d30a48bb
* Add event factory and refactor event dispatchingDavid Pursehouse2012-08-022-50/+65
| | | | | | | | | | | | | | | 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
* Add helper methods for initialisation from json dataDavid Pursehouse2012-08-013-59/+58
| | | | | | | | Added helper methods to initialise model member variables. Now the models' constructors will not throw exception if a value is missing, but instead just initialise the variable to None. Change-Id: I7473ec9bb471f95ea0142067af4750c7e26a0339
* Tidy up docstrings to follow the PEP-257 docstring convention0.0.2David Pursehouse2012-07-314-67/+49
| | | | | | http://www.python.org/dev/peps/pep-0257/ Change-Id: I1469a94f01660ef00aac196a5ca8995b3803a4bd
* Refactor into submodulesDavid Pursehouse2012-07-315-0/+347
Data models, events, errors, and stream handler are split from the single module into submodules. Change-Id: I03537c5e268135966c6b6e77ecaca1cb579a5fde