Esempio n. 1
0
 def __init__(self, cache_path, yum_conf, tagger_url=None, pkgdb_url=None):
     self.cache_path = cache_path
     self.dbpath = join(cache_path, 'search')
     self.yum_cache_path = join(cache_path, 'yum-cache')
     self.icons_path = join(cache_path, 'icons')
     self.yum_conf = yum_conf
     self.create_index()
     self._owners_cache = None
     self.default_icon = 'package_128x128'
     self.tagger_url = tagger_url
     if pkgdb_url:
         self.pkgdb_client = PackageDB(base_url=pkgdb_url)
     else:
         self.pkgdb_client = PackageDB()
    def request_collection_table(self, eol=False):
        session_id = None
        if self._environ:
            identity = self._environ.get('repoze.who.identity')
            if identity:
                session_id = identity.get('session_id')

        table = {}
        pkgdb = PackageDB(self._base_url,
                          insecure=self._insecure,
                          session_id=session_id)
        co = pkgdb.get_collection_list(eol=eol)
        for c, num in co:
            table[c['id']] = c

        return table
Esempio n. 3
0
if __name__ == '__main__':
    print 'Username: '******'Password: '******'http://bapp01/pkgdb/',
                      username=username,
                      password=password)
    collections = dict([(c[0]['id'], c[0])
                        for c in pkgdb.get_collection_list(eol=False)])
    pkgs = pkgdb.user_packages('mmaslano', acls=['owner', 'approveacls']).pkgs

    for pkg in (p for p in pkgs if p['name'].startswith('perl-')):
        c_ids = (p['collectionid'] for p in pkg['listings']
                 if p['collectionid'] in collections)
        branches = [collections[c]['branchname'] for c in c_ids]
        pkgdb.edit_package(pkg['name'],
                           comaintainers=['ppisar'],
                           branches=branches)

    sys.exit(0)
Esempio n. 4
0
def get_pkg_pushers(pkgName,
                    collectionName='Fedora',
                    collectionVersion='devel'):
    """ Pull users who can commit and are watching a package

    Return two two-tuples of lists:
    * The first tuple is for usernames.  The second tuple is for groups.
    * The first list of the tuple is for committers.  The second is for
      watchers.

    An example::
      >>> people, groups = get_pkg_pushers('foo', 'Fedora', 'devel')
      >>> print people
      (['toshio', 'lmacken'], ['wtogami', 'toshio', 'lmacken'])
      >>> print groups
      (['cvsextras'], [])

    Note: The interface to the pkgdb could undergo the following changes:
      FAS2 related:
      * pkg['packageListings'][0]['owneruser'] =>
        pkg['packageListings'][0]['owner']
      * pkg['packageListings'][0]['people'][0..n]['user'] =>
        pkg['packageListings'][0]['people'][0..n]['userid']

    * We may want to create a 'push' acl specifically for bodhi instead of
      reusing 'commit'.
    * ['status']['translations'] may one day contain more than the 'C'
      translation.  The pkgdb will have to figure out how to deal with that
      if so.

    This may raise: fedora.client.AppError if there's an error talking to the
    PackageDB (for instance, no such package)
    """
    if config.get('acl_system') == 'dummy':
        return (['guest'], ['guest']), (['guest'], ['guest'])

    pkgdb = PackageDB(config.get('pkgdb_url'))
    # Note if AppError is raised (for no pkgNamme or other server errors) we
    # do not catch the exception here.
    pkg = pkgdb.get_owners(pkgName, collectionName, collectionVersion)

    # Owner is allowed to commit and gets notified of pushes
    # This will always be the 0th element as we'll retrieve at most one
    # value for any given Package-Collection-Version
    pNotify = [pkg.packageListings[0]['owner']]
    pAllowed = [pNotify[0]]

    # Find other people in the acl
    for person in pkg['packageListings'][0]['people']:
        if person['aclOrder']['watchcommits'] and \
           pkg['statusMap'][str(person['aclOrder']['watchcommits']['statuscode'])] == 'Approved':
            pNotify.append(person['username'])
        if person['aclOrder']['commit'] and \
           pkg['statusMap'][str(person['aclOrder']['commit']['statuscode'])] == 'Approved':
            pAllowed.append(person['username'])

    # Find groups that can push
    gNotify = []
    gAllowed = []
    for group in pkg['packageListings'][0]['groups']:
        if group['aclOrder']['watchcommits'] and \
           pkg['statusMap'][str(group['aclOrder']['watchcommits']['statuscode'])] == 'Approved':
            gNotify.append(group['groupname'])
        if group['aclOrder']['commit'] and \
           pkg['statusMap'][str(group['aclOrder']['commit']['statuscode'])] == 'Approved':
            gAllowed.append(group['groupname'])

    return ((pAllowed, pNotify), (gAllowed, gNotify))
 def get_pkgdb(self):
     return PackageDB(self._base_url, insecure=self._insecure)
Esempio n. 6
0
# Determine how many critical path packages failed to build from source using
# gcc -Werror=format-security. https://fedoraproject.org/wiki/Changes/FormatSecurity

import os
import subprocess

from collections import defaultdict
from fedora.client import PackageDB

pkgdb = PackageDB('https://admin.fedoraproject.org/pkgdb')
critpath = pkgdb.get_critpath_pkgs(['devel'])['devel']
print('%d critpath packages in devel' % len(critpath))

logs = 'http://people.fedoraproject.org/~halfie/rebuild-logs.txt'
if not os.path.exists('rebuild-logs.txt'):
    subprocess.call('wget %s' % logs, shell=True)

critpath_ftbfs = defaultdict(list)

with file('rebuild-logs.txt') as log:
    for line in log:
        pkg = '-'.join(line.split(':')[0].split('-')[:-2])
        if pkg in critpath:
            critpath_ftbfs[pkg].append(line.strip())

print('%d FTBFS with -Werror=format-security' % len(critpath_ftbfs))
for pkg in sorted(critpath_ftbfs):
    print('')
    for line in critpath_ftbfs[pkg]:
        print(line)