当前位置: 首页>>代码示例>>Python>>正文


Python Job.from_thriftjob方法代码示例

本文整理汇总了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)
    ]
开发者ID:acnithin,项目名称:hue,代码行数:32,代码来源:views.py

示例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]
开发者ID:optimistdk,项目名称:hue,代码行数:31,代码来源:views.py

示例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]
开发者ID:Andrea1988,项目名称:hue,代码行数:10,代码来源:api.py


注:本文中的jobbrowser.models.Job.from_thriftjob方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。