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


Python models.Job类代码示例

本文整理汇总了Python中jobbrowser.models.Job的典型用法代码示例。如果您正苦于以下问题:Python Job类的具体用法?Python Job怎么用?Python Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Job类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: kill_job

def kill_job(request, jobid):
  """
  We get here from /jobs/jobid/kill
  """
  if request.method != "POST":
    raise Exception(_("kill_job may only be invoked with a POST (got a %(method)s)") % dict(method=request.method))
  job = Job.from_id(jt=request.jt, jobid=jobid)
  if job.user != request.user.username and not request.user.is_superuser:
    access_warn(request, _('Insufficient permission'))
    raise MessageException(_("Permission denied.  User %(username)s cannot delete user %(user)s's job.") %
                           dict(username=request.user.username, user=job.user))

  job.kill()
  cur_time = time.time()
  while time.time() - cur_time < 15:
    job = Job.from_id(jt=request.jt, jobid=jobid)

    if job.status not in ["RUNNING", "QUEUED"]:
      if request.REQUEST.get("next"):
        return HttpResponseRedirect(request.REQUEST.get("next"))
      else:
        raise MessageException("Job Killed")
    time.sleep(1)
    job = Job.from_id(jt=request.jt, jobid=jobid)

  raise Exception(_("Job did not appear as killed within 15 seconds"))
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:26,代码来源:views.py

示例2: kill_job

def kill_job(request, job):
  if request.method != "POST":
    raise Exception(_("kill_job may only be invoked with a POST (got a %(method)s).") % dict(method=request.method))

  if job.user != request.user.username and not request.user.is_superuser:
    access_warn(request, _('Insufficient permission'))
    raise MessageException(_("Permission denied.  User %(username)s cannot delete user %(user)s's job.") %
                           dict(username=request.user.username, user=job.user))

  job.kill()
  cur_time = time.time()
  while time.time() - cur_time < 15:
    job = Job.from_id(jt=request.jt, jobid=job.jobId)

    if job.status not in ["RUNNING", "QUEUED"]:
      if request.REQUEST.get("next"):
        return HttpResponseRedirect(request.REQUEST.get("next"))
      elif request.REQUEST.get("format") == "json":
        return HttpResponse(encode_json_for_js({'status': 0}), mimetype="application/json")
      else:
        raise MessageException("Job Killed")
    time.sleep(1)
    job = Job.from_id(jt=request.jt, jobid=job.jobId)

  raise Exception(_("Job did not appear as killed within 15 seconds."))
开发者ID:chiehwen,项目名称:hue,代码行数:25,代码来源:views.py

示例3: job_single_logs

def job_single_logs(request, jobid):
  """
  We get here from /jobs/jobid/logs
  """
  job = Job.from_id(jt=request.jt, jobid=jobid)

  def cmp_exec_time(task1, task2):
    return cmp(task1.execStartTimeMs, task2.execStartTimeMs)

  task = None

  failed_tasks = job.filter_tasks(task_states=('failed',))
  failed_tasks.sort(cmp_exec_time)
  if failed_tasks:
    task = failed_tasks[0]
  else:
    recent_tasks = job.filter_tasks(task_states=('running', 'succeeded',), task_types=('map', 'reduce',))
    recent_tasks.sort(cmp_exec_time, reverse=True)
    if recent_tasks:
      task = recent_tasks[0]

  if task is None:
    raise PopupException(_("No tasks found for job %(id)s") % dict(id=jobid))

  return single_task_attempt_logs(request, **{'jobid': jobid, 'taskid': task.taskId, 'attemptid': task.taskAttemptIds[-1]})
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:25,代码来源:views.py

示例4: get_matching_jobs

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,代码行数:30,代码来源:views.py

示例5: get_matching_jobs

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,代码行数:29,代码来源:views.py

示例6: filter_jobs

  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,代码行数:8,代码来源:api.py

示例7: decorate

 def decorate(request, *args, **kwargs):
   jobid = kwargs['jobid']
   job = Job.from_id(jt=request.jt, jobid=jobid)
   if not conf.SHARE_JOBS.get() and not request.user.is_superuser \
     and job.user != request.user.username:
     raise PopupException(_("You don't have the permissions to access"
                            " job %(id)s") % dict(id=jobid))
   return view_func(request, *args, **kwargs)
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:8,代码来源:views.py

示例8: kill_job

def kill_job(request, jobid):
  """
  We get here from /jobs/jobid/kill
  """
  if request.method != "POST":
    raise Exception("kill_job may only be invoked with a POST (got a %s)" % request.method)
  job = Job.from_id(jt=request.jt, jobid=jobid)
  if job.user != request.user.username and not request.user.is_superuser:
    access_warn(request, 'Insufficient permission')
    raise MessageException("Permission denied.  User %s cannot delete user %s's job." %
                           (request.user.username, job.profile.user))

  job.kill()
  cur_time = time.time()
  while time.time() - cur_time < 15:
    job = Job.from_id(jt=request.jt, jobid=jobid)

    if job.status not in ["RUNNING", "QUEUED"]:
      return render_json({})
    time.sleep(1)
    job = Job.from_id(jt=request.jt, jobid=jobid)

  raise Exception("Job did not appear as killed within 15 seconds")
开发者ID:anutron,项目名称:hue,代码行数:23,代码来源:views.py

示例9: single_job

def single_job(request, jobid):
    """
  We get here from /jobs/jobid
  """
    job = Job.from_id(jt=request.jt, jobid=jobid)

    def cmp_exec_time(task1, task2):
        return cmp(task1.execStartTimeMs, task2.execStartTimeMs)

    failed_tasks = job.filter_tasks(task_states=("failed",))
    failed_tasks.sort(cmp_exec_time)
    recent_tasks = job.filter_tasks(task_states=("running", "succeeded"))
    recent_tasks.sort(cmp_exec_time, reverse=True)

    return render(
        "job.mako",
        request,
        {"request": request, "job": job, "failed_tasks": failed_tasks[:5], "recent_tasks": recent_tasks[:5]},
    )
开发者ID:shreepadma,项目名称:hue,代码行数:19,代码来源:views.py

示例10: single_job

def single_job(request, jobid):
  """
  We get here from /jobs/jobid
  """
  job = Job.from_id(jt=request.jt, jobid=jobid)

  def cmp_exec_time(task1, task2):
    return cmp(task1.execStartTimeMs, task2.execStartTimeMs)

  failed_tasks = job.filter_tasks(task_states=('failed',))
  failed_tasks.sort(cmp_exec_time)
  recent_tasks = job.filter_tasks(task_states=('running', 'succeeded',))
  recent_tasks.sort(cmp_exec_time, reverse=True)

  return render("job.mako", request, {
    'request': request,
    'job': job,
    'failed_tasks': failed_tasks[:5],
    'recent_tasks': recent_tasks[:5]
  })
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:20,代码来源:views.py

示例11: get_job

 def get_job(self, jobid):
   return Job.from_id(jt=self.jt, jobid=jobid)
开发者ID:Andrea1988,项目名称:hue,代码行数:2,代码来源:api.py

示例12: job_counters

def job_counters(request, jobid):
  """
  We get here from /jobs/jobid/counters
  """
  job = Job.from_id(jt=request.jt, jobid=jobid)
  return render("counters.html", request, {"counters":job.counters})
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:6,代码来源:views.py

示例13: get_single_job

def get_single_job(request, jobid):
  """
  Returns the job which matches jobid.
  """
  return Job.from_id(jt=request.jt, jobid=jobid)
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:5,代码来源:views.py


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