~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/ftp_server.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-06-08 00:21:20 UTC
  • mfrom: (3453.2.11 fast-checkout2)
  • Revision ID: pqm@pqm.ubuntu.com-20080608002120-r3kcq0kxq24lhnak
Improve build_tree performance (igc, abentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    )
38
38
 
39
39
 
40
 
class test_filesystem(medusa.filesys.os_filesystem):
41
 
    """A custom filesystem wrapper to add missing functionalities."""
42
 
 
43
 
    def chmod(self, path, mode):
44
 
        p = self.normalize(self.path_module.join (self.wd, path))
45
 
        return os.chmod(self.translate(p), mode)
46
 
 
47
 
 
48
40
class test_authorizer(object):
49
41
    """A custom Authorizer object for running the test suite.
50
42
 
72
64
            and password != self.secured_password):
73
65
            return 0, 'Password invalid.', None
74
66
        else:
75
 
            return 1, 'OK.', test_filesystem(self.root)
 
67
            return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
76
68
 
77
69
 
78
70
class ftp_channel(medusa.ftp_server.ftp_channel):
161
153
            except:
162
154
                self.respond ('550 error creating directory.')
163
155
 
164
 
    def cmd_site(self, line):
165
 
        """Site specific commands."""
166
 
        command, args = line[1].split(' ', 1)
167
 
        if command.lower() == 'chmod':
168
 
            try:
169
 
                mode, path = args.split()
170
 
                mode = int(mode, 8)
171
 
            except ValueError:
172
 
                # We catch both malformed line and malformed mode with the same
173
 
                # ValueError.
174
 
                self.command_not_understood(' '.join(line))
175
 
                return
176
 
            try:
177
 
                # Yes path and mode are reversed
178
 
                self.filesystem.chmod(path, mode)
179
 
                self.respond('200 SITE CHMOD command successful')
180
 
            except AttributeError:
181
 
                # The chmod method is not available in read-only and will raise
182
 
                # AttributeError since a different filesystem is used in that
183
 
                # case
184
 
                self.command_not_authorized(' '.join(line))
185
 
        else:
186
 
            # Another site specific command was requested. We don't know that
187
 
            # one
188
 
            self.command_not_understood(' '.join(line))
189
 
 
190
156
 
191
157
class ftp_server(medusa.ftp_server.ftp_server):
192
158
    """Customize the behavior of the Medusa ftp_server.