From fa8cbd69f5b352f954031995b69f6ef45353731b Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 3 Jan 2010 17:30:08 +0100 Subject: [PATCH] [entropy.transceivers] EntropySshUriHandler: add timeout handling --- .../uri_handlers/plugins/interfaces/ssh_plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/entropy/transceivers/uri_handlers/plugins/interfaces/ssh_plugin.py b/libraries/entropy/transceivers/uri_handlers/plugins/interfaces/ssh_plugin.py index 5df74b3b5..bcd34feed 100644 --- a/libraries/entropy/transceivers/uri_handlers/plugins/interfaces/ssh_plugin.py +++ b/libraries/entropy/transceivers/uri_handlers/plugins/interfaces/ssh_plugin.py @@ -13,6 +13,7 @@ import os import time import tempfile +from entropy.const import const_isnumber from entropy.output import brown, darkgreen from entropy.i18n import _ from entropy.exceptions import ConnectionError @@ -50,6 +51,7 @@ class EntropySshUriHandler(EntropyUriHandler): def __init__(self, uri): EntropyUriHandler.__init__(self, uri) + self._timeout = EntropySshUriHandler._DEFAULT_TIMEOUT import socket, subprocess, pty self._socket, self._subprocess = socket, subprocess self._pty = pty @@ -193,6 +195,8 @@ class EntropySshUriHandler(EntropyUriHandler): def _setup_common_args(self, remote_path): args = [] + if const_isnumber(self._timeout): + args += ["-o", "ConnectTimeout=%s" % (self._timeout,)] if self._speed_limit: args += ["-l", str(self._speed_limit*8)] # scp wants kbits/sec remote_ptr = os.path.join(self.__dir, remote_path)