本文整理汇总了Python中bodhi.model.Release.byName方法的典型用法代码示例。如果您正苦于以下问题:Python Release.byName方法的具体用法?Python Release.byName怎么用?Python Release.byName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bodhi.model.Release
的用法示例。
在下文中一共展示了Release.byName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [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,
)
示例2: list
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [as 别名]
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)
示例3: main
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [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
示例4: get_rel
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [as 别名]
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
示例5: get_critpath_updates
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [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
)
示例6: main
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [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'])
示例7: get_feed_data
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [as 别名]
def get_feed_data(self, release=None, type=None, status=None,
comments=False, submitter=None, builds=None,
user=None, package=None, critpath=False,
unapproved=None, *args, **kw):
query = []
entries = []
date = lambda update: update.date_pushed
order = PackageUpdate.q.date_pushed
title = []
critpath = critpath in (True, 'True', 'true')
unapproved = unapproved in (True, 'True', 'true')
if critpath:
return self.get_critpath_updates(release=release,
unapproved=unapproved)
if comments:
return self.get_latest_comments(user=user)
if package:
return self.get_package_updates(package, release)
if release:
try:
rel = Release.byName(release.upper())
except SQLObjectNotFound:
return dict(title = '%s not found' % release, entries=[])
query.append(PackageUpdate.q.releaseID == rel.id)
title.append(rel.long_name)
if type:
query.append(PackageUpdate.q.type == type)
title.append(type.title())
if status:
query.append(PackageUpdate.q.status == status)
if status == 'pending':
date = lambda update: update.date_submitted
order = PackageUpdate.q.date_submitted
else:
# Let's only show pushed testing/stable updates
query.append(PackageUpdate.q.pushed == True)
title.append(status.title())
else:
query.append(PackageUpdate.q.pushed == True)
if submitter:
query.append(PackageUpdate.q.submitter == submitter)
title.append("submitted by %s" % submitter)
if builds:
query.append(PackageUpdate.q.builds == builds)
title.append("for %s" % builds)
updates = PackageUpdate.select(AND(*query), orderBy=order).reversed()
for update in updates:
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
entries.append({
'id' : config.get('base_address') + url(update.get_url()),
'summary' : update.notes,
'published' : date(update),
'link' : config.get('base_address') + url(update.get_url()),
'title' : "%s %sUpdate: %s" % (update.release.long_name,
update.type == 'security'
and 'Security ' or '',
update.title)
})
if len(update.bugs):
bugs = "<b>Resolved Bugs</b><br/>"
for bug in update.bugs:
bugs += "<a href=%s>%d</a> - %s<br/>" % (bug.get_url(),
bug.bz_id, bug.title)
entries[-1]['summary'] = "%s<br/>%s" % (bugs[:-2],
entries[-1]['summary'])
title.append('Updates')
return dict(
title = ' '.join(title),
subtitle = "",
link = config.get('base_address') + url('/'),
entries = entries
)
示例8: load_db
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [as 别名]
def load_db():
print "\nLoading pickled database %s" % sys.argv[2]
db = file(sys.argv[2], "r")
data = pickle.load(db)
# Legacy format was just a list of update dictionaries
# Now we'll pull things out into an organized dictionary:
# {'updates': [], 'releases': []}
if isinstance(data, dict):
for release in data["releases"]:
try:
Release.byName(release["name"])
except SQLObjectNotFound:
Release(**release)
data = data["updates"]
progress = ProgressBar(maxValue=len(data))
for u in data:
try:
release = Release.byName(u["release"][0])
except SQLObjectNotFound:
release = Release(
name=u["release"][0], long_name=u["release"][1], id_prefix=u["release"][2], dist_tag=u["release"][3]
)
## Backwards compatbility
request = u["request"]
if u["request"] == "move":
request = "stable"
elif u["request"] == "push":
request = "testing"
elif u["request"] == "unpush":
request = "obsolete"
if u["approved"] in (True, False):
u["approved"] = None
if u.has_key("update_id"):
u["updateid"] = u["update_id"]
if not u.has_key("date_modified"):
u["date_modified"] = None
try:
update = PackageUpdate.byTitle(u["title"])
except SQLObjectNotFound:
update = PackageUpdate(
title=u["title"],
date_submitted=u["date_submitted"],
date_pushed=u["date_pushed"],
date_modified=u["date_modified"],
release=release,
submitter=u["submitter"],
updateid=u["updateid"],
type=u["type"],
status=u["status"],
pushed=u["pushed"],
notes=u["notes"],
karma=u["karma"],
request=request,
approved=u["approved"],
)
## Create Package and PackageBuild objects
for pkg, nvr in u["builds"]:
try:
package = Package.byName(pkg)
except SQLObjectNotFound:
package = Package(name=pkg)
try:
build = PackageBuild.byNvr(nvr)
except SQLObjectNotFound:
build = PackageBuild(nvr=nvr, package=package)
update.addPackageBuild(build)
## Create all Bugzilla objects for this update
for bug_num, bug_title, security, parent in u["bugs"]:
try:
bug = Bugzilla.byBz_id(bug_num)
except SQLObjectNotFound:
bug = Bugzilla(bz_id=bug_num, security=security, parent=parent)
bug.title = bug_title
update.addBugzilla(bug)
## Create all CVE objects for this update
for cve_id in u["cves"]:
try:
cve = CVE.byCve_id(cve_id)
except SQLObjectNotFound:
cve = CVE(cve_id=cve_id)
update.addCVE(cve)
for timestamp, author, text, karma, anonymous in u["comments"]:
comment = Comment(
timestamp=timestamp, author=author, text=text, karma=karma, update=update, anonymous=anonymous
)
progress()
示例9: list_tagged
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [as 别名]
import pkg_resources
import sys
from bodhi.util import load_config
from bodhi.model import Release
from bodhi.buildsys import get_session
def list_tagged(tag):
koji = get_session()
builds = koji.listTagged(tag)
nvrs = [build['nvr'] for build in builds]
print "Fetched %d builds tagged with %s" % (
len(builds), tag)
return nvrs
def clean_stable_builds(release):
dist_builds = list_tagged(release.dist_tag)
stable_builds = list_tagged(release.stable_tag)
for stable_build in stable_builds:
if stable_build in dist_builds:
print(stable_build)
if __name__ == '__main__':
load_config()
release = Release.byName('F21')
clean_stable_builds(release)
示例10: load_db
# 需要导入模块: from bodhi.model import Release [as 别名]
# 或者: from bodhi.model.Release import byName [as 别名]
def load_db():
print "\nLoading pickled database %s" % sys.argv[2]
db = file(sys.argv[2], 'r')
data = pickle.load(db)
# Load up all of the overrides
for override in data.get('overrides', []):
try:
BuildRootOverride.byBuild(override['build'])
except SQLObjectNotFound:
BuildRootOverride(**override)
# Legacy format was just a list of update dictionaries
# Now we'll pull things out into an organized dictionary:
# {'updates': [], 'releases': []}
if isinstance(data, dict):
for release in data['releases']:
try:
Release.byName(release['name'])
except SQLObjectNotFound:
Release(**release)
data = data['updates']
progress = ProgressBar(maxValue=len(data))
for u in data:
try:
release = Release.byName(u['release'][0])
except SQLObjectNotFound:
release = Release(name=u['release'][0], long_name=u['release'][1],
id_prefix=u['release'][2], dist_tag=u['release'][3])
## Backwards compatbility
request = u['request']
if u['request'] == 'move':
request = 'stable'
elif u['request'] == 'push':
request = 'testing'
elif u['request'] == 'unpush':
request = 'obsolete'
if u['approved'] in (True, False):
u['approved'] = None
if 'update_id' in u:
u['updateid'] = u['update_id']
if not 'date_modified' in u:
u['date_modified'] = None
try:
update = PackageUpdate.byTitle(u['title'])
except SQLObjectNotFound:
update = PackageUpdate(title=u['title'],
date_submitted=u['date_submitted'],
date_pushed=u['date_pushed'],
date_modified=u['date_modified'],
release=release,
submitter=u['submitter'],
updateid=u['updateid'],
type=u['type'],
status=u['status'],
pushed=u['pushed'],
notes=u['notes'],
karma=u['karma'],
request=request,
approved=u['approved'])
## Create Package and PackageBuild objects
for pkg, nvr in u['builds']:
try:
package = Package.byName(pkg)
except SQLObjectNotFound:
package = Package(name=pkg)
try:
build = PackageBuild.byNvr(nvr)
except SQLObjectNotFound:
build = PackageBuild(nvr=nvr, package=package)
update.addPackageBuild(build)
## Create all Bugzilla objects for this update
for bug_num, bug_title, security, parent in u['bugs']:
try:
bug = Bugzilla.byBz_id(bug_num)
except SQLObjectNotFound:
bug = Bugzilla(bz_id=bug_num, security=security, parent=parent)
bug.title = bug_title
update.addBugzilla(bug)
## Create all CVE objects for this update
for cve_id in u['cves']:
try:
cve = CVE.byCve_id(cve_id)
except SQLObjectNotFound:
cve = CVE(cve_id=cve_id)
update.addCVE(cve)
for timestamp, author, text, karma, anonymous in u['comments']:
comment = Comment(timestamp=timestamp, author=author, text=text,
karma=karma, update=update, anonymous=anonymous)
progress()