How to use is_software_package method in avocado

Best Python code snippet using avocado_python

distro_def.py

Source:distro_def.py Github

copy

Full Screen

...111 # pylint: disable=I0011,W0612112 for dirpath, dirnames, filenames in os.walk(self.path):113 for filename in filenames:114 path = os.path.join(dirpath, filename)115 if self.is_software_package(path):116 packages_info.add(self.get_package_info(path))117 # because we do not track of locations or how many copies of a given118 # package file exists in the installation tree, packages should be119 # comprised of unique entries120 return list(packages_info)121 def is_software_package(self, path):122 '''123 Determines if the given file at :param:`path` is a software package124 This check will be used to determine if :method:`load_package_info`125 will be called for file at :param:`path`. This method should be126 implemented by classes inheriting from :class:`DistroPkgInfoLoader` and127 could be as simple as checking for a file suffix.128 :param path: path to the software package file129 :type path: str130 :return: either True if the file is a valid software package or False131 otherwise132 :rtype: bool133 '''134 raise NotImplementedError135 def get_package_info(self, path):136 '''137 Returns information about a given software package138 Should be implemented by classes inheriting from139 :class:`DistroDefinitionLoader`.140 :param path: path to the software package file141 :type path: str142 :returns: tuple with name, version, release, checksum and arch143 :rtype: tuple144 '''145 raise NotImplementedError146class DistroPkgInfoLoaderRpm(DistroPkgInfoLoader):147 '''148 Loads package information for RPM files149 '''150 def __init__(self, path):151 super(DistroPkgInfoLoaderRpm, self).__init__(path)152 try:153 os_dep.command('rpm')154 self.capable = True155 except ValueError:156 self.capable = False157 def is_software_package(self, path):158 '''159 Systems needs to be able to run the rpm binary in order to fetch160 information on package files. If the rpm binary is not available161 on this system, we simply ignore the rpm files found162 '''163 return self.capable and path.endswith('.rpm')164 def get_package_info(self, path):165 cmd = "rpm -qp --qf '%{NAME} %{VERSION} %{RELEASE} %{SIGMD5} %{ARCH}' "166 cmd += path167 info = utils.system_output(cmd, ignore_status=True)168 info = tuple(info.split(' '))169 return info170class DistroPkgInfoLoaderDeb(DistroPkgInfoLoader):171 '''172 Loads package information for DEB files173 '''174 def __init__(self, path):175 super(DistroPkgInfoLoaderDeb, self).__init__(path)176 try:177 os_dep.command('dpkg-deb')178 self.capable = True179 except ValueError:180 self.capable = False181 def is_software_package(self, path):182 return self.capable and (path.endswith('.deb') or183 path.endswith('.udeb'))184 def get_package_info(self, path):185 cmd = ("dpkg-deb --showformat '${Package} ${Version} ${Architecture}' "186 "--show ")187 cmd += path188 info = utils.system_output(cmd, ignore_status=True)189 name, version, arch = info.split(' ')190 return (name, version, '', '', arch)191#: the type of distro that will determine what loader will be used192DISTRO_PKG_INFO_LOADERS = {'rpm': DistroPkgInfoLoaderRpm,...

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