/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/stub_sftp.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
    def list_folder(self, path):
136
136
        path = self._realpath(path)
137
137
        try:
138
 
            out = [ ]
 
138
            out = []
139
139
            # TODO: win32 incorrectly lists paths with non-ascii if path is not
140
140
            # unicode. However on unix the server should only deal with
141
141
            # bytestreams and posix.listdir does the right thing
224
224
            return paramiko.SFTPServer.convert_errno(e.errno)
225
225
        return paramiko.SFTP_OK
226
226
 
 
227
    def readlink(self, path):
 
228
        path = self._realpath(path)
 
229
        try:
 
230
            target_path = os.readlink(path)
 
231
        except OSError as e:
 
232
            return paramiko.SFTPServer.convert_errno(e.errno)
 
233
        return target_path
 
234
 
227
235
    def mkdir(self, path, attr):
228
236
        path = self._realpath(path)
229
237
        try:
248
256
            return paramiko.SFTPServer.convert_errno(e.errno)
249
257
        return paramiko.SFTP_OK
250
258
 
251
 
    # removed: chattr, symlink, readlink
 
259
    # removed: chattr
252
260
    # (nothing in bzr's sftp transport uses those)
253
261
 
254
262
 
388
396
        # Re-import these as locals, so that they're still accessible during
389
397
        # interpreter shutdown (when all module globals get set to None, leading
390
398
        # to confusing errors like "'NoneType' object has no attribute 'error'".
 
399
 
391
400
        class FakeChannel(object):
392
401
            def get_transport(self):
393
402
                return self
 
403
 
394
404
            def get_log_channel(self):
395
405
                return 'brz.paramiko'
 
406
 
396
407
            def get_name(self):
397
408
                return '1'
 
409
 
398
410
            def get_hexdump(self):
399
411
                return False
 
412
 
400
413
            def close(self):
401
414
                pass
402
415
 
405
418
            FakeChannel(), 'sftp', StubServer(tcs), StubSFTPServer,
406
419
            root=tcs._root, home=tcs._server_homedir)
407
420
        self.sftp_server = sftp_server
408
 
        sys_stderr = sys.stderr # Used in error reporting during shutdown
 
421
        sys_stderr = sys.stderr  # Used in error reporting during shutdown
409
422
        try:
410
423
            sftp_server.start_subsystem(
411
424
                'sftp', None, ssh.SocketAsChannelAdapter(self.request))
485
498
    def start_server(self, backing_server=None):
486
499
        # XXX: TODO: make sftpserver back onto backing_server rather than local
487
500
        # disk.
488
 
        if not (backing_server is None or
489
 
                isinstance(backing_server, test_server.LocalURLServer)):
 
501
        if not (backing_server is None
 
502
                or isinstance(backing_server, test_server.LocalURLServer)):
490
503
            raise AssertionError(
491
504
                'backing_server should not be %r, because this can only serve '
492
505
                'the local current working directory.' % (backing_server,))
576
589
        server = super(SFTPSiblingAbsoluteServer, self).create_server()
577
590
        server._server_homedir = '/dev/noone/runs/tests/here'
578
591
        return server
579