SFTP w/ proper atomic put and locking

Robey Pointer robey at lag.net
Mon Nov 14 04:22:38 GMT 2005


On 13 Nov 2005, at 11:01, John A Meinel wrote:

> Robert Collins wrote:
>> On Fri, 2005-11-11 at 18:57 -0800, Robey Pointer wrote:
>>
>>> Well, you've definitely convinced me that paramiko's SFTPClient.file
>>> () should have some kind of file-flag translation for O_EXCL. :)  I
>>> picked 'x' (someone please shout out if this is a bad choice) and it
>>> should be in 1.5.2 or whatever the next version turns out to be.  I
>>> promise not to break your version any time soon. :)
>>
>> 'x' ?  Why not just 'O_EXCL' as already defined in python ?
>
> Well, paramiko's file() acts like pythons file(), which takes the "wb"
> flags, not O_CREAT | O_TRUNC, etc.
> I think he was trying to find a way to do it inside the same text
> string. Though I think it might actually work better to have another
> field for "extra_flags" or something like that.

Yep, exactly that.

I'd rather not add another flags field when python is already using  
the mode parameter for that, but I'm totally not wedded to 'x'.  I  
assume python doesn't normally expose this feature because some  
platform (windows?) doesn't support it.

(BTW, I found out the hard way that the os.open/etc calls are to be  
avoided in cross-platform code.)

robey





More information about the bazaar mailing list