'Run list of commands on remote device and return results'

def run_commands(self, commands, check_rc=True):

    output = None
    queue = list()
    responses = list()
    def _send(commands, output):
        return self.send_request(commands, output, check_status=check_rc)
    for item in to_list(commands):
        if is_json(item['command']):
            item['command'] = str(item['command']).split('|')[0]
            item['output'] = 'json'
        if (all(((output == 'json'), (item['output'] == 'text'))) or all(((output == 'text'), (item['output'] == 'json')))):
            responses.extend(_send(queue, output))
            queue = list()
        output = (item['output'] or 'json')
        queue.append(item['command'])
    if queue:
        responses.extend(_send(queue, output))
    return responses
