Rev 3023: Fix bug #164567 by catching connection errors. in file:///v/home/vila/src/bzr/bugs/164567/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Sun Nov 25 14:42:31 GMT 2007
At file:///v/home/vila/src/bzr/bugs/164567/
------------------------------------------------------------
revno: 3023
revision-id:v.ladeuil+lp at free.fr-20071125144229-kjnttz1wq4f1pls1
parent: v.ladeuil+lp at free.fr-20071125143444-krzhbakbps9f5tkl
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 164567
timestamp: Sun 2007-11-25 15:42:29 +0100
message:
Fix bug #164567 by catching connection errors.
* bzrlib/tests/test_transport_implementations.py:
(TransportTests.test_connection_error): Fix doc string.
* bzrlib/transport/ftp.py:
Add missing imports.
(FtpTransport._create_connection): Catch socket.error to detect
connection errors.
modified:
bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
bzrlib/transport/ftp.py ftp.py-20051116161804-58dc9506548c2a53
-------------- next part --------------
=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py 2007-11-23 04:56:43 +0000
+++ b/bzrlib/tests/test_transport_implementations.py 2007-11-25 14:42:29 +0000
@@ -1005,8 +1005,7 @@
def test_connection_error(self):
"""ConnectionError is raised when connection is impossible.
- The error may be raised from either the constructor or the first
- operation on the transport.
+ The error should be raised from the first operation on the transport.
"""
try:
url = self._server.get_bogus_url()
=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py 2007-11-04 15:29:17 +0000
+++ b/bzrlib/transport/ftp.py 2007-11-25 14:42:29 +0000
@@ -27,9 +27,11 @@
from cStringIO import StringIO
import errno
import ftplib
+import getpass
import os
import os.path
import urlparse
+import socket
import stat
import time
import random
@@ -141,6 +143,10 @@
port=self._port)
connection.login(user=user, passwd=password)
connection.set_pasv(not self.is_active)
+ except socket.error, e:
+ raise errors.ConnectionError(
+ 'failed to connect to %s:%d' % (self._host, self._port),
+ orig_error= e)
except ftplib.error_perm, e:
raise errors.TransportError(msg="Error setting up connection:"
" %s" % str(e), orig_error=e)
More information about the bazaar-commits
mailing list