Пример #1
0
    def download(self, path, to):
        conn, desc = self.session.data_objects.open(path, O_RDONLY)
        raw = iRODSDataObjectFileRaw(conn, desc)
        br = BufferedRandom(raw)

        try:
            with open(to, 'w') as wf:
                while(True):
                    buf = _readLargeBlock(br)

                    if not buf:
                        break

                    wf.write(buf)
        finally:
            conn.release(True)
            br.close()

        return to
Пример #2
0
    def read(self, path, offset, size):
        buf = None
        br = None
        conn = None
        try:
            conn, desc = self.session.data_objects.open(path, O_RDONLY)
            raw = iRODSDataObjectFileRaw(conn, desc)
            br = BufferedRandom(raw)
            new_offset = br.seek(offset)
            
            if new_offset == offset:
                buf = br.read(size)
        finally:
            if br:
                br.close()
            if conn:
                conn.release(True)

        return buf
Пример #3
0
    def open(self, path, mode='r', errors=None):
        stream = self.opened.get(path)
        if not stream:
            if mode[0] == 'r':
                raise FileNotFoundError(path)
            stream = self.opened[path] = BytesIO()
        stream.seek(0)
        stream = BufferedRandom(stream) if mode[-1] == 'b' else TextIOWrapper(
            stream)
        stream.close = stream.flush

        return stream
Пример #4
0
def FileClose(file_handle: io.BufferedRandom) -> None:
    file_handle.close()