本文整理汇总了Python中bkr.server.model.Job.find_jobs方法的典型用法代码示例。如果您正苦于以下问题:Python Job.find_jobs方法的具体用法?Python Job.find_jobs怎么用?Python Job.find_jobs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Job
的用法示例。
在下文中一共展示了Job.find_jobs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_jobs
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import find_jobs [as 别名]
def delete_jobs(self, jobs=None, tag=None, complete_days=None, family=None, dryrun=False, product=None):
"""
delete_jobs will mark the job to be deleted
To select jobs by id, pass an array for the *jobs* argument. Elements
of the array must be strings of the form ``'J:123'``.
Alternatively, pass some combination of the *tag*, *complete_days*, or
*family* arguments to select jobs for deletion. These arguments behave
as per the :meth:`jobs.list` method.
If *dryrun* is True, deletions will be reported but nothing will be
modified.
Admins are not be able to delete jobs which are not owned by
themselves by using the tag, complete_days etc kwargs, instead, they
should do that via the *jobs* argument.
"""
if jobs: #Turn them into job objects
if not isinstance(jobs,list):
jobs = [jobs]
jobs_to_try_to_del = []
for j_id in jobs:
job = TaskBase.get_by_t_id(j_id)
if not isinstance(job,Job):
raise BeakerException('Incorrect task type passed %s' % j_id )
if not job.can_delete(identity.current.user):
raise BeakerException("You don't have permission to delete job %s" % j_id)
jobs_to_try_to_del.append(job)
delete_jobs_kw = dict(jobs=jobs_to_try_to_del)
else:
# only allow people to delete their own jobs while using these kwargs
delete_jobs_kw = dict(query=Job.find_jobs(tag=tag,
complete_days=complete_days,
family=family, product=product,
owner=identity.current.user.user_name))
deleted_jobs = Job.delete_jobs(**delete_jobs_kw)
msg = 'Jobs deleted'
if dryrun:
session.rollback()
msg = 'Dryrun only. %s' % (msg)
return '%s: %s' % (msg, [j.t_id for j in deleted_jobs])