[entropy.transceivers] do not mandate to test the connection on __init__()

Besides making context support complex, it doesn't do any good because
connectivity errors are generally transient anyway (apart from misconfigs).
This commit is contained in:
Fabio Erculiani
2013-07-17 09:47:28 +02:00
parent 5afdea550d
commit 4e482dc339
3 changed files with 0 additions and 28 deletions

View File

@@ -71,11 +71,6 @@ class EntropyFtpUriHandler(EntropyUriHandler):
self._init_vars()
# as documentation suggests
# test out connection first
self._connect()
self._disconnect()
def __enter__(self):
pass # self.__connect_if_not()

View File

@@ -63,32 +63,12 @@ class EntropySshUriHandler(EntropyUriHandler):
self.__user, self.__port, self.__dir = self.__extract_scp_data(
self._uri)
# as documentation suggests
# test out connection first
self.__test_connection()
def __enter__(self):
pass
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def __test_connection(self):
tries = 5
while tries:
tries -= 1
try:
sock = self._socket.create_connection(
(self.__host, self.__port), 5)
sock.close()
return
except self._socket.error:
time.sleep(5)
continue
raise TransceiverConnectionError("cannot connect to %s on port %s" % (
self.__host, self.__port,))
def __extract_scp_data(self, uri):
no_ssh_split = uri.split("ssh://")[-1]

View File

@@ -30,9 +30,6 @@ class EntropyUriHandler(TextInterface):
def __init__(self, uri):
"""
EntropyUriHandler constructor.
When constructor is called, instance should perform a connection and
permissions check and raise TransceiverConnectionError in case
of issues.
@param uri: URI to handle
@type uri: string