Пример #1
0
 def open_write_stream(self, relpath, mode=None):
     """See Transport.open_write_stream."""
     # initialise the file
     self.put_bytes_non_atomic(relpath, "", mode=mode)
     abspath = self._abspath(relpath)
     handle = osutils.open_file(abspath, 'wb')
     if mode is not None:
         self._check_mode_and_size(abspath, handle.fileno(), mode)
     transport._file_streams[self.abspath(relpath)] = handle
     return transport.FileFileStream(self, relpath, handle)
Пример #2
0
    def get(self, relpath):
        """Get the file at the given relative path.

        :param relpath: The relative path to the file
        """
        logf = open("/tmp/anvserve", "a")
        canonical_url = self.abspath(relpath)
        if canonical_url in transport._file_streams:
            transport._file_streams[canonical_url].flush()
        filectt = None
        try:
            path = self._abspath(relpath)
            logf.write("Get " + relpath + " => " + path + "... ")
            filectt = osutils.open_file(path, 'rb')
            logf.write("file succesffuly opened")
        except (IOError, OSError),e:
            if e.errno == errno.EISDIR:
                filectt = LateReadError(relpath)
            self._translate_error(e, path)