[MERGE] Fix ftp transport so that it handles the 'mode' parameter when provided.

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Jun 27 22:59:37 BST 2008


>>>>> "john" == John Arbash Meinel <john at arbash-meinel.com> writes:

<snip/>

    john> +class test_filesystem(medusa.filesys.os_filesystem):
    john> +    """A custom filesystem wrapper to add missing functionalities."""
    john> +
    john> +    def chmod(self, path, mode):
    john> +        p = self.normalize (self.path_module.join (self.wd, path))
    john> +        return os.chmod(self.translate(p), mode)

    john> ^- 'self.normalize ()' is not our standard syntax.

Good catch, thanks, I missed that one.

<cough> Me ? Copy/pasting ? Naaaaaah

    john> +    def cmd_site(self, line):
    john> +        command, args = line[1].split(' ', 1)
    john> +        if command.lower() == 'chmod':
    john> +            try:
    john> +                mode, path = args.split()
    john> +                mode = int(mode, 8)
    john> +            except ValueError:
    john> +                self.command_not_understood(' '.join(line))
    john> +                return
    john> +            try:
    john> +                # Yes path and mode are reversed
    john> +                self.filesystem.chmod(path, mode)
    john> +                self.respond('200 SITE CHMOD command successful')
    john> +            except AttributeError:
    john> +                # The chmod method is not available in read-only
    john> +                self.command_not_authorized(' '.join(line))
    john> +        else:
    john> +            self.command_not_understood(' '.join(line))
    john> +

    john> ^- Is this the fallback, or do you need to call back into the original
    john> handler?

<shudder> original handler ? I wish there was one :-/

I'll add comments.

    john> I think if our test setup can
    john> "roundtrip_unix_mode_bits" then we should be setting
    john> this to True, so that we can have them tested in the
    john> test suite.


    john> Though you would still need a win32 check since you
    john> still can't round-trip them if the underlying fs
    john> doesn't support it.

Sure. The plan was to... copy the sftp one :-)

    john> Otherwise, I think it is a simple:

    john> BB:tweak

Thanks,

        Vincent



More information about the bazaar mailing list