Beispiel #1
0
def test_chunks():
    data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    result = list()
    for chunk in chunks(data, 2):
        result.extend(chunk)
        eq_(len(chunk), 2)
    eq_(result, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Beispiel #2
0
    def write_fru_data(self, data, offset=0, fru_id=0):
        req = create_request_by_name('WriteFruData')
        req.fru_id = fru_id

        for chunk in chunks(data, self.write_length):
            req.offset = offset
            req.data = chunk
            rsp = self.send_message(req)
            check_completion_code(rsp.completion_code)
            offset += len(chunk)
Beispiel #3
0
    def write_fru_data(self, data, offset=0, fru_id=0):
        req = create_request_by_name('WriteFruData')
        req.fru_id = fru_id

        for chunk in chunks(data, self.write_length):
            req.offset = offset
            req.data = chunk
            rsp = self.send_message(req)
            check_completion_code(rsp.completion_code)
            offset += len(chunk)
Beispiel #4
0
    def write_fru_data(self, data, offset=0, fru_id=0):
        for chunk in chunks(data, self.write_length):
            write_rsp = self.send_message_with_name('WriteFruData',
                            fru_id=fru_id, offset=offset, data=chunk)

            # check if device wrote the same number of bytes sent
            if write_rsp.count_written != len(chunk):
                raise Exception('sent {:} bytes but device wrote {:} bytes'
                                .format(len(chunk), write_rsp.count_written))

            offset += len(chunk)
Beispiel #5
0
    def upload_binary(self, binary, timeout=2, interval=0.1):
        """ Upload all firmware blocks from binary and wait for
            long running command. """
        block_number = 0
        block_size = self._determine_max_block_size()

        for chunk in chunks(binary, block_size):
            try:
                self.upload_firmware_block(block_number, chunk)
            except CompletionCodeError, e:
                if e.cc == LONG_DURATION_CMD_IN_PROGRESS_CC:
                    self.wait_for_long_duration_command(
                            constants.CMDID_HPM_UPLOAD_FIRMWARE_BLOCK,
                            timeout, interval)
                else:
                    raise HpmError('upload_firmware_block CC=0x%02x' % e.cc)
            block_number += 1
            block_number &= 0xff
Beispiel #6
0
    def upload_binary(self, binary, timeout=2, interval=0.1):
        """ Upload all firmware blocks from binary and wait for
            long running command. """
        block_number = 0
        block_size = self._determine_max_block_size()

        for chunk in chunks(binary, block_size):
            try:
                self.upload_firmware_block(block_number, chunk)
            except CompletionCodeError, e:
                if e.cc == LONG_DURATION_CMD_IN_PROGRESS_CC:
                    self.wait_for_long_duration_command(
                        constants.CMDID_HPM_UPLOAD_FIRMWARE_BLOCK, timeout,
                        interval)
                else:
                    raise HpmError('upload_firmware_block CC=0x%02x' % e.cc)
            block_number += 1
            block_number &= 0xff