summaryrefslogtreecommitdiff
path: root/pygerrit/ssh.py
Commit message (Collapse)AuthorAgeFilesLines
* Add method to get username and Gerrit versionDavid Pursehouse2013-11-071-0/+5
| | | | | | | | | | If the username is not given in the constructor, it is detected from the ssh config. Add a method that allows the client to get the detected username that was used to connect to Gerrit. Change-Id: I15747d1446b07ce6b250f294fe72842a1be50a6c
* Fix #10: Allow to manually specify ssh username and portDavid Pursehouse2013-09-121-10/+20
| | | | | | | | | | | 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
* 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
* 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
* Don't put copyright and license headers in Python module docstringsDavid Pursehouse2013-08-071-25/+23
| | | | | | | | | | | | | | 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 pylint warningsDavid Pursehouse2013-08-061-2/+4
| | | | | | | | | | | | | | | - 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-061-1/+1
| | | | Change-Id: I6bc8d92ed1055959f1c24128b8beace814eaf998
* Only allow strings as query terms and commandsDavid Pursehouse2013-08-051-7/+6
| | | | Change-Id: I850978039ca10162a5ae2ab0a4f79374183107ba
* 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
* Add missing docstrings to conform to PEP-257David Pursehouse2013-08-041-1/+6
| | | | 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-251-1/+1
| | | | | | | | | | | | 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-241-3/+13
| | | | | | | | 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
* Refactor getting the Gerrit versionDavid Pursehouse2012-10-241-0/+31
| | | | | | | | | | | | | 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
* 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
* 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
* Add license informationDavid Pursehouse2012-09-201-1/+25
| | | | Change-Id: I25ce3fafe7a51d0221f66fe30b2fb7cc8115c4aa
* 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