def execute(self, command, timeout=None, check_exit_code=True, as_root=False, strip_colors=True):
        try:
            with self.lock:
                if self.connection_lost:
                    logger.debug('Attempting to reconnect...')
                    self.reconnect()
                    self.connection_lost = False
                output = self._execute_and_wait_for_prompt(command, timeout, as_root, strip_colors)
                if check_exit_code:
                    exit_code_text = self._execute_and_wait_for_prompt('echo $?', strip_colors=strip_colors, log=False)
                    try:
                        exit_code = int(exit_code_text.split()[0])
                        if exit_code:
                            message = 'Got exit code {}\nfrom: {}\nOUTPUT: {}'
                            raise DeviceError(message.format(exit_code, command, output))
                    except (ValueError, __HOLE__):
                        logger.warning('Could not get exit code for "{}",\ngot: "{}"'.format(command, exit_code_text))
                return output
        except EOF:
            self.connection_lost = True
            raise DeviceError('Connection dropped.')
dataset/ETHPy150Open ARM-software/workload-automation/wlauto/utils/ssh.py/SshShell.execute