Beispiel #1
0
    def read_file(self, desc, size=-1, buffer=None):
        if size < 0:
            size = len(buffer)
        elif buffer is not None:
            size = min(size, len(buffer))

        message_body = OpenedDataObjRequest(l1descInx=desc,
                                            len=size,
                                            whence=0,
                                            oprType=0,
                                            offset=0,
                                            bytesWritten=0,
                                            KeyValPair_PI=StringStringMap())
        message = iRODSMessage('RODS_API_REQ',
                               msg=message_body,
                               int_info=api_number['DATA_OBJ_READ_AN'])

        logger.debug(desc)
        self.send(message)
        if buffer is None:
            response = self.recv()
        else:
            response = self.recv_into(buffer)

        return response.bs
Beispiel #2
0
    def close_file(self, desc):
        message_body = OpenedDataObjRequest(l1descInx=desc,
                                            len=0,
                                            whence=0,
                                            oprType=0,
                                            offset=0,
                                            bytesWritten=0,
                                            KeyValPair_PI=StringStringMap())
        message = iRODSMessage('RODS_API_REQ',
                               msg=message_body,
                               int_info=api_number['DATA_OBJ_CLOSE_AN'])

        self.send(message)
        response = self.recv()
Beispiel #3
0
 def write_file(self, desc, string):
     message_body = OpenedDataObjRequest(l1descInx=desc,
                                         len=len(string),
                                         whence=0,
                                         oprType=0,
                                         offset=0,
                                         bytesWritten=0,
                                         KeyValPair_PI=StringStringMap())
     message = iRODSMessage('RODS_API_REQ',
                            msg=message_body,
                            bs=string,
                            int_info=api_number['DATA_OBJ_WRITE_AN'])
     self.send(message)
     response = self.recv()
     return response.int_info
Beispiel #4
0
    def seek_file(self, desc, offset, whence):
        message_body = OpenedDataObjRequest(l1descInx=desc,
                                            len=0,
                                            whence=whence,
                                            oprType=0,
                                            offset=offset,
                                            bytesWritten=0,
                                            KeyValPair_PI=StringStringMap())
        message = iRODSMessage('RODS_API_REQ',
                               msg=message_body,
                               int_info=api_number['DATA_OBJ_LSEEK_AN'])

        self.send(message)
        response = self.recv()
        offset = response.get_main_message(FileSeekResponse).offset
        return offset
Beispiel #5
0
    def read_file(self, desc, size):
        message_body = OpenedDataObjRequest(l1descInx=desc,
                                            len=size,
                                            whence=0,
                                            oprType=0,
                                            offset=0,
                                            bytesWritten=0,
                                            KeyValPair_PI=StringStringMap())
        message = iRODSMessage('RODS_API_REQ',
                               msg=message_body,
                               int_info=api_number['DATA_OBJ_READ_AN'])

        logger.debug(desc)
        self.send(message)
        response = self.recv()
        return response.bs