本文整理汇总了Python中bodhi.model.PackageUpdate类的典型用法代码示例。如果您正苦于以下问题:Python PackageUpdate类的具体用法?Python PackageUpdate怎么用?Python PackageUpdate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackageUpdate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testing_statistics
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
示例2: _lock
def _lock(self):
""" Write out what updates we are pushing and any successfully mashed
repositories to our MASHING lock """
mashed_dir = config.get("mashed_dir")
mash_stage = config.get("mashed_stage_dir")
mash_lock = join(mashed_dir, "MASHING-%s" % self.mash_lock_id)
if not os.path.isdir(mashed_dir):
log.info("Creating mashed_dir %s" % mashed_dir)
os.makedirs(mashed_dir)
if not os.path.isdir(mash_stage):
log.info("Creating mashed_stage_dir %s" % mash_stage)
os.makedirs(mash_stage)
if os.path.exists(mash_lock):
if self.resume:
log.debug("Resuming previous push!")
lock = file(mash_lock, "r")
masher_state = pickle.load(lock)
lock.close()
# For backwards compatability, we need to make sure we handle
# masher state that is just a list of updates, as well as a
# dictionary of updates and successfully mashed repos
if isinstance(masher_state, list):
for up in masher_state:
try:
up = PackageUpdate.byTitle(up)
self.updates.add(up)
except SQLObjectNotFound:
log.warning("Cannot find %s" % up)
# { 'updates' : [PackageUpdate.title,],
# 'repos' : ['/path_to_completed_repo',] }
elif isinstance(masher_state, dict):
for up in masher_state["updates"]:
try:
up = PackageUpdate.byTitle(up)
self.updates.add(up)
except SQLObjectNotFound:
log.warning("Cannot find %s" % up)
for repo in masher_state["composed_repos"]:
self.composed_repos.append(repo)
else:
log.error("Unknown masher lock format: %s" % masher_state)
raise MashTaskException
else:
log.error("Previous mash not complete! Either resume the last " "push, or remove %s" % mash_lock)
raise MashTaskException
else:
if self.resume:
msg = "Trying to resume a push, yet %s doesn't exist!" % mash_lock
log.error(msg)
raise MashTaskException(msg)
log.debug("Creating lock for updates push: %s" % mash_lock)
lock = file(mash_lock, "w")
pickle.dump(
{"updates": [update.title for update in self.updates], "composed_repos": self.composed_repos}, lock
)
lock.close()
示例3: nagmail
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!")
示例4: get_update
def get_update(self, name='TurboGears-1.0.2.2-2.fc7'):
update = PackageUpdate(title=name,
release=get_rel(),
submitter='[email protected]',
status='testing',
notes='foobar',
type='security')
build = get_build(name)
update.addPackageBuild(build)
return update
示例5: test_delete
def test_delete(self):
bodhi = self.__get_bodhi_client()
opts = self.__get_opts()
self.__save_update(self.build, opts, bodhi)
assert PackageUpdate.byTitle(self.build)
data = bodhi.delete(update=self.build)
try:
PackageUpdate.byTitle(self.build)
assert False, "Update not deleted properly"
except SQLObjectNotFound:
pass
示例6: test_request
def test_request(self):
bodhi = self.__get_bodhi_client()
opts = self.__get_opts()
self.__save_update(self.build, opts, bodhi)
assert PackageUpdate.byTitle(self.build)
bodhi.request(update=self.build, request=opts.request)
update = PackageUpdate.byTitle(self.build)
assert update.request == 'testing'
opts.request = 'testing'
bodhi.request(update=self.build, request=opts.request)
update = PackageUpdate.byTitle(self.build)
assert update.request == 'testing'
示例7: test_comment
def test_comment(self):
bodhi = self.__get_bodhi_client()
opts = self.__get_opts()
self.__save_update(self.build, opts, bodhi)
assert PackageUpdate.byTitle(self.build)
bodhi.comment(update=self.build, comment=opts.comment, karma=opts.karma)
update = PackageUpdate.byTitle(self.build)
assert len(update.comments) == 2, update.comments
assert update.comments[1].text == opts.comment
assert update.karma == int(opts.karma)
bodhi.comment(update=self.build, comment=opts.comment, karma=1)
update = PackageUpdate.byTitle(self.build)
assert len(update.comments) == 3, update.comments
assert update.karma == int(opts.karma) + 2
示例8: test_encoding
def test_encoding(self, buildnvr='yum-3.2.1-1.fc7'):
update = PackageUpdate(title=buildnvr,
release=get_rel(),
submitter=u'Foo \xc3\xa9 Bar <[email protected]>',
notes=u'Testing \u2019t stuff',
type='security')
assert update
assert update.notes == u'Testing \u2019t stuff'
assert update.submitter == u'Foo \xc3\xa9 Bar <[email protected]>'
build = get_build(buildnvr)
update.addPackageBuild(build)
update = PackageUpdate.byTitle(buildnvr)
assert update.builds[0].updates[0] == update
return update
示例9: approve_testing_updates
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.')
示例10: save_db
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()
示例11: test_file_input
def test_file_input(self):
bodhi = self.__get_bodhi_client()
opts = self.__get_opts()
out = file(opts.input_file, 'w')
out.write('''[%s]
type=enhancement
request=testing
bugs=123,456
notes=bar
autokarma=True
stable_karma=10
unstable_karma=-10
close_bugs=True
''' % self.build)
out.close()
updates = bodhi.parse_file(input_file=opts.input_file)
for update_args in updates:
bodhi.save(**update_args)
update = PackageUpdate.byTitle(self.build)
assert update.type == 'enhancement'
assert update.request == 'testing'
assert update.notes == 'bar', repr(update.notes)
for bug in (123, 456):
bz = Bugzilla.byBz_id(bug)
assert bz in update.bugs
os.unlink(opts.input_file)
示例12: get_security_updates
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))
示例13: main
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
示例14: refresh
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!")
示例15: default
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)