How to use _save_checksum_dict method in autotest

Best Python code snippet using autotest_python

base_packages.py

Source:base_packages.py Github

copy

Full Screen

...582 for line in checksum_file_contents.splitlines():583 checksum, package_name = line.split(None, 1)584 self._checksum_dict[package_name] = checksum585 return self._checksum_dict586 def _save_checksum_dict(self, checksum_dict):587 '''588 Save the checksum dictionary onto the checksum file. Update the589 local _checksum_dict variable with this new set of values.590 checksum_dict : New checksum dictionary591 checksum_dir : The directory in which to store the checksum file to.592 '''593 checksum_path = self._get_checksum_file_path()594 self._checksum_dict = checksum_dict.copy()595 checksum_contents = '\n'.join(checksum + ' ' + pkg_name596 for pkg_name, checksum in597 checksum_dict.iteritems())598 # Write the checksum file back to disk599 self._run_command('echo "%s" > %s' % (checksum_contents,600 checksum_path),601 _run_command_dargs={'verbose': False})602 def compute_checksum(self, pkg_path):603 '''604 Compute the MD5 checksum for the package file and return it.605 pkg_path : The complete path for the package file606 '''607 md5sum_output = self._run_command("md5sum %s " % pkg_path).stdout608 return md5sum_output.split()[0]609 def update_checksum(self, pkg_path):610 '''611 Update the checksum of the package in the packages' checksum612 file. This method is called whenever a package is fetched just613 to be sure that the checksums in the local file are the latest.614 pkg_path : The complete path to the package file.615 '''616 # Compute the new checksum617 new_checksum = self.compute_checksum(pkg_path)618 checksum_dict = self._get_checksum_dict()619 checksum_dict[os.path.basename(pkg_path)] = new_checksum620 self._save_checksum_dict(checksum_dict)621 def remove_checksum(self, pkg_name):622 '''623 Remove the checksum of the package from the packages checksum file.624 This method is called whenever a package is removed from the625 repositories in order clean its corresponding checksum.626 pkg_name : The name of the package to be removed627 '''628 checksum_dict = self._get_checksum_dict()629 if pkg_name in checksum_dict:630 del checksum_dict[pkg_name]631 self._save_checksum_dict(checksum_dict)632 def compare_checksum(self, pkg_path):633 '''634 Calculate the checksum of the file specified in pkg_path and635 compare it with the checksum in the checksum file636 Return True if both match else return False.637 pkg_path : The full path to the package file for which the638 checksum is being compared639 '''640 checksum_dict = self._get_checksum_dict()641 package_name = os.path.basename(pkg_path)642 if not checksum_dict or package_name not in checksum_dict:643 return False644 repository_checksum = checksum_dict[package_name]645 local_checksum = self.compute_checksum(pkg_path)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful