178
178
def _put_non_atomic_helper(self, relpath, writer,
180
create_parent_dir=False):
180
create_parent_dir=False,
181
182
"""Common functionality information for the put_*_non_atomic.
183
184
This tracks all the create_parent_dir stuff.
206
207
parent_dir = os.path.dirname(abspath)
207
208
if not parent_dir:
208
209
self._translate_error(e, relpath)
211
except (IOError, OSError), e:
212
self._translate_error(e, relpath)
210
self._mkdir(parent_dir, mode=dir_mode)
213
211
# We created the parent directory, lets try to open the
229
227
def put_file_non_atomic(self, relpath, f, mode=None,
230
create_parent_dir=False):
228
create_parent_dir=False,
231
230
"""Copy the file-like object into the target location.
233
232
This function is not strictly safe to use. It is only meant to
247
246
self._pump_to_fd(f, fd)
248
247
self._put_non_atomic_helper(relpath, writer, mode=mode,
249
create_parent_dir=create_parent_dir)
248
create_parent_dir=create_parent_dir,
251
251
def put_bytes_non_atomic(self, relpath, bytes, mode=None,
252
create_parent_dir=False):
252
create_parent_dir=False, dir_mode=None):
254
254
os.write(fd, bytes)
255
255
self._put_non_atomic_helper(relpath, writer, mode=mode,
256
create_parent_dir=create_parent_dir)
256
create_parent_dir=create_parent_dir,
258
259
def iter_files_recursive(self):
259
260
"""Iter the relative paths of files in the transports sub-tree."""
270
def mkdir(self, relpath, mode=None):
271
"""Create a directory at the given path."""
271
def _mkdir(self, abspath, mode=None):
272
"""Create a real directory, filtering through mode"""
274
# os.mkdir() will filter through umask
275
# os.mkdir() will filter through umask
279
path = self._abspath(relpath)
280
os.mkdir(path, local_mode)
279
os.mkdir(abspath, local_mode)
281
280
if mode is not None:
282
281
# It is probably faster to just do the chmod, rather than
283
282
# doing a stat, and then trying to compare
283
os.chmod(abspath, mode)
285
284
except (IOError, OSError),e:
286
self._translate_error(e, path)
285
self._translate_error(e, abspath)
287
def mkdir(self, relpath, mode=None):
288
"""Create a directory at the given path."""
289
self._mkdir(self._abspath(relpath), mode=mode)
288
291
def _get_append_file(self, relpath, mode=None):
289
292
"""Call os.open() for the given relpath"""