Rev 5438: (spiv) Simplify connect_ssh/sftp error handling (Andrew Bennetts) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Sep 21 10:32:47 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5438 [merge]
revision-id: pqm at pqm.ubuntu.com-20100921093244-q0290ai8j4s3lo1v
parent: pqm at pqm.ubuntu.com-20100921081716-phuyp6i3ull8eng1
parent: andrew.bennetts at canonical.com-20100917074008-i2lz3i0sfat2g725
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2010-09-21 10:32:44 +0100
message:
(spiv) Simplify connect_ssh/sftp error handling (Andrew Bennetts)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/transport/ssh.py ssh.py-20060824042150-0s9787kng6zv1nwq-1
=== modified file 'NEWS'
--- a/NEWS 2010-09-20 13:31:09 +0000
+++ b/NEWS 2010-09-21 09:32:44 +0000
@@ -311,6 +311,9 @@
be available from ``bzrlib.tests.*``. They used to be, but were
accidentally removed. (John Arbash Meinel, #627438)
+* Treat all IO, OS, and socket errors consistently when establishing
+ SSH/SFTP connections via a subprocess. (Andrew Bennetts)
+
* ``Transport.stat`` on a symlink, including a transport pointing directly
to a symlink, now returns information about the symlink.
(Martin Pool)
=== modified file 'bzrlib/transport/ssh.py'
--- a/bzrlib/transport/ssh.py 2010-09-15 10:10:22 +0000
+++ b/bzrlib/transport/ssh.py 2010-09-17 07:40:08 +0000
@@ -336,15 +336,14 @@
self._raise_connection_error(host, port=port, orig_error=e,
msg='Unable to invoke remote bzr')
+_ssh_connection_errors = (EOFError, OSError, IOError, socket.error)
if paramiko is not None:
vendor = ParamikoVendor()
register_ssh_vendor('paramiko', vendor)
register_ssh_vendor('none', vendor)
register_default_ssh_vendor(vendor)
- _sftp_connection_errors = (EOFError, paramiko.SSHException)
+ _ssh_connection_errors += (paramiko.SSHException,)
del vendor
-else:
- _sftp_connection_errors = (EOFError,)
class SubprocessVendor(SSHVendor):
@@ -375,14 +374,7 @@
subsystem='sftp')
sock = self._connect(argv)
return SFTPClient(SocketAsChannelAdapter(sock))
- except _sftp_connection_errors, e:
- self._raise_connection_error(host, port=port, orig_error=e)
- except (OSError, IOError, socket.error), e:
- # If the machine is fast enough, ssh can actually exit
- # before we try and send it the sftp request, which
- # raises a Broken Pipe
- if e.errno not in (errno.EPIPE,):
- raise
+ except _ssh_connection_errors, e:
self._raise_connection_error(host, port=port, orig_error=e)
def connect_ssh(self, username, password, host, port, command):
@@ -390,14 +382,7 @@
argv = self._get_vendor_specific_argv(username, host, port,
command=command)
return self._connect(argv)
- except (EOFError), e:
- self._raise_connection_error(host, port=port, orig_error=e)
- except (OSError, IOError, socket.error), e:
- # If the machine is fast enough, ssh can actually exit
- # before we try and send it the sftp request, which
- # raises a Broken Pipe
- if e.errno not in (errno.EPIPE,):
- raise
+ except _ssh_connection_errors, e:
self._raise_connection_error(host, port=port, orig_error=e)
def _get_vendor_specific_argv(self, username, host, port, subsystem=None,
More information about the bazaar-commits
mailing list