本文整理汇总了Python中bkr.server.model.Job.by_tag方法的典型用法代码示例。如果您正苦于以下问题:Python Job.by_tag方法的具体用法?Python Job.by_tag怎么用?Python Job.by_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Job
的用法示例。
在下文中一共展示了Job.by_tag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import by_tag [as 别名]
def filter(self, filters):
"""
Returns a list of details for jobs filtered by the given criteria.
The *filter* argument must be a an XML-RPC structure (dict) specifying
filter criteria. The following keys are recognised:
'tags'
List of job tags.
'daysComplete'
Number of days elapsed since the jobs completion.
'family'
Job distro family, for example ``'RedHatEnterpriseLinuxServer5'``.
'product'
Job product name
'owner'
Job owner username
'mine'
Inclusion is equivalent to including own username in 'owner'
'whiteboard'
Job whiteboard
'limit'
Integer limit to number of jobs returned.
'minid'
Min JobID of the jobs to search
'maxid'
Maximum Job ID of the jobs to search
Returns a two-element array. The first element is an array of JobIDs
of the form ``'J:123'``, suitable to be passed to the
:meth:`jobs.delete_jobs` method. The second element is a human-readable
count of the number of Jobs matched. Does not return deleted jobs.
"""
# if min/max/both IDs have been specified, filter it right here
minid = filters.get('minid', None)
maxid = filters.get('maxid', None)
jobs = session.query(Job)
if minid:
jobs = jobs.filter(Job.id >= minid)
if maxid:
jobs = jobs.filter(Job.id <= maxid)
tags = filters.get('tags', None)
complete_days = filters.get('daysComplete', None)
family = filters.get('family', None)
product = filters.get('product', None)
owner = filters.get('owner', None)
whiteboard = filters.get('whiteboard', None)
mine = filters.get('mine', None)
limit = filters.get('limit', None)
if mine and not identity.not_anonymous():
raise BX(_('You should be authenticated to use the --mine filter.'))
if mine and identity.not_anonymous():
if owner:
if type(owner) is list:
owner.append(identity.current.user.user_name)
else:
owner = [owner, identity.current.user.user_name]
else:
owner = identity.current.user.user_name
jobs = jobs.order_by(Job.id.desc())
if tags:
jobs = Job.by_tag(tags, jobs)
if complete_days:
jobs = Job.complete_delta({'days':int(complete_days)}, jobs)
if family:
jobs = Job.has_family(family, jobs)
if product:
jobs = Job.by_product(product, jobs)
if owner:
jobs = Job.by_owner(owner, jobs)
if whiteboard:
jobs = Job.by_whiteboard(whiteboard, jobs)
jobs = Job.sanitise_jobs(jobs)
if limit:
limit = int(limit)
jobs = jobs.limit(limit)
jobs = jobs.values(Job.id)
return_value = ['J:%s' % j[0] for j in jobs]
return return_value