summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@lag.net>2006-03-26 16:17:26 -0800
committerRobey Pointer <robey@lag.net>2006-03-26 16:17:26 -0800
commit0cee90eeca1c421ee1fa7078df7b91db13ecc032 (patch)
treee7d3d30b1f3f0c0aa986941876da64c9f228153e
parent4120a158239d70ce346ab0116c2aa71949e32825 (diff)
[project @ robey@lag.net-20060327001726-7ccb095fd5c416f5]
roll in some changes from bzr that may be necessary to get stub_sftp to work on windows
-rw-r--r--tests/stub_sftp.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/stub_sftp.py b/tests/stub_sftp.py
index 459af066..1679e34e 100644
--- a/tests/stub_sftp.py
+++ b/tests/stub_sftp.py
@@ -91,18 +91,25 @@ class StubSFTPServer (SFTPServerInterface):
def open(self, path, flags, attr):
path = self._realpath(path)
try:
- fd = os.open(path, flags)
+ binary_flag = getattr(os, 'O_BINARY', 0)
+ flags |= binary_flag
+ mode = getattr(attr, 'st_mode', None)
+ if mode is not None:
+ fd = os.open(path, flags, mode)
+ else:
+ fd = os.open(path, flags)
except OSError, e:
return SFTPServer.convert_errno(e.errno)
if (flags & os.O_CREAT) and (attr is not None):
+ attr._flags &= ~attr.FLAG_PERMISSIONS
SFTPServer.set_file_attr(path, attr)
if flags & os.O_WRONLY:
- fstr = 'w'
+ fstr = 'wb'
elif flags & os.O_RDWR:
- fstr = 'r+'
+ fstr = 'r+b'
else:
# O_RDONLY (== 0)
- fstr = 'r'
+ fstr = 'rb'
try:
f = os.fdopen(fd, fstr)
except OSError, e: