Пример #1
0
    def process_result(self, commandName, command, result):
        if len(result['output']) == 0:
            return

        resultBuf = result['output'].encode()
        results = []
        while len(resultBuf) > 0:
            try:
                (_, _, responseLen, _) = OnkyoAVR.ISCP_HEADER.unpack(
                    resultBuf[:OnkyoAVR.ISCP_HEADER.size])
                # strip first 2 chars last 3 chars for \x1a\r\n
                results.append(resultBuf[OnkyoAVR.ISCP_HEADER.size +
                                         len(OnkyoAVR.DESTINATION_UNIT_TYPE
                                             ):OnkyoAVR.ISCP_HEADER.size +
                                         responseLen - 3].decode())
                resultBuf = resultBuf[OnkyoAVR.ISCP_HEADER.size + responseLen:]
            except:
                self.logger.error(
                    "Error processing buffer. "
                    "Possibly incomplete buffer. Increase receive buffer size")
                break

        result['output'] = utils.get_last_output(command, results,
                                                 self.paramParser.value_sets,
                                                 OnkyoAVR.SEARCH_SUFFIX)

        super(OnkyoAVR, self).process_result(commandName, command, result)
Пример #2
0
    def process_result(self, commandName, command, result):
        if len(result) == 0:
            return

        if commandName.startswith('current_volume'):
            output = utils.get_last_output(command, result['output'],
                self.paramParser.value_sets, DenonAVR.SEARCH_SUFFIX)

            if output is None:
                return

            if len(output) > 2:
                output = output[:2] + '.5'
            else:
                output = output + '.0'
            output = float(output)
        else:
            output = self.paramParser.translate_param(command,
                utils.get_last_output(command, result['output'],
                    self.paramParser.value_sets, DenonAVR.SEARCH_SUFFIX))

        if output:
            result['result'] = output
Пример #3
0
 def test_last_output_suffix(self):
     config = UtilsTester.config['last_output']
     output = utils.get_last_output(config['commands']['suffixCommand'],
                                    ['cmd123'], {}, 'n')
     self.assertEqual(output, '123')
Пример #4
0
 def test_last_output_values_multi_line(self):
     config = UtilsTester.config['last_output']
     output = utils.get_last_output(config['commands']['valueCommand'],
                                    ['cmd123', 'cmdkey1'], config['values'],
                                    '')
     self.assertEqual(output, 'key1')
Пример #5
0
 def test_last_output_hex_multi_line(self):
     config = UtilsTester.config['last_output']
     output = utils.get_last_output(config['commands']['hexCommand'],
                                    ['cmdbaba', 'cmdcaca'], {}, '')
     self.assertEqual(output, 'caca')
Пример #6
0
 def test_last_output_float_multi_line(self):
     config = UtilsTester.config['last_output']
     output = utils.get_last_output(config['commands']['floatCommand'],
                                    ['cmd123', 'cmd234'], {}, '')
     self.assertEqual(output, '234')
Пример #7
0
 def test_last_output_number_multi_prefix(self):
     config = UtilsTester.config['last_output']
     output = utils.get_last_output(config['commands']['intCommand'],
                                    ['cmd123', 'cmdn234'], {}, '')
     self.assertEqual(output, '123')