~ubuntu-branches/ubuntu/lucid/bzr/lucid-proposed

« back to all changes in this revision

Viewing changes to bzrlib/tests/stub_sftp.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Bailey
  • Date: 2006-03-20 08:31:00 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060320083100-ovdi2ssuw0epcx8s
Tags: 0.8~200603200831-0ubuntu1
* Snapshot uploaded to Dapper at Martin Pool's request.

* Disable testsuite for upload.  Fakeroot and the testsuite don't
  play along.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
 
61
61
class StubSFTPServer (SFTPServerInterface):
62
 
    def __init__(self, server, root):
 
62
    def __init__(self, server, root, home=None):
63
63
        SFTPServerInterface.__init__(self, server)
64
64
        self.root = root
65
 
        
 
65
        if home is None:
 
66
            self.home = self.root
 
67
        else:
 
68
            self.home = home[len(self.root):]
 
69
        if (len(self.home) > 0) and (self.home[0] == '/'):
 
70
            self.home = self.home[1:]
 
71
        server._test_case.log('sftpserver - new connection')
 
72
 
66
73
    def _realpath(self, path):
67
74
        return self.root + self.canonicalize(path)
68
75
 
 
76
    def canonicalize(self, path):
 
77
        if os.path.isabs(path):
 
78
            return os.path.normpath(path)
 
79
        else:
 
80
            return os.path.normpath('/' + os.path.join(self.home, path))
 
81
 
69
82
    def chattr(self, path, attr):
70
83
        try:
71
84
            SFTPServer.set_file_attr(path, attr)