~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/stub_sftp.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-06-12 18:16:35 UTC
  • mfrom: (1185.84.3 bundles)
  • Revision ID: pqm@pqm.ubuntu.com-20060612181635-930f7114f61dbfcb
Hide diffs for old revisions in bundles

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import os
23
23
from paramiko import ServerInterface, SFTPServerInterface, SFTPServer, SFTPAttributes, \
24
24
    SFTPHandle, SFTP_OK, AUTH_SUCCESSFUL, OPEN_SUCCEEDED
 
25
 
25
26
from bzrlib.osutils import pathjoin
26
27
from bzrlib.trace import mutter
27
28
 
28
29
 
29
30
class StubServer (ServerInterface):
 
31
 
30
32
    def __init__(self, test_case):
31
33
        ServerInterface.__init__(self)
32
34
        self._test_case = test_case
59
61
 
60
62
 
61
63
class StubSFTPServer (SFTPServerInterface):
 
64
 
62
65
    def __init__(self, server, root, home=None):
63
66
        SFTPServerInterface.__init__(self, server)
64
67
        self.root = root
90
93
        path = self._realpath(path)
91
94
        try:
92
95
            out = [ ]
 
96
            # TODO: win32 incorrectly lists paths with non-ascii if path is not
 
97
            # unicode. However on Linux the server should only deal with
 
98
            # bytestreams and posix.listdir does the right thing 
93
99
            flist = os.listdir(path)
94
100
            for fname in flist:
95
101
                attr = SFTPAttributes.from_stat(os.stat(pathjoin(path, fname)))
124
130
                fd = os.open(path, flags)
125
131
        except OSError, e:
126
132
            return SFTPServer.convert_errno(e.errno)
 
133
 
127
134
        if (flags & os.O_CREAT) and (attr is not None):
128
135
            attr._flags &= ~attr.FLAG_PERMISSIONS
129
136
            SFTPServer.set_file_attr(path, attr)