diff options
author | Robey Pointer <robey@lag.net> | 2006-08-21 19:56:01 -0700 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2006-08-21 19:56:01 -0700 |
commit | cc3e383baf0f6db049264db1a55730cc6996fc35 (patch) | |
tree | cc68300f8fc87c3f0dd0929bb30b4c64aff2acd8 /tests/stub_sftp.py | |
parent | 49418d1145db07b189ebb72a5907518570252afd (diff) |
[project @ robey@lag.net-20060822025601-aab3b723b95d3a9c]
add 'flags' param to SFTPHandle and make the default impl avoid calling tell() when in append mode; add proper append-mode support to stub_sftp
Diffstat (limited to 'tests/stub_sftp.py')
-rw-r--r-- | tests/stub_sftp.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/stub_sftp.py b/tests/stub_sftp.py index 1679e34e..2eb5f241 100644 --- a/tests/stub_sftp.py +++ b/tests/stub_sftp.py @@ -104,9 +104,15 @@ class StubSFTPServer (SFTPServerInterface): attr._flags &= ~attr.FLAG_PERMISSIONS SFTPServer.set_file_attr(path, attr) if flags & os.O_WRONLY: - fstr = 'wb' + if flags & os.O_APPEND: + fstr = 'ab' + else: + fstr = 'wb' elif flags & os.O_RDWR: - fstr = 'r+b' + if flags & os.O_APPEND: + fstr = 'a+b' + else: + fstr = 'r+b' else: # O_RDONLY (== 0) fstr = 'rb' @@ -114,7 +120,7 @@ class StubSFTPServer (SFTPServerInterface): f = os.fdopen(fd, fstr) except OSError, e: return SFTPServer.convert_errno(e.errno) - fobj = StubSFTPHandle() + fobj = StubSFTPHandle(flags) fobj.filename = path fobj.readfile = f fobj.writefile = f |