本文整理匯總了Python中bodhi.model.Release類的典型用法代碼示例。如果您正苦於以下問題:Python Release類的具體用法?Python Release怎麽用?Python Release使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Release類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: index
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,
)
示例2: clean_repo
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!")
示例3: test_epel7_tags
def test_epel7_tags(self):
el7 = Release(name='EPEL-7', long_name='Fedora EPEL 7',
id_prefix='FEDORA-EPEL', dist_tag='epel7')
assert el7.get_version() == 7
assert el7.candidate_tag == 'epel7-testing-candidate'
assert el7.testing_tag == 'epel7-testing'
assert el7.stable_tag == 'epel7'
assert el7.stable_repo == 'epel7'
示例4: clean_tables
def clean_tables():
from bodhi.model import Release, Package
print "Cleaning out tables"
Release.dropTable(ifExists=True, cascade=True)
Package.dropTable(ifExists=True, cascade=True)
hub.commit()
Release.createTable(ifNotExists=True)
Package.createTable(ifNotExists=True)
示例5: 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!")
示例6: 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()
示例7: list
def list(self, build=None, tg_errors=None, mine=False, release=None,
show_expired=False, **kw):
query = []
title = '%d Buildroot Overrides'
if mine:
show_expired = True
query.append(
BuildRootOverride.q.submitter == identity.current.user_name)
title += ' submitted by %s' % identity.current.user_name
if release:
rel = Release.byName(release)
query.append(
BuildRootOverride.q.releaseID == rel.id)
title += ' for %s' % rel.long_name
if not show_expired:
query.append(
BuildRootOverride.q.date_expired == None)
overrides = BuildRootOverride.select(AND(*query))
if request_format() == 'json':
overrides = [o.__json__() for o in overrides]
num_items = len(overrides)
else:
num_items = overrides.count()
return dict(overrides=overrides,
title=title % num_items,
num_items=num_items,
show_expired=show_expired,
mine=mine)
示例8: 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
示例9: 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))
示例10: get_widgets
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]
示例11: get_critpath_updates
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
)
示例12: _get_epel_release
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
示例13: get_rel
def get_rel():
rel = None
try:
rel = Release.byName('fc7')
except SQLObjectNotFound:
rel = Release(name='fc7', long_name='Fedora 7', id_prefix='FEDORA',
dist_tag='dist-fc7')
return rel
示例14: get_security_updates
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
示例15: 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()
dump = file("bodhi-pickledb-%s" % time.strftime("%y%m%d.%H%M"), "w")
pickle.dump({"updates": updates, "releases": releases}, dump)
dump.close()