Best Python code snippet using autotest_python
bootloader.py
Source:bootloader.py  
...69        # FIXME: add unsafe options strings sequence to host.run() parameters70        for option in options:71            cmd += ' "%s"' % utils.sh_escape(option)72        return self._host().run(cmd)73    def _run_boottool_stdout(self, *options):74        '''75        Runs a boottool command, return its output76        '''77        return self._run_boottool_cmd(*options).stdout78    def _run_boottool_exit_status(self, *options):79        '''80        Runs a boottool command, return its exit status81        '''82        return self._run_boottool_cmd(*options).exit_status83    def get_bootloader(self):84        """85        Get the bootloader name that is detected on this machine86        :return: name of detected bootloader87        """88        return self._run_boottool_stdout('--bootloader-probe').strip()89    get_type = get_bootloader90    def get_architecture(self):91        '''92        Get the system architecture93        '''94        return self._run_boottool_stdout('--arch-probe').strip()95    arch_probe = get_architecture96    def get_titles(self):97        """98        Returns a list of boot entries titles.99        """100        return [entry.get('title', '')101                for entry in self.get_entries().itervalues()]102    def get_default_index(self):103        """104        Return an int with the # of the default bootloader entry.105        """106        return int(self._run_boottool_stdout('--default').strip())107    get_default = get_default_index108    def set_default_by_index(self, index):109        '''110        Sets the given entry number to be the default on every next boot111        To set a default only for the next boot, use boot_once() instead.112        :param index: entry index number to set as the default.113        '''114        if self._host().job:115            self._host().job.last_boot_tag = None116        return self._run_boottool_exit_status('--set-default=%s' %117                                              utils.sh_escape(str(index)))118    set_default = set_default_by_index119    def get_default_title(self):120        '''121        Get the default entry title.122        :return: a string of the default entry title.123        '''124        default = self.get_default_index()125        entry = self.get_entry(default)126        if entry.has_key('title'):127            return entry['title']128        elif 'label' in entry:129            return entry['label']130    def get_entry(self, entry):131        """132        Get a single bootloader entry information.133        :param entry: entry index134        :return: a dictionary of key->value where key is the type of entry135                information (ex. 'title', 'args', 'kernel', etc) and value136                is the value for that piece of information.137        """138        output = self._run_boottool_stdout('--info=%s' % entry).strip()139        return parse_entry(output, ":")140    def get_entries(self):141        """142        Get all entries information.143        :return: a dictionary of index -> entry where entry is a dictionary144                of entry information as described for get_entry().145        """146        raw = "\n" + self._run_boottool_stdout('--info=all')147        entries = {}148        for entry_str in raw.split("\nindex"):149            if len(entry_str.strip()) == 0:150                continue151            entry = parse_entry("index" + entry_str, ":")152            entries[entry["index"]] = entry153        return entries154    def add_args(self, kernel, args):155        """156        Add cmdline arguments for the specified kernel.157        :param kernel: can be a position number (index) or title158        :param args: argument to be added to the current list of args159        """160        return self._run_boottool_exit_status('--update-kernel=%s' %...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
