本文整理汇总了Python中jobbrowser.models.Job.from_thriftjob方法的典型用法代码示例。如果您正苦于以下问题:Python Job.from_thriftjob方法的具体用法?Python Job.from_thriftjob怎么用?Python Job.from_thriftjob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jobbrowser.models.Job
的用法示例。
在下文中一共展示了Job.from_thriftjob方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_matching_jobs
# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_thriftjob [as 别名]
def get_matching_jobs(request, **kwargs):
"""
Returns an array of jobs where the returned
jobs are matched by the provided filter arguments.
If a filter argument is in kwargs it will supersede the same argument
in the request object.
Filter arguments may be jobid, pools, user, tasks, text and state.
"""
jobfunc = {
"completed": request.jt.completed_jobs,
# Succeeded and completed are synonyms here.
"succeeded": request.jt.completed_jobs,
"running": request.jt.running_jobs,
"failed": request.jt.failed_jobs,
"killed": request.jt.killed_jobs,
"all": request.jt.all_jobs
}
if 'state' in kwargs:
selection = kwargs['state']
else:
selection = request.GET.get("state", "all")
joblist = jobfunc[selection]().jobs
return [
Job.from_thriftjob(request.jt, j)
for j in _filter_jobs_by_req(joblist, request, **kwargs)
]
示例2: get_matching_jobs
# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_thriftjob [as 别名]
def get_matching_jobs(request, check_permission=False, **kwargs):
"""
Returns an array of jobs where the returned
jobs are matched by the provided filter arguments.
If a filter argument is in kwargs it will supersede the same argument
in the request object.
Filter arguments may be jobid, pools, user, tasks, text and state.
Filter by user ownership if check_permission is set to true.
"""
jobfunc = {"completed" : (request.jt.completed_jobs, ThriftJobState.SUCCEEDED),
# Succeeded and completed are synonyms here.
"succeeded" : (request.jt.completed_jobs, ThriftJobState.SUCCEEDED),
"running" : (request.jt.running_jobs, ThriftJobState.RUNNING),
"failed" : (request.jt.failed_jobs, ThriftJobState.FAILED),
"killed" : (request.jt.killed_jobs, ThriftJobState.KILLED),
"all" : (request.jt.all_jobs, None)}
if 'state' in kwargs:
selection = kwargs['state']
else:
selection = request.GET.get("state", "all")
joblist = jobfunc[selection][0]().jobs + request.jt.retired_jobs(jobfunc[selection][1]).jobs
return [Job.from_thriftjob(request.jt, j)
for j in _filter_jobs_by_req(joblist, request, **kwargs)
if not check_permission or request.user.is_superuser or j.profile.user == request.user]
示例3: filter_jobs
# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_thriftjob [as 别名]
def filter_jobs(self, user, jobs, **kwargs):
check_permission = not SHARE_JOBS.get() and not user.is_superuser
limit = kwargs.pop('limit', 10000)
return [Job.from_thriftjob(self.jt, j)
for j in self._filter_jobs(jobs, **kwargs)
if not check_permission or user.is_superuser or j.profile.user == user.username][:limit]