summaryrefslogtreecommitdiff
path: root/pygerrit/ssh.py
Commit message (Collapse)AuthorAgeFilesLines
* Add support for automatically adding known_hostsChris Opland2019-04-121-2/+5
| | | | | | | | | | | | Currently, if a server is not in the known_hosts file then the client will fail with an error like: paramiko.SSHException: Server '[<host>]:<port>' not found in known_hosts This change allows users to configure paramiko with the AutoAddPolicy(). It should be noted that using this policy opens users to man-in-the-middle attacks, which is why it is an optional setting and defaults to False.
* Add keepalive support to GerritSSHClientVineet Naik2015-06-301-1/+4
| | | | | | | This will allow keeping the SSH sessions alive for a duration of time longer than the timeout configured for the server. Change-Id: I9d86c0fc304783fab944ebae7bd0da8f3b1edd6c
* Allow unicode characters in gerrit commandsNikki Heald2015-04-061-0/+6
| | | | | | | | | Trying to use pygerrit to submit reviews fails if there is a unicode character in the review comment. This change sees if the message is valid ascii, and if it's not, encodes as utf-8. Change-Id: Ia14d59d28b11a78bee9d89fd84fb09976015787f
* Bump pep8 to 1.5.7David Pursehouse2014-10-271-1/+1
| | | | | | And fix a couple of newly discovered warnings. Change-Id: I835d16ed94f2e20f003a2aa0b0370483d02e7926
* Add support for ProxyCommand in GerritSSHClient0.2.6Alexander D. Kanevskiy2014-05-291-2/+6
| | | | Change-Id: I776a58b2cdac17e3eafc985ee727cd88e8294ccc
* Revert "Remove support for Gerrit over ssh"David Pursehouse2014-05-291-0/+178
| | | | | | | | | | | | | | | | | | | | | 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-178/+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
* 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