当前位置: 首页>>代码示例>>Python>>正文


Python PackageUpdate.select方法代码示例

本文整理汇总了Python中bodhi.model.PackageUpdate.select方法的典型用法代码示例。如果您正苦于以下问题:Python PackageUpdate.select方法的具体用法?Python PackageUpdate.select怎么用?Python PackageUpdate.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bodhi.model.PackageUpdate的用法示例。


在下文中一共展示了PackageUpdate.select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testing_statistics

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
def testing_statistics():
    """ Calculate and display various testing statistics """
    from datetime import timedelta
    from bodhi.model import PackageUpdate

    deltas = []
    occurrences = {}
    accumulative = timedelta()

    for update in PackageUpdate.select():
        for comment in update.comments:
            if comment.text == 'This update has been pushed to testing':
                for othercomment in update.comments:
                    if othercomment.text == 'This update has been pushed to stable':
                        delta = othercomment.timestamp - comment.timestamp
                        deltas.append(delta)
                        occurrences[delta.days] = occurrences.setdefault(delta.days, 0) + 1
                        accumulative += deltas[-1]
                        break
                break

    deltas.sort()
    all = PackageUpdate.select().count()
    percentage = int(float(len(deltas)) / float(all) * 100)
    mode = sorted(occurrences.items(), cmp=lambda x, y: cmp(x[1], y[1]))[-1][0]

    print "%d out of %d updates went through testing (%d%%)" % (len(deltas), all, percentage)
    print "mean = %d days" % (accumulative.days / len(deltas))
    print "median = %d days" % deltas[len(deltas) / 2].days
    print "mode = %d days" % mode
开发者ID:kmcdowell85,项目名称:bodhi,代码行数:32,代码来源:util.py

示例2: nagmail

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
def nagmail():
    """
    Nag the submitters of updates based on a list of queries
    """
    log.info("Starting nagmail job!")
    queries = [
            ('old_testing', PackageUpdate.select(
                                    AND(PackageUpdate.q.status == 'testing',
                                        PackageUpdate.q.request == None)),
             lambda update: update.days_in_testing),
            ('old_pending', PackageUpdate.select(
                                    AND(PackageUpdate.q.status == 'pending',
                                        PackageUpdate.q.request == None)),
             lambda update: get_age_in_days(update.date_submitted)),
    ]
    oldname = None
    mail_admin = False
    #mail_proventesters = False

    for name, query, date in queries:
        for update in query:
            if date(update) > 14:
                if update.nagged:
                    if update.nagged.has_key(name) and update.nagged[name]:
                        if (datetime.utcnow() - update.nagged[name]).days < 7:
                            continue # Only nag once a week at most
                    nagged = update.nagged
                else:
                    nagged = {}

                if update.critpath:
                    if update.critpath_approved:
                        continue
                    else:
                        oldname = name
                        name = 'old_testing_critpath'
                        mail_admin = True
                        #mail_proventesters = True

                log.info("[%s] Nagging %s about %s" % (name, update.submitter,
                                                       update.title))
                mail.send(update.submitter, name, update)
                if mail_admin:
                    mail.send_admin(name, update)
                    mail_admin = False
                #if mail_proventesters:
                #    mail.send(config.get('proventesters_email'), name, update)
                #    mail_proventesters = False

                nagged[name] = datetime.utcnow()
                update.nagged = nagged

                if oldname:
                    name = oldname
                    oldname = None

    log.info("nagmail complete!")
开发者ID:ralphbean,项目名称:bodhi,代码行数:59,代码来源:jobs.py

示例3: save_db

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
def save_db():
    ## Save each release and it's metrics
    releases = []
    for release in Release.select():
        rel = {}
        for attr in ('name', 'long_name', 'id_prefix', 'dist_tag',
                     'locked', 'metrics'):
            rel[attr] = getattr(release, attr)
        releases.append(rel)

    updates = []
    all_updates = PackageUpdate.select()
    progress = ProgressBar(maxValue=all_updates.count())

    for update in all_updates:
        data = {}
        data['title'] = update.title
        data['builds'] = [(build.package.name, build.nvr) for build in update.builds]
        data['date_submitted'] = update.date_submitted
        data['date_pushed'] = update.date_pushed
        data['date_modified'] = update.date_modified
        data['release'] = [update.release.name, update.release.long_name,
                           update.release.id_prefix, update.release.dist_tag]
        data['submitter'] = update.submitter
        data['update_id'] = hasattr(update, 'update_id') and update.update_id or update.updateid
        data['type'] = update.type
        data['karma'] = update.karma
        data['cves'] = [cve.cve_id for cve in update.cves]
        data['bugs'] = []
        for bug in update.bugs:
            data['bugs'].append([bug.bz_id, bug.title, bug.security])
            if hasattr(bug, 'parent'):
                data['bugs'][-1].append(bug.parent)
            else:
                data['bugs'][-1].append(False)
        data['status'] = update.status
        data['pushed'] = update.pushed
        data['notes'] = update.notes
        data['request'] = update.request
        data['comments'] = [(c.timestamp, c.author, c.text, c.karma, c.anonymous) for c in update.comments]
        if hasattr(update, 'approved'):
            data['approved'] = update.approved
        else:
            data['approved'] = None

        updates.append(data)
        progress()

    # Save all buildroot overrides
    overrides = []
    for override in BuildRootOverride.select():
        try:
            overrides.append(override.__json__())
        except:
            print("Removing stray override: %s" % override)
            override.destroySelf()

    dump = file('bodhi-pickledb-%s' % time.strftime("%y%m%d.%H%M"), 'w')
    pickle.dump({'updates': updates, 'releases': releases, 'overrides': overrides}, dump)
    dump.close()
开发者ID:bitlord,项目名称:bodhi,代码行数:62,代码来源:pickledb.py

示例4: refresh

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
    def refresh(self):
        """ Refresh all of the metrics for all releases.

        For each release, initialize our metrics objects, and feed them every
        update for that release.  Do the necessary calculations, and then save
        our metrics to the database in the Release.metrics PickleCol.
        """
        log.info("Doing a hard refresh of our metrics data")
        metrics = {}
        updates = {}  # {release: [updates,]}
        all_updates = list(PackageUpdate.select())
        releases = list(Release.select())
        for release in releases:
            updates[release.name] = []
        for update in all_updates:
            updates[update.release.name].append(update)
        for release in releases:
            log.debug("Calculating metrics for %s" % release.name)
            self.init_metrics(release)
            for update in updates[release.name]:
                for metric in self.metrics:
                    metric.update(update)
            for metric in self.metrics:
                metric.done()
                metrics[metric.__class__.__name__] = metric.get_data()
            release.metrics = metrics
        hub.commit()
        del all_updates
        del releases
        log.info("Metrics generation complete!")
开发者ID:ralphbean,项目名称:bodhi,代码行数:32,代码来源:metrics.py

示例5: main

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
def main():
    load_config()
    __connection__ = hub = PackageHub("bodhi")
    if len(sys.argv) != 2:
        print "Usage: %s <release>" % sys.argv[0]
        sys.exit(1)
    try:
        release = Release.byName(sys.argv[1].upper())
    except SQLObjectNotFound:
        print "Cannot find Release '%s'" % sys.argv[1]
        sys.exit(1)

    updates = PackageUpdate.select(PackageUpdate.q.releaseID == release.id)
    progress = ProgressBar(maxValue=updates.count())
    print "Destroying all updates, comments, and bugs associated with %s" % release.name

    for update in updates:
        for comment in update.comments:
            comment.destroySelf()
        for build in update.builds:
            build.destroySelf()
        for bug in update.bugs:
            if len(bug.updates) == 1:
                bug.destroySelf()
        update.destroySelf()
        progress()

    release.destroySelf()
    hub.commit()
    print
开发者ID:ralphbean,项目名称:bodhi,代码行数:32,代码来源:rmrelease.py

示例6: default

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
    def default(self, search, *args, **kw):
        results = set()
        search = search.strip()

        # Search name-version-release
        map(results.add, PackageUpdate.select(
            LIKE(PackageUpdate.q.title, '%%%s%%' % search),
                 orderBy=PackageUpdate.q.date_submitted))

        # Search bug numbers
        try:
            map(lambda bug: map(results.add, bug.updates),
                Bugzilla.select(Bugzilla.q.bz_id==int(search)))
        except ValueError: # can't convert search search to integer
            pass

        # Search CVEs
        if search.startswith('CVE') or search.startswith('CAN'):
            # Search bug titles for CVE, since that is how we track them now
            map(lambda bug: map(results.add, bug.updates),
                Bugzilla.select(LIKE(Bugzilla.q.title, '%%%s%%' % search)))

            # We still have some CVE objects lying around, so search them too
            map(lambda cve: map(results.add, cve.updates),
                CVE.select(CVE.q.cve_id==search))

        # If there is only 1 result, then jump right to it
        num_items = len(results)
        if len(results) == 1:
            raise redirect(results.pop().get_url())

        return dict(updates=list(results), num_items=num_items,
                    title="%d Results Found" % num_items)
开发者ID:docent-net,项目名称:bodhi,代码行数:35,代码来源:search.py

示例7: approve_testing_updates

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
def approve_testing_updates():
    """
    Scan all testing updates and approve ones that have met the per-release
    testing requirements.

    https://fedoraproject.org/wiki/Package_update_acceptance_criteria
    """
    log.info('Running approve_testing_updates job...')
    for update in PackageUpdate.select(
            AND(PackageUpdate.q.status == 'testing',
                PackageUpdate.q.request == None)):
        # If this release does not have any testing requirements, skip it
        if not update.release.mandatory_days_in_testing:
            continue
        # If this has already met testing requirements, skip it
        if update.met_testing_requirements:
            continue
        # If this is a critpath update, skip it, since they have their own
        # testing requirements, aside from spending time in testing.
        if update.critpath:
            continue
        if update.meets_testing_requirements:
            log.info('%s now meets testing requirements' % update.title)
            update.comment(
                config.get('testing_approval_msg') % update.days_in_testing,
                author='bodhi')
    log.info('approve_testing_updates job complete.')
开发者ID:ralphbean,项目名称:bodhi,代码行数:29,代码来源:jobs.py

示例8: get_security_updates

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
 def get_security_updates(self, release):
     release = Release.select(Release.q.long_name==release)[0]
     return PackageUpdate.select(
             AND(PackageUpdate.q.releaseID == release.id,
                 PackageUpdate.q.type == 'security',
                 PackageUpdate.q.status == 'testing',
                 PackageUpdate.q.request == None))
开发者ID:ralphbean,项目名称:bodhi,代码行数:9,代码来源:masher.py

示例9: get_security_updates

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
 def get_security_updates(self, release):
     release = Release.select(Release.q.long_name == release)[0]
     updates = PackageUpdate.select(
         AND(PackageUpdate.q.releaseID == release.id,
             PackageUpdate.q.type == 'security',
             PackageUpdate.q.status == 'testing',
             PackageUpdate.q.request == None))
     updates = self.sort_by_days_in_testing(updates)
     return updates
开发者ID:docent-net,项目名称:bodhi,代码行数:11,代码来源:masher.py

示例10: save_db

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
def save_db():
    ## Save each release and it's metrics
    releases = []
    for release in Release.select():
        rel = {}
        for attr in ("name", "long_name", "id_prefix", "dist_tag", "locked", "metrics"):
            rel[attr] = getattr(release, attr)
        releases.append(rel)

    updates = []
    all_updates = PackageUpdate.select()
    progress = ProgressBar(maxValue=all_updates.count())

    for update in all_updates:
        data = {}
        data["title"] = update.title
        data["builds"] = [(build.package.name, build.nvr) for build in update.builds]
        data["date_submitted"] = update.date_submitted
        data["date_pushed"] = update.date_pushed
        data["date_modified"] = update.date_modified
        data["release"] = [
            update.release.name,
            update.release.long_name,
            update.release.id_prefix,
            update.release.dist_tag,
        ]
        data["submitter"] = update.submitter
        data["update_id"] = hasattr(update, "update_id") and update.update_id or update.updateid
        data["type"] = update.type
        data["karma"] = update.karma
        data["cves"] = [cve.cve_id for cve in update.cves]
        data["bugs"] = []
        for bug in update.bugs:
            data["bugs"].append([bug.bz_id, bug.title, bug.security])
            if hasattr(bug, "parent"):
                data["bugs"][-1].append(bug.parent)
            else:
                data["bugs"][-1].append(False)
        data["status"] = update.status
        data["pushed"] = update.pushed
        data["notes"] = update.notes
        data["request"] = update.request
        data["comments"] = [(c.timestamp, c.author, c.text, c.karma, c.anonymous) for c in update.comments]
        if hasattr(update, "approved"):
            data["approved"] = update.approved
        else:
            data["approved"] = None

        updates.append(data)
        progress()

    dump = file("bodhi-pickledb-%s" % time.strftime("%y%m%d.%H%M"), "w")
    pickle.dump({"updates": updates, "releases": releases}, dump)
    dump.close()
开发者ID:ralphbean,项目名称:bodhi,代码行数:56,代码来源:pickledb.py

示例11: get_unapproved_critpath_updates

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
 def get_unapproved_critpath_updates(self, release):
     release = Release.select(Release.q.long_name == release)[0]
     updates = []
     for update in PackageUpdate.select(
             AND(PackageUpdate.q.releaseID == release.id,
                 PackageUpdate.q.status == 'testing',
                 PackageUpdate.q.request == None),
             orderBy=PackageUpdate.q.date_submitted).reversed():
         if update.critpath and not update.critpath_approved:
             updates.append(update)
     updates = self.sort_by_days_in_testing(updates)
     return updates
开发者ID:docent-net,项目名称:bodhi,代码行数:14,代码来源:masher.py

示例12: get_unapproved_critpath_updates

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
 def get_unapproved_critpath_updates(self, release):
     release = Release.select(Release.q.long_name==release)[0]
     updates = []
     for update in PackageUpdate.select(
             AND(PackageUpdate.q.releaseID == release.id,
                 PackageUpdate.q.status != 'stable',
                 PackageUpdate.q.status != 'obsolete',
                 PackageUpdate.q.request == None),
             orderBy=PackageUpdate.q.date_submitted).reversed():
         if update.critpath and not update.critpath_approved:
             updates.append(update)
     return updates
开发者ID:ralphbean,项目名称:bodhi,代码行数:14,代码来源:masher.py

示例13: clean_testing_builds

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
def clean_testing_builds(untag=False):
    koji = get_session()
    for release in Release.select():
        stable_builds = koji.listTagged(release.stable_tag, latest=True)
        stable_nvrs = [build["nvr"] for build in stable_builds]
        print "Fetched %d builds tagged with %s" % (len(stable_builds), release.stable_tag)
        testing_builds = koji.listTagged(release.testing_tag, latest=True)
        print "Fetched %d builds tagged with %s" % (len(testing_builds), release.testing_tag)
        testing_nvrs = [build["nvr"] for build in testing_builds]
        for testing_build in testing_builds:
            for build in testing_builds:
                compare_builds(testing_build, build, untag, release.testing_tag)
            for build in stable_builds:
                compare_builds(testing_build, build, untag, release.testing_tag)

        # Find testing updates that aren't in the list of latest builds
        for update in PackageUpdate.select(
            AND(
                PackageUpdate.q.releaseID == release.id,
                PackageUpdate.q.status == "testing",
                PackageUpdate.q.request == None,
            )
        ):
            for build in update.builds:
                if build.nvr not in testing_nvrs:
                    latest_testing = None
                    latest_stable = None
                    for testing in testing_nvrs:
                        if testing.startswith(build.package.name + "-"):
                            latest_testing = testing
                            break
                    for stable in stable_nvrs:
                        if stable.startswith(build.package.name + "-"):
                            latest_stable = stable
                            break
                    if latest_testing:
                        koji_build = koji.getBuild(build.nvr)
                        latest_build = koji.getBuild(latest_testing)
                        if rpm.labelCompare(build_evr(koji_build), build_evr(latest_build)) < 0:
                            print "%s in testing, latest_testing = %s, latest_stable = %s" % (
                                update.title,
                                latest_testing,
                                latest_stable,
                            )
                            if untag:
                                print "Obsoleting %s" % update.title
                                update.obsolete(newer=latest_testing)
开发者ID:ralphbean,项目名称:bodhi,代码行数:49,代码来源:clean-testing.py

示例14: get_critpath_updates

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
    def get_critpath_updates(self, release=None, unapproved=None):
        i = 0
        entries = []
        base = config.get('base_address')
        title = 'Latest Critical Path Updates'
        query = [PackageUpdate.q.status != 'obsolete']
        if release:
            try:
                release = Release.byName(release)
            except SQLObjectNotFound:
                return dict(title = '%s release not found' % release, entries=[])
            releases = [release]
            title = title + ' for %s' % release.long_name
        else:
            releases = Release.select()
        if unapproved:
            query.append(PackageUpdate.q.status != 'stable')
        for update in PackageUpdate.select(
                AND(OR(*[PackageUpdate.q.releaseID == release.id
                         for release in releases]),
                    *query),
                orderBy=PackageUpdate.q.date_submitted).reversed():

            delta = datetime.utcnow() - update.date_submitted
            if delta and delta.days > config.get('feeds.num_days_to_show'):
                if len(entries) >= config.get('feeds.max_entries'):
                    break

            if update.critpath:
                if unapproved:
                    if update.critpath_approved:
                        continue
                entries.append({
                    'id'        : base + url(update.get_url()),
                    'summary'   : update.notes,
                    'link'      : base + url(update.get_url()),
                    'published' : update.date_submitted,
                    'updated'   : update.date_submitted,
                    'title'     : update.title,
                })
                i += 1
        return dict(
                title = title,
                subtitle = "",
                link = config.get('base_address') + url('/'),
                entries = entries
        )
开发者ID:docent-net,项目名称:bodhi,代码行数:49,代码来源:rss.py

示例15: main

# 需要导入模块: from bodhi.model import PackageUpdate [as 别名]
# 或者: from bodhi.model.PackageUpdate import select [as 别名]
def main():
    load_config()
    print "Calculating F11 0day update metrics..."
    updates = {'bugfix': [], 'security': [], 'enhancement': [], 'newpackage': []}
    date = datetime(*time.strptime('06-09-2009', '%m-%d-%Y')[:-2])
    f11 = Release.byName('F11')
    for update in PackageUpdate.select(PackageUpdate.q.releaseID==f11.id):
        for comment in update.comments:
            if comment.author == 'bodhi' and comment.timestamp < date and \
               comment.text.startswith('This update has been pushed to stable'):
                updates[update.type].append(update.title)
                break

    pprint(updates)
    print '=' * 80
    print 'F11 0day stats'
    print ' * %d security' % len(updates['security'])
    print ' * %d bugfixes' % len(updates['bugfix'])
    print ' * %d enhancements' % len(updates['enhancement'])
    print ' * %d newpackage' % len(updates['newpackage'])
开发者ID:bitlord,项目名称:bodhi,代码行数:22,代码来源:0day.py


注:本文中的bodhi.model.PackageUpdate.select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。