Example #1
0
 def _get_version(self, pkg_name, branch):
     ver = {}
     cmd = "%s latest-pkg \"%s\" \"%s\"" % (self.command, branch, pkg_name)
     ver['cmd'] = cmd
     errc, out, err = run(cmd)
     if errc:
         ver['error'] = err or out
         return ver
     lines = out.strip().split("\n")[2:]
     if not lines:
         ver['error'] = 'No results. Bad package name?'
         return ver
     if len(lines) > 1:
         ver['error'] = \
                 "`%s latest-pkg` returned more than one result. WAT?" \
                 % self.command
         return ver
     line = lines[0]
     cols = re.split(' +', line)
     if len(cols) == 1:
         ver['error'] = '%s output parsing failed: %s' % (self.command,
                                                          line)
         return ver
     nvr = parse_nvr(cols[0], pkg_name)
     ver.update(nvr)
     return ver
Example #2
0
 def _get_version(self, pkg_name, branch):
     ver = {}
     cmd = 'bodhi -L %s' % pkg_name
     ver['cmd'] = cmd
     if pkg_name not in self.cache:
         errc, out, err = run(cmd)
         if errc:
             ver['error'] =  err or out
             return ver
         if not out:
             ver['error'] = 'No version returned.'
             return ver
         pkg_vers = {}
         for line in out.rstrip().split('\n'):
             line = line.strip()
             br, nvr = re.split(' +', line)
             pkg_vers[br] = parse_nvr(nvr, pkg_name)
         self.cache[pkg_name] = pkg_vers
     pkg_vers = self.cache[pkg_name]
     if branch not in pkg_vers:
         ver['error'] = "Tag not found."
         return ver
     ver.update(pkg_vers[branch])
     testing_branch = "%s-testing" % branch
     if testing_branch in pkg_vers:
         ver['next'] = pkg_vers[testing_branch]
         ver['next']['cmd'] = cmd
     return ver
Example #3
0
 def _get_version(self, pkg_name, branch):
     hsh = hashlib.md5()
     hsh.update(self.repo_base)
     hsh.update(branch)
     repoid = "verw_%s" % hsh.hexdigest()
     ver = {}
     cmd = ("repoquery "
            "--repofrompath=%(repoid)s,%(repo_base)s/%(branch)s/ "
            "--repoid=%(repoid)s -q %(pkg_name)s" % {
                'repo_base': self.repo_base,
                'branch': branch,
                'pkg_name': pkg_name,
                'repoid': repoid})
     ver['cmd'] = cmd
     errc, out, err = run(cmd)
     if errc:
         ver['error'] = err or out
         return ver
     if not out:
         ver['error'] = "No version found."
         return ver
     lines = out.strip().split("\n")
     if len(lines) > 1:
         # TODO: Select best version.
         msg = "Got more than 1 version using repoquery... FIXME!"
         raise NotImplementedError(msg)
     nvr = parse_nvr(lines[0], pkg_name)
     ver.update(nvr)
     return ver
Example #4
0
 def _koji_get_version(self, pkg_name, branch):
     ver = {}
     cmd = "%s latest-pkg \"%s\" \"%s\"" % (self.command, branch, pkg_name)
     ver['cmd'] = cmd
     errc, out, err = run(cmd)
     if errc:
         ver['error'] = err or out
         return ver
     lines = out.strip().split("\n")[2:]
     if not lines:
         ver['error'] = 'No results. Bad package name?'
         return ver
     if len(lines) > 1:
         ver['error'] = \
                 "`%s latest-pkg` returned more than one result. WAT?" \
                 % self.command
         return ver
     line = lines[0]
     cols = re.split(' +', line)
     if len(cols) == 1:
         ver['error'] = '%s output parsing failed: %s' % (self.command,
                                                          line)
         return ver
     nvr = parse_nvr(cols[0], pkg_name)
     ver.update(nvr)
     return ver
Example #5
0
 def _get_version(self, pkg_name, branch):
     ver = {}
     cmd = 'bodhi -L %s' % pkg_name
     ver['cmd'] = cmd
     if pkg_name not in self.cache:
         errc, out, err = run(cmd)
         if errc:
             ver['error'] = err or out
             return ver
         if not out:
             ver['error'] = 'No version returned.'
             return ver
         pkg_vers = {}
         for line in out.rstrip().split('\n'):
             line = line.strip()
             br, nvr = re.split(' +', line)
             pkg_vers[br] = parse_nvr(nvr, pkg_name)
         self.cache[pkg_name] = pkg_vers
     pkg_vers = self.cache[pkg_name]
     if branch not in pkg_vers:
         ver['error'] = "Tag not found."
         return ver
     ver.update(pkg_vers[branch])
     testing_branch = "%s-testing" % branch
     if testing_branch in pkg_vers:
         ver['next'] = pkg_vers[testing_branch]
         ver['next']['cmd'] = cmd
     return ver
Example #6
0
 def _get_version(self, pkg_name, branch):
     ver = {}
     args = {"pkg_name": pkg_name, "branch": branch}
     try:
         repo = Repository()
         p = Package(pkg_name, None, None, repo)
         p.url = self.url_base % args
         p.regex = self.regex % args
         #print (p.name, p.upstream_versions, p.latest_upstream)
         p.upstream_versions
     except Exception as e:
         ver['error'] = str(e)
         ver['error'] += ' - Bad regex or URL?'
         return ver
     nvr = parse_nvr(p.latest_upstream, pkg_name)
     ver.update(nvr)
     return ver