[patch] let hpss tests pass without paramiko present

Martin Pool mbp at canonical.com
Wed Oct 4 07:49:17 BST 2006


One of the smart server tests was only declared if paramiko is present,
but in fact it's OK to declare it always.  In any case we can cope
without paramiko using an external ssh client.  get_ssh_vendor will fail
if none can be found at runtime.

-- 
Martin
-------------- next part --------------
=== modified file 'bzrlib/transport/smart.py'
--- bzrlib/transport/smart.py	2006-10-04 02:01:11 +0000
+++ bzrlib/transport/smart.py	2006-10-04 06:42:20 +0000
@@ -1027,36 +1027,31 @@
         if self._socket is not None:
             self._socket.close()
 
-try:
-    from bzrlib.transport import sftp, ssh
-except errors.ParamikoNotPresent:
-    # no paramiko, no SSHTransport.
-    pass
-else:
-    class SmartSSHTransport(SmartTransport):
-        """Connection to smart server over SSH."""
-
-        def __init__(self, url, clone_from=None):
-            # TODO: all this probably belongs in the parent class.
-            super(SmartSSHTransport, self).__init__(url, clone_from)
-            try:
-                if self._port is not None:
-                    self._port = int(self._port)
-            except (ValueError, TypeError), e:
-                raise errors.InvalidURL(path=url, extra="invalid port %s" % self._port)
-
-        def _connect_to_server(self):
-            executable = os.environ.get('BZR_REMOTE_PATH', 'bzr')
-            vendor = ssh._get_ssh_vendor()
-            self._ssh_connection = vendor.connect_ssh(self._username,
-                    self._password, self._host, self._port,
-                    command=[executable, 'serve', '--inet', '--directory=/',
-                             '--allow-writes'])
-            return self._ssh_connection.get_filelike_channels()
-
-        def disconnect(self):
-            super(SmartSSHTransport, self).disconnect()
-            self._ssh_connection.close()
+
+class SmartSSHTransport(SmartTransport):
+    """Connection to smart server over SSH."""
+
+    def __init__(self, url, clone_from=None):
+        # TODO: all this probably belongs in the parent class.
+        super(SmartSSHTransport, self).__init__(url, clone_from)
+        try:
+            if self._port is not None:
+                self._port = int(self._port)
+        except (ValueError, TypeError), e:
+            raise errors.InvalidURL(path=url, extra="invalid port %s" % self._port)
+
+    def _connect_to_server(self):
+        executable = os.environ.get('BZR_REMOTE_PATH', 'bzr')
+        vendor = ssh._get_ssh_vendor()
+        self._ssh_connection = vendor.connect_ssh(self._username,
+                self._password, self._host, self._port,
+                command=[executable, 'serve', '--inet', '--directory=/',
+                         '--allow-writes'])
+        return self._ssh_connection.get_filelike_channels()
+
+    def disconnect(self):
+        super(SmartSSHTransport, self).disconnect()
+        self._ssh_connection.close()
 
 
 def get_test_permutations():



More information about the bazaar mailing list