summaryrefslogtreecommitdiff
path: root/pygerrit
Commit message (Collapse)AuthorAgeFilesLines
...
| * Fix #10: Allow to manually specify ssh username and portDavid Pursehouse2013-09-122-12/+22
| | | | | | | | | | | | | | | | | | | | | | If the username and port are specified when constructing the client, they will be used instead of attempting to fetch from the ssh config file. In this case the full hostname of the server is required, rather than only the name as listed in the ssh config. Change-Id: I82b8638d99922c9b40a54a8275ffc085f505696f
| * Completely refactor the stream event handlingDavid Pursehouse2013-09-122-23/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Add missing __repr__ methods on ErrorEvent and UnhandledEventDavid Pursehouse2013-09-121-1/+7
| | | | | | | | | | | | Also fix a minor coding style issue. Change-Id: Ib366a816e5cf979eb94c7ce545d1c87c6c3984c8
| * Fix initialisation of error eventDavid Pursehouse2013-09-111-0/+1
| | | | | | | | Change-Id: I19e955c3ca7c84600ec89ff24d5c7458202ff609
| * Fix #11: correct handling of `identityfile` in the ssh configDavid Pursehouse2013-09-111-1/+1
| | | | | | | | | | | | | | | | The `identityfile` element of the result returned by SSHConfig.lookup() is a list, not a string, therefore calling `expanduser` on it results in a crash. Change-Id: I8673295d66cac9ca3b522867735b1211f0556d21
| * Fix #8: Support the "topic-changed" stream eventDavid Pursehouse2013-09-111-0/+23
| | | | | | | | Change-Id: I70b9cbea1da20a1434eea39e3d8e85e94357b792
| * Fix #7: Support the "reviewer-added" stream eventDavid Pursehouse2013-09-111-0/+20
| | | | | | | | Change-Id: I72ece72c08ddc6da31c14db35dd84f35d61d39ed
| * Fix #6: Support the "merge-failed" stream eventDavid Pursehouse2013-09-111-0/+21
| | | | | | | | Change-Id: I3308b44dc1bbfcaa70e38cb4857c2241c551cfa4
| * Fix #5: Move json parsing and error handling into the event factoryDavid Pursehouse2013-09-113-27/+40
| | | | | | | | | | | | | | | | | | | | 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 #3: Don't treat unhandled event types as errorsDavid Pursehouse2013-09-111-3/+11
| | | | | | | | | | | | | | | | If an unknown event is received on the event stream, for example if a new event has been added in a later version of Gerrit, do not raise an error. Instead, generate an "UnhandledEvent" event. Change-Id: Ia1902bf4a54883011b7ad3e004f58a2ba8739b21
| * Fix #4: Keep event's raw json data in the event objectDavid Pursehouse2013-09-111-9/+9
| | | | | | | | | | | | | | | | If any future versions of Gerrit add data elements that are not encapsulated by the event class, clients will be able to access them via the raw json data. Change-Id: Ia689acb808f9d200f53b86c60f024e865dd12a18
| * Add __repr__ methods on event and model classesDavid Pursehouse2013-09-112-3/+50
| | | | | | | | | | | | | | | | | | | | This gives more meaningful output when doing: print(event) and means it's not necessary to use str(event). Change-Id: I3c1546ab89c481bec24fbc4445ed7f33aa05eff8
| * Remove redundant `exec_command` methodDavid Pursehouse2013-09-111-15/+10
| | | | | | | | | | | | | | | | | | | | The `exec_command` overrides the method of the same name from the parent class unnecessarily. Remove it and call the parent `exec_command` method directly from the `run_gerrit_command` method. Change-Id: I977000a372c9b6e9143ca0e740b971a606a83146
| * Fix #2: Establish SSH connection in a thread-safe wayDavid Pursehouse2013-09-111-6/+20
| | | | | | | | | | | | | | | | | | Use an Event(), rather than a boolean, to determine whether or not the remote is connected. Protect the connection logic with a Lock(). Change-Id: Ifc5888894a90b7e3a11e21ec3f9bf69f0a7608a8
| * 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
* | Make get, put, post and delete REST methods publicDavid Pursehouse2013-09-121-4/+4
| | | | | | | | | | | | | | | | | | | | The initial intention was for these to only be used internally, and add wrapper methods to be used by clients. Instead, we now make them public, allowing the API to be used as a basic REST client before any wrappers are added. Change-Id: Icfa92125466b9b798ac30fb865d2d15a2892f552
* | Fix authentication setupDavid Pursehouse2013-08-271-5/+5
| | | | | | | | Change-Id: I8a7557818cd3c207035ef627e6912ee945c083c6
* | Add handling of HTTP error status codes in responsesDavid Pursehouse2013-08-271-0/+24
| | | | | | | | Change-Id: I9cdb6b7ff2bf6ea20925c5b2eac68ef454a6ea23
* | Add support for HTTP digest authenticationDavid Pursehouse2013-08-261-1/+41
| | | | | | | | | | | | | | If the username and password are given, pass them to the request with HTTP digest authentication. Change-Id: If15628262a4ef6b370c3d0794dbc9ecd3a0be624
* | 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