Best Python code snippet using autotest_python
utils_koji.py
Source:utils_koji.py  
...252            tag = self.session.getTag(pkg.tag)253            if tag:254                return True255        return False256    def get_pkg_rpm_info(self, pkg, arch=None):257        '''258        Returns a list of infomation on the RPM packages found on koji259        @type pkg: KojiPkgSpec260        @param pkg: a package specification261        @type arch: string262        @param arch: packages built for this architecture, but also including263                architecture independent (noarch) packages264        '''265        if arch is None:266            arch = utils.get_arch()267        rpms = []268        info = self.get_pkg_info(pkg)269        if info:270            rpms = self.session.listRPMs(buildID=info['id'],271                                         arches=[arch, 'noarch'])272            if pkg.subpackages:273                rpms = [d for d in rpms if d['name'] in pkg.subpackages]274        return rpms275    def get_pkg_rpm_names(self, pkg, arch=None):276        '''277        Gets the names for the RPM packages specified in pkg278        @type pkg: KojiPkgSpec279        @param pkg: a package specification280        @type arch: string281        @param arch: packages built for this architecture, but also including282                architecture independent (noarch) packages283        '''284        if arch is None:285            arch = utils.get_arch()286        rpms = self.get_pkg_rpm_info(pkg, arch)287        return [rpm['name'] for rpm in rpms]288    def get_pkg_rpm_file_names(self, pkg, arch=None):289        '''290        Gets the file names for the RPM packages specified in pkg291        @type pkg: KojiPkgSpec292        @param pkg: a package specification293        @type arch: string294        @param arch: packages built for this architecture, but also including295                architecture independent (noarch) packages296        '''297        if arch is None:298            arch = utils.get_arch()299        rpm_names = []300        rpms = self.get_pkg_rpm_info(pkg, arch)301        for rpm in rpms:302            arch_rpm_name = koji.pathinfo.rpm(rpm)303            rpm_name = os.path.basename(arch_rpm_name)304            rpm_names.append(rpm_name)305        return rpm_names306    def get_pkg_base_url(self):307        '''308        Gets the base url for packages in Koji309        '''310        if self.config_options.has_key('pkgurl'):311            return self.config_options['pkgurl']312        else:313            return "%s/%s" % (self.config_options['topurl'],314                              'packages')315    def get_scratch_base_url(self):316        '''317        Gets the base url for scratch builds in Koji318        '''319        one_level_up = os.path.dirname(self.get_pkg_base_url())320        return "%s/%s" % (one_level_up, 'scratch')321    def get_pkg_urls(self, pkg, arch=None):322        '''323        Gets the urls for the packages specified in pkg324        @type pkg: KojiPkgSpec325        @param pkg: a package specification326        @type arch: string327        @param arch: packages built for this architecture, but also including328                architecture independent (noarch) packages329        '''330        info = self.get_pkg_info(pkg)331        rpms = self.get_pkg_rpm_info(pkg, arch)332        rpm_urls = []333        base_url = self.get_pkg_base_url()334        for rpm in rpms:335            rpm_name = koji.pathinfo.rpm(rpm)336            url = ("%s/%s/%s/%s/%s" % (base_url,337                                       info['package_name'],338                                       info['version'], info['release'],339                                       rpm_name))340            rpm_urls.append(url)341        return rpm_urls342    def get_pkgs(self, pkg, dst_dir, arch=None):343        '''344        Download the packages345        @type pkg: KojiPkgSpec...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!!
