~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-05-18 18:20:31 UTC
  • mto: (2485.8.44 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070518182031-gbg2cgidv5l20x9p
Takes Robert comments into account.

* bzrlib/transport/ftp.py:
(FtpTransport.__init__): Write a better explanation.

* bzrlib/tests/test_init.py:
(InstrumentedTransport): Just make hooks a class attribute.
(InstrumentedTransport._get_FTP): Run hook directly in the for
loop.
(TransportHooks.run_hook, TransportHooks.uninstall_hook): Not
needed. The hooks should be cleaned up by the test itself.
(TestInit.setUp.cleanup): Resset to default hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import time
35
35
import urllib
36
36
import urlparse
 
37
import weakref
37
38
 
38
39
from bzrlib import (
39
40
    errors,
47
48
                           ParamikoNotPresent,
48
49
                           )
49
50
from bzrlib.osutils import pathjoin, fancy_rename, getcwd
50
 
from bzrlib.symbol_versioning import (
51
 
        deprecated_function,
52
 
        zero_nineteen,
53
 
        )
54
51
from bzrlib.trace import mutter, warning
55
52
from bzrlib.transport import (
56
53
    local,
57
54
    register_urlparse_netloc_protocol,
58
55
    Server,
 
56
    split_url,
59
57
    ssh,
60
 
    ConnectedTransport,
 
58
    Transport,
61
59
    )
62
60
 
63
61
try:
75
73
register_urlparse_netloc_protocol('sftp')
76
74
 
77
75
 
 
76
# This is a weakref dictionary, so that we can reuse connections
 
77
# that are still active. Long term, it might be nice to have some
 
78
# sort of expiration policy, such as disconnect if inactive for
 
79
# X seconds. But that requires a lot more fanciness.
 
80
_connected_hosts = weakref.WeakValueDictionary()
 
81
 
 
82
 
78
83
_paramiko_version = getattr(paramiko, '__version_info__', (0, 0, 0))
79
84
# don't use prefetch unless paramiko version >= 1.5.5 (there were bugs earlier)
80
85
_default_do_prefetch = (_paramiko_version >= (1, 5, 5))
81
86
 
82
87
 
83
 
@deprecated_function(zero_nineteen)
84
88
def clear_connection_cache():
85
89
    """Remove all hosts from the SFTP connection cache.
86
90
 
87
91
    Primarily useful for test cases wanting to force garbage collection.
88
 
    We don't have a global connection cache anymore.
89
92
    """
 
93
    _connected_hosts.clear()
 
94
 
90
95
 
91
96
class SFTPLock(object):
92
97
    """This fakes a lock in a remote location.
130
135
            pass
131
136
 
132
137
 
133
 
class SFTPTransport(ConnectedTransport):
 
138
class SFTPUrlHandling(Transport):
 
139
    """Mix-in that does common handling of SSH/SFTP URLs."""
 
140
 
 
141
    def __init__(self, base):
 
142
        self._parse_url(base)
 
143
        base = self._unparse_url(self._path)
 
144
        if base[-1] != '/':
 
145
            base += '/'
 
146
        super(SFTPUrlHandling, self).__init__(base)
 
147
 
 
148
    def _parse_url(self, url):
 
149
        (self._scheme,
 
150
         self._username, self._password,
 
151
         self._host, self._port, self._path) = self._split_url(url)
 
152
 
 
153
    def _unparse_url(self, path):
 
154
        """Return a URL for a path relative to this transport.
 
155
        """
 
156
        path = urllib.quote(path)
 
157
        # handle homedir paths
 
158
        if not path.startswith('/'):
 
159
            path = "/~/" + path
 
160
        netloc = urllib.quote(self._host)
 
161
        if self._username is not None:
 
162
            netloc = '%s@%s' % (urllib.quote(self._username), netloc)
 
163
        if self._port is not None:
 
164
            netloc = '%s:%d' % (netloc, self._port)
 
165
        return urlparse.urlunparse((self._scheme, netloc, path, '', '', ''))
 
166
 
 
167
    def _split_url(self, url):
 
168
        (scheme, username, password, host, port, path) = split_url(url)
 
169
        ## assert scheme == 'sftp'
 
170
 
 
171
        # the initial slash should be removed from the path, and treated
 
172
        # as a homedir relative path (the path begins with a double slash
 
173
        # if it is absolute).
 
174
        # see draft-ietf-secsh-scp-sftp-ssh-uri-03.txt
 
175
        # RBC 20060118 we are not using this as its too user hostile. instead
 
176
        # we are following lftp and using /~/foo to mean '~/foo'.
 
177
        # handle homedir paths
 
178
        if path.startswith('/~/'):
 
179
            path = path[3:]
 
180
        elif path == '/~':
 
181
            path = ''
 
182
        return (scheme, username, password, host, port, path)
 
183
 
 
184
    def abspath(self, relpath):
 
185
        """Return the full url to the given relative path.
 
186
        
 
187
        @param relpath: the relative path or path components
 
188
        @type relpath: str or list
 
189
        """
 
190
        return self._unparse_url(self._remote_path(relpath))
 
191
    
 
192
    def _remote_path(self, relpath):
 
193
        """Return the path to be passed along the sftp protocol for relpath.
 
194
        
 
195
        :param relpath: is a urlencoded string.
 
196
        """
 
197
        return self._combine_paths(self._path, relpath)
 
198
 
 
199
 
 
200
class SFTPTransport(SFTPUrlHandling):
134
201
    """Transport implementation for SFTP access."""
135
202
 
136
203
    _do_prefetch = _default_do_prefetch
151
218
    # up the request itself, rather than us having to worry about it
152
219
    _max_request_size = 32768
153
220
 
154
 
    def __init__(self, base, _from_transport=None):
155
 
        assert base.startswith('sftp://')
156
 
        super(SFTPTransport, self).__init__(base,
157
 
                                            _from_transport=_from_transport)
158
 
 
159
 
    def _remote_path(self, relpath):
160
 
        """Return the path to be passed along the sftp protocol for relpath.
161
 
        
162
 
        :param relpath: is a urlencoded string.
163
 
        """
164
 
        relative = urlutils.unescape(relpath).encode('utf-8')
165
 
        remote_path = self._combine_paths(self._path, relative)
166
 
        # the initial slash should be removed from the path, and treated as a
167
 
        # homedir relative path (the path begins with a double slash if it is
168
 
        # absolute).  see draft-ietf-secsh-scp-sftp-ssh-uri-03.txt
169
 
        # RBC 20060118 we are not using this as its too user hostile. instead
170
 
        # we are following lftp and using /~/foo to mean '~/foo'
171
 
        # vila--20070602 and leave absolute paths begin with a single slash.
172
 
        if remote_path.startswith('/~/'):
173
 
            remote_path = remote_path[3:]
174
 
        elif remote_path == '/~':
175
 
            remote_path = ''
176
 
        return remote_path
177
 
 
178
 
    def _create_connection(self, credentials=None):
179
 
        """Create a new connection with the provided credentials.
180
 
 
181
 
        :param credentials: The credentials needed to establish the connection.
182
 
 
183
 
        :return: The created connection and its associated credentials.
184
 
 
185
 
        The credentials are only the password as it may have been entered
186
 
        interactively by the user and may be different from the one provided
187
 
        in base url at transport creation time.
188
 
        """
189
 
        if credentials is None:
190
 
            password = self._password
 
221
    def __init__(self, base, clone_from=None):
 
222
        super(SFTPTransport, self).__init__(base)
 
223
        if clone_from is None:
 
224
            self._sftp_connect()
191
225
        else:
192
 
            password = credentials
193
 
 
194
 
        vendor = ssh._get_ssh_vendor()
195
 
        connection = vendor.connect_sftp(self._user, password,
196
 
                                         self._host, self._port)
197
 
        return connection, password
198
 
 
199
 
    def _get_sftp(self):
200
 
        """Ensures that a connection is established"""
201
 
        connection = self._get_connection()
202
 
        if connection is None:
203
 
            # First connection ever
204
 
            connection, credentials = self._create_connection()
205
 
            self._set_connection(connection, credentials)
206
 
        return connection
207
 
 
208
 
 
 
226
            # use the same ssh connection, etc
 
227
            self._sftp = clone_from._sftp
 
228
        # super saves 'self.base'
 
229
    
209
230
    def should_cache(self):
210
231
        """
211
232
        Return True if the data pulled across should be cached locally.
212
233
        """
213
234
        return True
214
235
 
 
236
    def clone(self, offset=None):
 
237
        """
 
238
        Return a new SFTPTransport with root at self.base + offset.
 
239
        We share the same SFTP session between such transports, because it's
 
240
        fairly expensive to set them up.
 
241
        """
 
242
        if offset is None:
 
243
            return SFTPTransport(self.base, self)
 
244
        else:
 
245
            return SFTPTransport(self.abspath(offset), self)
 
246
 
 
247
    def _remote_path(self, relpath):
 
248
        """Return the path to be passed along the sftp protocol for relpath.
 
249
        
 
250
        relpath is a urlencoded string.
 
251
 
 
252
        :return: a path prefixed with / for regular abspath-based urls, or a
 
253
            path that does not begin with / for urls which begin with /~/.
 
254
        """
 
255
        # how does this work? 
 
256
        # it processes relpath with respect to 
 
257
        # our state:
 
258
        # firstly we create a path to evaluate: 
 
259
        # if relpath is an abspath or homedir path, its the entire thing
 
260
        # otherwise we join our base with relpath
 
261
        # then we eliminate all empty segments (double //'s) outside the first
 
262
        # two elements of the list. This avoids problems with trailing 
 
263
        # slashes, or other abnormalities.
 
264
        # finally we evaluate the entire path in a single pass
 
265
        # '.'s are stripped,
 
266
        # '..' result in popping the left most already 
 
267
        # processed path (which can never be empty because of the check for
 
268
        # abspath and homedir meaning that its not, or that we've used our
 
269
        # path. If the pop would pop the root, we ignore it.
 
270
 
 
271
        # Specific case examinations:
 
272
        # remove the special casefor ~: if the current root is ~/ popping of it
 
273
        # = / thus our seed for a ~ based path is ['', '~']
 
274
        # and if we end up with [''] then we had basically ('', '..') (which is
 
275
        # '/..' so we append '' if the length is one, and assert that the first
 
276
        # element is still ''. Lastly, if we end with ['', '~'] as a prefix for
 
277
        # the output, we've got a homedir path, so we strip that prefix before
 
278
        # '/' joining the resulting list.
 
279
        #
 
280
        # case one: '/' -> ['', ''] cannot shrink
 
281
        # case two: '/' + '../foo' -> ['', 'foo'] (take '', '', '..', 'foo')
 
282
        #           and pop the second '' for the '..', append 'foo'
 
283
        # case three: '/~/' -> ['', '~', ''] 
 
284
        # case four: '/~/' + '../foo' -> ['', '~', '', '..', 'foo'],
 
285
        #           and we want to get '/foo' - the empty path in the middle
 
286
        #           needs to be stripped, then normal path manipulation will 
 
287
        #           work.
 
288
        # case five: '/..' ['', '..'], we want ['', '']
 
289
        #            stripping '' outside the first two is ok
 
290
        #            ignore .. if its too high up
 
291
        #
 
292
        # lastly this code is possibly reusable by FTP, but not reusable by
 
293
        # local paths: ~ is resolvable correctly, nor by HTTP or the smart
 
294
        # server: ~ is resolved remotely.
 
295
        # 
 
296
        # however, a version of this that acts on self.base is possible to be
 
297
        # written which manipulates the URL in canonical form, and would be
 
298
        # reusable for all transports, if a flag for allowing ~/ at all was
 
299
        # provided.
 
300
        assert isinstance(relpath, basestring)
 
301
        relpath = urlutils.unescape(relpath)
 
302
 
 
303
        # case 1)
 
304
        if relpath.startswith('/'):
 
305
            # abspath - normal split is fine.
 
306
            current_path = relpath.split('/')
 
307
        elif relpath.startswith('~/'):
 
308
            # root is homedir based: normal split and prefix '' to remote the
 
309
            # special case
 
310
            current_path = [''].extend(relpath.split('/'))
 
311
        else:
 
312
            # root is from the current directory:
 
313
            if self._path.startswith('/'):
 
314
                # abspath, take the regular split
 
315
                current_path = []
 
316
            else:
 
317
                # homedir based, add the '', '~' not present in self._path
 
318
                current_path = ['', '~']
 
319
            # add our current dir
 
320
            current_path.extend(self._path.split('/'))
 
321
            # add the users relpath
 
322
            current_path.extend(relpath.split('/'))
 
323
        # strip '' segments that are not in the first one - the leading /.
 
324
        to_process = current_path[:1]
 
325
        for segment in current_path[1:]:
 
326
            if segment != '':
 
327
                to_process.append(segment)
 
328
 
 
329
        # process '.' and '..' segments into output_path.
 
330
        output_path = []
 
331
        for segment in to_process:
 
332
            if segment == '..':
 
333
                # directory pop. Remove a directory 
 
334
                # as long as we are not at the root
 
335
                if len(output_path) > 1:
 
336
                    output_path.pop()
 
337
                # else: pass
 
338
                # cannot pop beyond the root, so do nothing
 
339
            elif segment == '.':
 
340
                continue # strip the '.' from the output.
 
341
            else:
 
342
                # this will append '' to output_path for the root elements,
 
343
                # which is appropriate: its why we strip '' in the first pass.
 
344
                output_path.append(segment)
 
345
 
 
346
        # check output special cases:
 
347
        if output_path == ['']:
 
348
            # [''] -> ['', '']
 
349
            output_path = ['', '']
 
350
        elif output_path[:2] == ['', '~']:
 
351
            # ['', '~', ...] -> ...
 
352
            output_path = output_path[2:]
 
353
        path = '/'.join(output_path)
 
354
        return path
 
355
 
 
356
    def relpath(self, abspath):
 
357
        scheme, username, password, host, port, path = self._split_url(abspath)
 
358
        error = []
 
359
        if (username != self._username):
 
360
            error.append('username mismatch')
 
361
        if (host != self._host):
 
362
            error.append('host mismatch')
 
363
        if (port != self._port):
 
364
            error.append('port mismatch')
 
365
        if (not path.startswith(self._path)):
 
366
            error.append('path mismatch')
 
367
        if error:
 
368
            extra = ': ' + ', '.join(error)
 
369
            raise PathNotChild(abspath, self.base, extra=extra)
 
370
        pl = len(self._path)
 
371
        return path[pl:].strip('/')
 
372
 
215
373
    def has(self, relpath):
216
374
        """
217
375
        Does the target location exist?
218
376
        """
219
377
        try:
220
 
            self._get_sftp().stat(self._remote_path(relpath))
 
378
            self._sftp.stat(self._remote_path(relpath))
221
379
            return True
222
380
        except IOError:
223
381
            return False
230
388
        """
231
389
        try:
232
390
            path = self._remote_path(relpath)
233
 
            f = self._get_sftp().file(path, mode='rb')
 
391
            f = self._sftp.file(path, mode='rb')
234
392
            if self._do_prefetch and (getattr(f, 'prefetch', None) is not None):
235
393
                f.prefetch()
236
394
            return f
237
395
        except (IOError, paramiko.SSHException), e:
238
 
            self._translate_io_exception(e, path, ': error retrieving',
239
 
                failure_exc=errors.ReadError)
 
396
            self._translate_io_exception(e, path, ': error retrieving')
240
397
 
241
398
    def readv(self, relpath, offsets):
242
399
        """See Transport.readv()"""
248
405
 
249
406
        try:
250
407
            path = self._remote_path(relpath)
251
 
            fp = self._get_sftp().file(path, mode='rb')
 
408
            fp = self._sftp.file(path, mode='rb')
252
409
            readv = getattr(fp, 'readv', None)
253
410
            if readv:
254
411
                return self._sftp_readv(fp, offsets, relpath)
397
554
            # Because we set_pipelined() earlier, theoretically we might 
398
555
            # avoid the round trip for fout.close()
399
556
            if mode is not None:
400
 
                self._get_sftp().chmod(tmp_abspath, mode)
 
557
                self._sftp.chmod(tmp_abspath, mode)
401
558
            fout.close()
402
559
            closed = True
403
560
            self._rename_and_overwrite(tmp_abspath, abspath)
412
569
            try:
413
570
                if not closed:
414
571
                    fout.close()
415
 
                self._get_sftp().remove(tmp_abspath)
 
572
                self._sftp.remove(tmp_abspath)
416
573
            except:
417
574
                # raise the saved except
418
575
                raise e
433
590
            fout = None
434
591
            try:
435
592
                try:
436
 
                    fout = self._get_sftp().file(abspath, mode='wb')
 
593
                    fout = self._sftp.file(abspath, mode='wb')
437
594
                    fout.set_pipelined(True)
438
595
                    writer(fout)
439
596
                except (paramiko.SSHException, IOError), e:
444
601
                # Because we set_pipelined() earlier, theoretically we might 
445
602
                # avoid the round trip for fout.close()
446
603
                if mode is not None:
447
 
                    self._get_sftp().chmod(abspath, mode)
 
604
                    self._sftp.chmod(abspath, mode)
448
605
            finally:
449
606
                if fout is not None:
450
607
                    fout.close()
514
671
        else:
515
672
            local_mode = mode
516
673
        try:
517
 
            self._get_sftp().mkdir(abspath, local_mode)
 
674
            self._sftp.mkdir(abspath, local_mode)
518
675
            if mode is not None:
519
 
                self._get_sftp().chmod(abspath, mode=mode)
 
676
                self._sftp.chmod(abspath, mode=mode)
520
677
        except (paramiko.SSHException, IOError), e:
521
678
            self._translate_io_exception(e, abspath, ': unable to mkdir',
522
679
                failure_exc=FileExists)
525
682
        """Create a directory at the given path."""
526
683
        self._mkdir(self._remote_path(relpath), mode=mode)
527
684
 
528
 
    def _translate_io_exception(self, e, path, more_info='',
 
685
    def _translate_io_exception(self, e, path, more_info='', 
529
686
                                failure_exc=PathError):
530
687
        """Translate a paramiko or IOError into a friendlier exception.
531
688
 
562
719
        """
563
720
        try:
564
721
            path = self._remote_path(relpath)
565
 
            fout = self._get_sftp().file(path, 'ab')
 
722
            fout = self._sftp.file(path, 'ab')
566
723
            if mode is not None:
567
 
                self._get_sftp().chmod(path, mode)
 
724
                self._sftp.chmod(path, mode)
568
725
            result = fout.tell()
569
726
            self._pump(f, fout)
570
727
            return result
574
731
    def rename(self, rel_from, rel_to):
575
732
        """Rename without special overwriting"""
576
733
        try:
577
 
            self._get_sftp().rename(self._remote_path(rel_from),
 
734
            self._sftp.rename(self._remote_path(rel_from),
578
735
                              self._remote_path(rel_to))
579
736
        except (IOError, paramiko.SSHException), e:
580
737
            self._translate_io_exception(e, rel_from,
586
743
        Using the implementation provided by osutils.
587
744
        """
588
745
        try:
589
 
            sftp = self._get_sftp()
590
746
            fancy_rename(abs_from, abs_to,
591
 
                         rename_func=sftp.rename,
592
 
                         unlink_func=sftp.remove)
 
747
                    rename_func=self._sftp.rename,
 
748
                    unlink_func=self._sftp.remove)
593
749
        except (IOError, paramiko.SSHException), e:
594
 
            self._translate_io_exception(e, abs_from,
595
 
                                         ': unable to rename to %r' % (abs_to))
 
750
            self._translate_io_exception(e, abs_from, ': unable to rename to %r' % (abs_to))
596
751
 
597
752
    def move(self, rel_from, rel_to):
598
753
        """Move the item at rel_from to the location at rel_to"""
604
759
        """Delete the item at relpath"""
605
760
        path = self._remote_path(relpath)
606
761
        try:
607
 
            self._get_sftp().remove(path)
 
762
            self._sftp.remove(path)
608
763
        except (IOError, paramiko.SSHException), e:
609
764
            self._translate_io_exception(e, path, ': unable to delete')
610
765
            
611
 
    def external_url(self):
612
 
        """See bzrlib.transport.Transport.external_url."""
613
 
        # the external path for SFTP is the base
614
 
        return self.base
615
 
 
616
766
    def listable(self):
617
767
        """Return True if this store supports listing."""
618
768
        return True
627
777
        # -- David Allouche 2006-08-11
628
778
        path = self._remote_path(relpath)
629
779
        try:
630
 
            entries = self._get_sftp().listdir(path)
 
780
            entries = self._sftp.listdir(path)
631
781
        except (IOError, paramiko.SSHException), e:
632
782
            self._translate_io_exception(e, path, ': failed to list_dir')
633
783
        return [urlutils.escape(entry) for entry in entries]
636
786
        """See Transport.rmdir."""
637
787
        path = self._remote_path(relpath)
638
788
        try:
639
 
            return self._get_sftp().rmdir(path)
 
789
            return self._sftp.rmdir(path)
640
790
        except (IOError, paramiko.SSHException), e:
641
791
            self._translate_io_exception(e, path, ': failed to rmdir')
642
792
 
644
794
        """Return the stat information for a file."""
645
795
        path = self._remote_path(relpath)
646
796
        try:
647
 
            return self._get_sftp().stat(path)
 
797
            return self._sftp.stat(path)
648
798
        except (IOError, paramiko.SSHException), e:
649
799
            self._translate_io_exception(e, path, ': unable to stat')
650
800
 
674
824
        # that we have taken the lock.
675
825
        return SFTPLock(relpath, self)
676
826
 
 
827
    def _sftp_connect(self):
 
828
        """Connect to the remote sftp server.
 
829
        After this, self._sftp should have a valid connection (or
 
830
        we raise an TransportError 'could not connect').
 
831
 
 
832
        TODO: Raise a more reasonable ConnectionFailed exception
 
833
        """
 
834
        self._sftp = _sftp_connect(self._host, self._port, self._username,
 
835
                self._password)
 
836
 
677
837
    def _sftp_open_exclusive(self, abspath, mode=None):
678
838
        """Open a remote path exclusively.
679
839
 
692
852
        #       using the 'x' flag to indicate SFTP_FLAG_EXCL.
693
853
        #       However, there is no way to set the permission mode at open 
694
854
        #       time using the sftp_client.file() functionality.
695
 
        path = self._get_sftp()._adjust_cwd(abspath)
 
855
        path = self._sftp._adjust_cwd(abspath)
696
856
        # mutter('sftp abspath %s => %s', abspath, path)
697
857
        attr = SFTPAttributes()
698
858
        if mode is not None:
700
860
        omode = (SFTP_FLAG_WRITE | SFTP_FLAG_CREATE 
701
861
                | SFTP_FLAG_TRUNC | SFTP_FLAG_EXCL)
702
862
        try:
703
 
            t, msg = self._get_sftp()._request(CMD_OPEN, path, omode, attr)
 
863
            t, msg = self._sftp._request(CMD_OPEN, path, omode, attr)
704
864
            if t != CMD_HANDLE:
705
865
                raise TransportError('Expected an SFTP handle')
706
866
            handle = msg.get_string()
707
 
            return SFTPFile(self._get_sftp(), handle, 'wb', -1)
 
867
            return SFTPFile(self._sftp, handle, 'wb', -1)
708
868
        except (paramiko.SSHException, IOError), e:
709
869
            self._translate_io_exception(e, abspath, ': unable to open',
710
870
                failure_exc=FileExists)
1036
1196
        super(SFTPSiblingAbsoluteServer, self).setUp(backing_server)
1037
1197
 
1038
1198
 
 
1199
def _sftp_connect(host, port, username, password):
 
1200
    """Connect to the remote sftp server.
 
1201
 
 
1202
    :raises: a TransportError 'could not connect'.
 
1203
 
 
1204
    :returns: an paramiko.sftp_client.SFTPClient
 
1205
 
 
1206
    TODO: Raise a more reasonable ConnectionFailed exception
 
1207
    """
 
1208
    idx = (host, port, username)
 
1209
    try:
 
1210
        return _connected_hosts[idx]
 
1211
    except KeyError:
 
1212
        pass
 
1213
    
 
1214
    sftp = _sftp_connect_uncached(host, port, username, password)
 
1215
    _connected_hosts[idx] = sftp
 
1216
    return sftp
 
1217
 
 
1218
def _sftp_connect_uncached(host, port, username, password):
 
1219
    vendor = ssh._get_ssh_vendor()
 
1220
    sftp = vendor.connect_sftp(username, password, host, port)
 
1221
    return sftp
 
1222
 
 
1223
 
1039
1224
def get_test_permutations():
1040
1225
    """Return the permutations to be used in testing."""
1041
1226
    return [(SFTPTransport, SFTPAbsoluteServer),