How to use _check_installed_version method in avocado

Best Python code snippet using avocado_python

rpm.py

Source:rpm.py Github

copy

Full Screen

...16 PACKAGE_TYPE + ' ' +17 '%{NAME} %{VERSION} %{RELEASE} %{SIGMD5} %{ARCH}')18 def __init__(self):19 self.lowlevel_base_cmd = utils_path.find_command('rpm')20 def _check_installed_version(self, name, version):21 """22 Helper for the check_installed public method.23 :param name: Package name.24 :param version: Package version.25 """26 cmd = (self.lowlevel_base_cmd + ' -q --qf %{VERSION} ' + name)27 inst_version = process.system_output(cmd, ignore_status=True)28 if 'not installed' in inst_version:29 return False30 return bool(inst_version >= version)31 def check_installed(self, name, version=None, arch=None):32 """33 Check if package [name] is installed.34 :param name: Package name.35 :param version: Package version.36 :param arch: Package architecture.37 """38 if arch:39 cmd = (self.lowlevel_base_cmd + ' -q --qf %{ARCH} ' + name)40 inst_archs = process.system_output(cmd, ignore_status=True)41 inst_archs = inst_archs.split('\n')42 for inst_arch in inst_archs:43 if inst_arch == arch:44 return self._check_installed_version(name, version)45 return False46 elif version:47 return self._check_installed_version(name, version)48 else:49 cmd = 'rpm -q ' + name50 try:51 process.system(cmd)52 return True53 except process.CmdError:54 return False55 def list_all(self, software_components=True):56 """57 List all installed packages.58 :param software_components: log in a format suitable for the59 SoftwareComponent schema60 """61 log.debug("Listing all system packages (may take a while)")...

Full Screen

Full Screen

Updater.py

Source:Updater.py Github

copy

Full Screen

...22 def start(self):23 if not os.path.exists('no_update.txt'):24 try:25 # on check & get version from live and installed file26 self._check_installed_version()27 self._check_live_version()28 if self._installed_version != self._live_version:29 print("Starting to update")30 # dl zip file31 self._download_file(self._url_zip, self._tmp_zip_file)32 # extart zip file33 self._extract_zip_file(self._tmp_zip_file)34 # remove zip file35 self._remove_file(self._tmp_zip_file)36 # write new version in installed file37 self._write_version_installed_file()38 print("Update finish")39 print("Restarting...")40 time.sleep(2)41 python = sys.executable42 os.execl(python, python, *sys.argv)43 else:44 print("No need to update")45 except:46 print("Error while doing update")47 def _download_file(self, url: str, filename_output: str):48 try:49 filename, __ = urllib.request.urlretrieve(url, filename=filename_output)50 print("File '" + str(filename) + "' downloaded")51 except:52 print("Error while downloading '" + str(self._tmp_zip_file) + "' file")53 def _extract_zip_file(self, file_name: str):54 print("Extracting '" + file_name + "' folder")55 try:56 with zipfile.ZipFile(file_name, 'r') as zip_file:57 zip_file.extractall(self._extract_folder)58 zip_file.close()59 print("'" + file_name + "' file Extracted")60 except Exception as e:61 print("Error while extracting '" + str(file_name) + "' folder")62 def _remove_file(self, file_name: str):63 try:64 os.remove(file_name)65 print("File '" + file_name + "' removed")66 except:67 print("Error while removing '" + file_name + "' file")68 def _check_installed_version(self):69 if not os.path.exists(self._version_installed_file):70 """ si ya pas de fichier version installé on le crée """71 self._create_version_installed_file()72 else:73 self._installed_version = self._read_version_file(self._version_installed_file)74 def _check_live_version(self):75 self._download_file(self._version_file_url, self._version_live_file)76 self._live_version = self._read_version_file(self._version_live_file)77 self._remove_file(self._version_live_file)78 def _read_version_file(self, file_name: str):79 with open(file_name, "r+") as v_file:80 version = v_file.readline()81 v_file.close()82 return version...

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 avocado 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