Best Python code snippet using autotest_python
monitor_db_functional_test.py
Source:monitor_db_functional_test.py  
...156                                 file_path=None):157        self._attached_files.setdefault(result_dir, set()).add((file_path,158                                                                file_contents))159        return 'attach_path'160    def _initialize_pidfile(self, pidfile_id):161        if pidfile_id not in self._pidfiles:162            assert pidfile_id.key() not in self._pidfile_index163            self._pidfiles[pidfile_id] = drone_manager.PidfileContents()164            self._pidfile_index[pidfile_id.key()] = pidfile_id165    def _set_last_pidfile(self, pidfile_id, working_directory, pidfile_name):166        if working_directory.startswith('hosts/'):167            # such paths look like hosts/host1/1-verify, we'll grab the end168            type_string = working_directory.rsplit('-', 1)[1]169            pidfile_type = _PidfileType.get_value(type_string)170        else:171            pidfile_type = _PIDFILE_TO_PIDFILE_TYPE[pidfile_name]172        self._last_pidfile_id[pidfile_type] = pidfile_id173    def execute_command(self, command, working_directory, pidfile_name,174                        num_processes, log_file=None, paired_with_pidfile=None,175                        username=None, drone_hostnames_allowed=None):176        logging.debug('Executing %s in %s', command, working_directory)177        pidfile_id = self._DummyPidfileId(working_directory, pidfile_name)178        if pidfile_id.key() in self._pidfile_index:179            pidfile_id = self._pidfile_index[pidfile_id.key()]180        pidfile_id._num_processes = num_processes181        pidfile_id._paired_with_pidfile = paired_with_pidfile182        self._future_pidfiles.append(pidfile_id)183        self._initialize_pidfile(pidfile_id)184        self._pidfile_index[(working_directory, pidfile_name)] = pidfile_id185        self._set_last_pidfile(pidfile_id, working_directory, pidfile_name)186        return pidfile_id187    def get_pidfile_contents(self, pidfile_id, use_second_read=False):188        if pidfile_id not in self._pidfiles:189            logging.debug('Request for nonexistent pidfile %s', pidfile_id)190        return self._pidfiles.get(pidfile_id, drone_manager.PidfileContents())191    def is_process_running(self, process):192        return True193    def register_pidfile(self, pidfile_id):194        self._initialize_pidfile(pidfile_id)195    def unregister_pidfile(self, pidfile_id):196        self._unregistered_pidfiles.add(pidfile_id)197    def declare_process_count(self, pidfile_id, num_processes):198        pidfile_id.num_processes = num_processes199    def absolute_path(self, path):200        return 'absolute/' + path201    def write_lines_to_file(self, file_path, lines, paired_with_process=None):202        # TODO: record this203        pass204    def get_pidfile_id_from(self, execution_tag, pidfile_name):205        default_pidfile = self._DummyPidfileId(execution_tag, pidfile_name,206                                               num_processes=0)207        return self._pidfile_index.get((execution_tag, pidfile_name),208                                       default_pidfile)...monitor_db_functional_unittest.py
Source:monitor_db_functional_unittest.py  
...157                                 file_path=None):158        self._attached_files.setdefault(result_dir, set()).add((file_path,159                                                                file_contents))160        return 'attach_path'161    def _initialize_pidfile(self, pidfile_id):162        if pidfile_id not in self._pidfiles:163            assert pidfile_id.key() not in self._pidfile_index164            self._pidfiles[pidfile_id] = drone_manager.PidfileContents()165            self._pidfile_index[pidfile_id.key()] = pidfile_id166    def _set_last_pidfile(self, pidfile_id, working_directory, pidfile_name):167        if working_directory.startswith('hosts/'):168            # such paths look like hosts/host1/1-verify, we'll grab the end169            type_string = working_directory.rsplit('-', 1)[1]170            pidfile_type = _PidfileType.get_value(type_string)171        else:172            pidfile_type = _PIDFILE_TO_PIDFILE_TYPE[pidfile_name]173        self._last_pidfile_id[pidfile_type] = pidfile_id174    def execute_command(self, command, working_directory, pidfile_name,175                        num_processes, log_file=None, paired_with_pidfile=None,176                        username=None, drone_hostnames_allowed=None):177        logging.debug('Executing %s in %s', command, working_directory)178        pidfile_id = self._DummyPidfileId(working_directory, pidfile_name)179        if pidfile_id.key() in self._pidfile_index:180            pidfile_id = self._pidfile_index[pidfile_id.key()]181        pidfile_id._num_processes = num_processes182        pidfile_id._paired_with_pidfile = paired_with_pidfile183        self._future_pidfiles.append(pidfile_id)184        self._initialize_pidfile(pidfile_id)185        self._pidfile_index[(working_directory, pidfile_name)] = pidfile_id186        self._set_last_pidfile(pidfile_id, working_directory, pidfile_name)187        return pidfile_id188    def get_pidfile_contents(self, pidfile_id, use_second_read=False):189        if pidfile_id not in self._pidfiles:190            logging.debug('Request for nonexistent pidfile %s' % pidfile_id)191        return self._pidfiles.get(pidfile_id, drone_manager.PidfileContents())192    def is_process_running(self, process):193        return True194    def register_pidfile(self, pidfile_id):195        self._initialize_pidfile(pidfile_id)196    def unregister_pidfile(self, pidfile_id):197        self._unregistered_pidfiles.add(pidfile_id)198    def declare_process_count(self, pidfile_id, num_processes):199        pidfile_id.num_processes = num_processes200    def absolute_path(self, path):201        return 'absolute/' + path202    def write_lines_to_file(self, file_path, lines, paired_with_process=None):203        # TODO: record this204        pass205    def get_pidfile_id_from(self, execution_tag, pidfile_name):206        default_pidfile = self._DummyPidfileId(execution_tag, pidfile_name,207                                               num_processes=0)208        return self._pidfile_index.get((execution_tag, pidfile_name),209                                       default_pidfile)...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!!
