예제 #1
0
def main():
    ''' Retrieve the list of packages to monitor and set the monitoring
    flag in pkgdb
    '''
    args = get_args()

    pkgs = get_packages()

    url = args.url
    if args.prod:
        url = 'https://admin.fedoraproject.org/pkgdb'

    pkgdbclient = pkgdb2client.PkgDB(
        url,
        insecure=True,
        login_callback=pkgdb2client.ask_password
    )

    for pkg in pkgs:
        args = {
            'pkgnames': pkg,
        }
        try:
            pkgdbclient.handle_api_call(
                '/package/%s/monitor/1' % pkg, data=args
            )
        except pkgdb2client.PkgDBException as err:
            print pkg, err
def get_pkgdb_packages(status=PKGDB_ORPHANED,
                       branches="master",
                       use_cache=True):
    if use_cache is True:
        # cachefile = "{}-{}.json".format(branches, status)
        cachefile = "%s-%s.json" % (branches, status)
        cacheurl = PKGDB_CACHE_URL + cachefile
        if requests is None:
            resp = StringIO()
            c = pycurl.Curl()
            c.setopt(c.URL, cacheurl)
            c.setopt(c.WRITEFUNCTION, resp.write)
            c.perform()
            c.close()
            result = json.loads(resp.getvalue())
        else:
            resp = requests.get(cacheurl)
            result = resp.json()
    else:
        if pkgdb2client is None:
            raise RuntimeError("Error: required module pkgdb2client not found")
        pkgdb = pkgdb2client.PkgDB()
        result = pkgdb.get_packages(branches=branches,
                                    status=status,
                                    page="all")
    return [x["name"] for x in result["packages"]]
예제 #3
0
    def retire(self):
        try:
            # Skip if package is already retired to allow to retire only in
            # pkgdb
            if os.path.isfile(os.path.join(self.cmd.path, 'dead.package')):
                self.log.warn('dead.package found, package probably already '
                              'retired - will not remove files from git or '
                              'overwrite existing dead.package file')
            else:
                self.cmd.retire(self.args.reason)
            self.push()

            # get module name from git, because pyrpkg gets it from SPEC,
            # which is deleted at this point
            cmd = ['git', 'config', '--get', 'remote.origin.url']
            module_name = subprocess.check_output(cmd, cwd=self.cmd.path)
            module_name = \
                module_name.strip().split(self.cmd.gitbaseurl %
                                          {'user': self.cmd.user,
                                           'module': ''})[1]
            branch = self.cmd.branch_merge
            pkgdb = pkgdb2client.PkgDB(
                login_callback=pkgdb2client.ask_password)
            pkgdb.retire_packages(module_name, branch)
        except Exception, e:
            self.log.error('Could not retire package: %s' % e)
            sys.exit(1)
def get_active_branches():
    pkgdb = pkgdb2client.PkgDB()

    branches = []
    for status in ["Active", "Under Development"]:
        for collection in pkgdb.get_collections(
                clt_status=status)["collections"]:
            branches.append(collection["branchname"])
    return branches
예제 #5
0
def pkgdb_packages(base_url, extra=False):
    """ Return a generator over all the packages in pkgdb.  """
    import pkgdb2client
    log.info("Connecting to pkgdb at %r" % base_url)
    pkgdb = pkgdb2client.PkgDB(url=base_url)
    result = pkgdb.get_packages(page='all')
    packages = result['packages']
    if extra:
        for i in range(len(packages)):
            package = pkgdb.get_package(packages[i]['name'])
            collections = [p['collection'] for p in package['packages']]
            packages[i]['collections'] = collections
            yield packages[i]
    else:
        for i in range(len(packages)):
            yield packages[i]
예제 #6
0
파일: fedora.py 프로젝트: xsuchy/faf
    def __init__(self):
        super(Fedora, self).__init__()

        self.load_config_to_self("eol", ["fedora.supporteol"],
                                 False,
                                 callback=str2bool)
        self.load_config_to_self("pkgdb_url", ["fedora.pkgdburl"],
                                 "https://admin.fedoraproject.org/pkgdb/")

        self._pkgdb = pkgdb2client.PkgDB(url=self.pkgdb_url)

        self.load_config_to_self("build_aging_days",
                                 ["fedora.build-aging-days"],
                                 7,
                                 callback=int)
        self.load_config_to_self("koji_url", ["fedora.koji-url"], None)
예제 #7
0
    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 = pkgdb2client.PkgDB(self._base_url)
        if not eol:
            active = ['Active', 'Under Development']
            co = pkgdb.get_collections(clt_status=active)
        else:
            co = pkgdb.get_collections()

        for c in co['collections']:
            table[c['branchname']] = c

        return table
예제 #8
0
파일: cli.py 프로젝트: hobbes1069/rfpkg
    def retire(self):
        try:
            repo_name = self.cmd.repo_name
            ns_repo_name = self.cmd.ns_repo_name
            namespace = ns_repo_name.split(repo_name)[0].rstrip('/')
            # Skip if package is already retired to allow to retire only in
            # pkgdb
            if os.path.isfile(os.path.join(self.cmd.path, 'dead.package')):
                self.log.warn('dead.package found, package probably already '
                              'retired - will not remove files from git or '
                              'overwrite existing dead.package file')
            else:
                self.cmd.retire(self.args.reason)
            self.push()

            branch = self.cmd.branch_merge
            pkgdb = pkgdb2client.PkgDB(
                login_callback=pkgdb2client.ask_password, url="https://admin.rpmfusion.org/pkgdb")
            pkgdb.retire_packages(repo_name, branch, namespace=namespace)
        except Exception as e:
            self.log.error('Could not retire package: %s' % e)
            sys.exit(1)
예제 #9
0
https://fedoraproject.org/wiki/How_to_remove_a_package_at_end_of_life

According to https://fedoraproject.org/wiki/Schedule branching will
occur not earlier than 2014-07-08. The packages will be retired shortly before.

Note: If you received this mail directly you (co)maintain one of the affected
packages or a package that depends on one.
""".format(TAG.upper())

FOOTER = """The script creating this output is run and developed by Fedora
Release Engineering. Please report issues at its trac instance:
https://fedorahosted.org/rel-eng/
The sources of this script can be found at:
https://git.fedorahosted.org/cgit/releng/tree/scripts/find_unblocked_orphans.py
"""
pkgdb = pkgdb2client.PkgDB()


def get_cache(filename, max_age=3600, cachedir='~/.cache', default=None):
    """ Get a pickle file from cache
    :param filename: Filename with pickle data
    :type filename: str
    :param max_age: Maximum age of cache in seconds
    :type max_age: int
    :param cachedir: Directory to get file from
    :type cachedir: str
    :param default: Default value if cache is too old or does not exist
    :type default: object
    :returns: pickled object
    """
    cache_file = os.path.expanduser(os.path.join(cachedir, filename))
예제 #10
0
                    help='A comma separated list of module '
                    'names to be created in staging.')
args = parser.parse_args()
users = [user.strip() for user in args.users.split(',')]
modules = [module.strip() for module in args.modules.split(',')]

print "%r will get full ACLs on new modules %r" % (users, modules)
response = raw_input("Does that look correct?  [y/N]")
if response.lower() != 'y':
    print "Exiting."
    sys.exit(0)
else:
    print "Ok."

client = pkgdb2client.PkgDB(
    'https://admin.stg.fedoraproject.org/pkgdb',
    login_callback=pkgdb2client.ask_password,
)

modules = [{
    'name': name,
    'summary': 'The %s module' % name,
    'description': 'This is a test entry for modularity development.',
    'review_url': 'https://fedoraproject.org/wiki/Modularity',
    'upstream_url': 'https://fedoraproject.org/wiki/Modularity',
    'status': 'Approved',
    'namespace': 'modules',
} for name in modules]

for module in modules:
    print "Handling %s/%s" % (module['namespace'], module['name'])
    client.create_package(
import pkgdb2client


def get_active_branches():
    pkgdb = pkgdb2client.PkgDB()

    branches = []
    for status in ["Active", "Under Development"]:
        for collection in pkgdb.get_collections(
                clt_status=status)["collections"]:
            branches.append(collection["branchname"])
    return branches


if __name__ == "__main__":
    pkgdb = pkgdb2client.PkgDB()
    states = ["Approved", "Retired", "Orphaned"]
    try:
        outdir = sys.argv[1]
    except IndexError:
        outdir = "./"

    for branch in get_active_branches():
        for status in states:
            result = pkgdb2client.PkgDB().get_packages(branches=branch,
                                                       status=status,
                                                       page="all")
            outfilename = "{}-{}.json".format(branch, status)
            outfile = tempfile.NamedTemporaryFile(dir=outdir,
                                                  suffix=outfilename,
                                                  delete=False)
예제 #12
0
 def get_pkgdb(self):
     return pkgdb2client.PkgDB(self._base_url)