本文整理匯總了Python中bodhi.model.Release.select方法的典型用法代碼示例。如果您正苦於以下問題:Python Release.select方法的具體用法?Python Release.select怎麽用?Python Release.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bodhi.model.Release
的用法示例。
在下文中一共展示了Release.select方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: clean_repo
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release import select [as 別名]
def clean_repo():
"""
Clean up our mashed_dir, removing all referenced repositories
"""
log.info("Starting clean_repo job")
liverepos = []
repos = config.get('mashed_dir')
mash_locks = set()
for release in Release.select():
lock = join(repos, 'MASHING-%s' % release.id_prefix)
mash_locks.add(lock)
if exists(lock):
log.info("Mash in progress. Aborting clean_repo job")
return
for release in [rel.name.lower() for rel in Release.select()]:
# TODO: keep the 2 most recent repos!
for repo in [release + '-updates', release + '-updates-testing']:
liverepos.append(dirname(realpath(join(repos, repo))))
for repo in [join(repos, repo) for repo in os.listdir(repos)]:
if 'repodata' in repo: # skip our repodata caches
continue
if not islink(repo) and isdir(repo):
fullpath = realpath(repo)
if fullpath not in liverepos:
log.info("Removing %s" % fullpath)
subprocess.call(['rm', '-fr', fullpath])
# Bail out if a push started in the middle of this job
for lock in mash_locks:
if exists(lock):
log.warning('Mash lock detected! Stopping clean_repo job.')
return
log.info("clean_repo complete!")
示例2: index
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release import select [as 別名]
def index(self, release=None):
# /updates/metrics?tg_format=json API
if request_format() == "json":
json = {}
query = release and [Release.byName(release)] or Release.select()
for release in query:
json[release.name] = release.metrics
return json
try:
if not release:
rel = Release.select()[0]
release = rel.name
else:
rel = Release.byName(release)
except SQLObjectNotFound:
flash("Unknown Release")
raise redirect("/metrics")
widgets = MetricData().get_widgets(release)
if not widgets:
return dict(metrics=[], title="Metrics currently unavailable")
return dict(
metrics=[widgets[name.__name__] for name in metrics if name.__name__ in widgets],
title="%s Update Metrics" % rel.long_name,
)
示例3: save_db
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release 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()
示例4: get_widgets
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release import select [as 別名]
def get_widgets(self, release):
""" Return the metrics for a specified release.
If our metric widgets are more than a day old, recreate them with
fresh metrics from our database.
"""
if self.age and get_age_in_days(self.age) < 1:
return self.widgets[release]
log.debug("Generating some fresh metric widgets...")
freshwidgets = {}
for rel in Release.select():
if not rel.metrics:
log.warning("No metrics found for %s" % rel.name)
return
self.init_metrics(rel)
if not freshwidgets.has_key(rel.name):
freshwidgets[rel.name] = {}
for metric in self.metrics:
widget = metric.get_widget(rel.metrics[metric.__class__.__name__])
if widget:
freshwidgets[rel.name][metric.__class__.__name__] = widget
self.widgets = freshwidgets
self.age = datetime.utcnow()
return self.widgets[release]
示例5: refresh
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release 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!")
示例6: get_security_updates
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release 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))
示例7: _get_epel_release
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release import select [as 別名]
def _get_epel_release(self):
rel = Release.select(Release.q.name=='EL5')
if rel.count():
rel = rel[0]
else:
rel = Release(name='EL5', long_name='Fedora EPEL 5', id_prefix='FEDORA-EPEL',
dist_tag='dist-5E-epel')
return rel
示例8: get_security_updates
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release 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
示例9: save_db
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release 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()
示例10: get_unapproved_critpath_updates
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release 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
示例11: get_unapproved_critpath_updates
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release 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
示例12: send_digest_mail
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release import select [as 別名]
def send_digest_mail(self):
"""
Send digest mail to mailing lists
"""
for prefix, content in self.testing_digest.items():
log.debug("Sending digest for updates-testing %s" % prefix)
maildata = u""
try:
security_updates = self.get_security_updates(prefix)
if security_updates:
maildata += u"The following %s Security updates need testing:\n Age URL\n" % prefix
for update in security_updates:
maildata += u" %3i %s%s\n" % (
update.days_in_testing,
config.get("base_address"),
url(update.get_url()),
)
maildata += "\n\n"
critpath_updates = self.get_unapproved_critpath_updates(prefix)
if critpath_updates:
maildata += u"The following %s Critical Path updates have yet to be approved:\n Age URL\n" % prefix
for update in self.get_unapproved_critpath_updates(prefix):
maildata += u" %3i %s%s\n" % (
update.days_in_testing,
config.get("base_address"),
url(update.get_url()),
)
maildata += "\n\n"
except Exception, e:
log.exception(e)
maildata += u"The following builds have been pushed to %s updates-testing\n\n" % prefix
# get a list af all nvr's
updlist = content.keys()
# sort the list
updlist.sort()
# Add the list of builds to the mail
for pkg in updlist:
maildata += u" %s\n" % pkg
# Add some space between the short list and the Details"
maildata += u"\nDetails about builds:\n\n"
# Add the detail of each build
for nvr in updlist:
maildata += u"\n" + self.testing_digest[prefix][nvr]
release = Release.select(Release.q.long_name == prefix)[0]
mail.send_mail(
config.get("bodhi_email"),
config.get("%s_test_announce_list" % release.id_prefix.lower().replace("-", "_")),
"%s updates-testing report" % prefix,
maildata,
)
示例13: _fetch_candidate_builds
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release import select [as 別名]
def _fetch_candidate_builds(self, pkg):
""" Return all candidate builds for a given package """
matches = {}
koji = get_session()
koji.multicall = True
for tag in [r.candidate_tag for r in Release.select()]:
koji.listTagged(tag, package=pkg)
results = koji.multiCall()
for result in results:
for entries in result:
for entry in entries:
matches[entry['nvr']] = entry['completion_time']
return [build[0] for build in
sorted(matches.items(), key=itemgetter(1), reverse=True)]
示例14: masher
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release import select [as 別名]
def masher(self):
""" Display the current status of the Masher """
if config.get('masher'):
data = self._masher_request('/admin/masher')
if not data:
data = {'masher_str': 'Unable to contact the masher', 'tags': []}
return dict(masher_str=data['masher_str'], tags=data['tags'])
else:
from bodhi.masher import masher
tags = []
for release in Release.select():
tags.append(release.stable_tag)
tags.append(release.testing_tag)
return dict(masher_str=str(masher), tags=tags)
示例15: clean_stable_builds
# 需要導入模塊: from bodhi.model import Release [as 別名]
# 或者: from bodhi.model.Release import select [as 別名]
def clean_stable_builds(untag=False):
koji = get_session()
for release in Release.select():
latest_stable_builds = koji.listTagged(release.stable_tag, latest=True)
latest_stable_nvrs = [build['nvr'] for build in latest_stable_builds]
print "Fetched %d latest stable builds tagged with %s" % (
len(latest_stable_builds), release.stable_tag)
stable_builds = koji.listTagged(release.stable_tag)
stable_nvrs = [build['nvr'] for build in stable_builds]
print "Fetched %d stable builds tagged with %s" % (
len(stable_builds), release.stable_tag)
for latest_build in latest_stable_builds:
for build in stable_builds:
if build['nvr'] == latest_build['nvr']:
continue
compare_builds(latest_build, build, untag, release.stable_tag)