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


Python SHARE_JOBS.get方法代码示例

本文整理汇总了Python中jobbrowser.conf.SHARE_JOBS.get方法的典型用法代码示例。如果您正苦于以下问题:Python SHARE_JOBS.get方法的具体用法?Python SHARE_JOBS.get怎么用?Python SHARE_JOBS.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jobbrowser.conf.SHARE_JOBS的用法示例。


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

示例1: filter_jobs

# 需要导入模块: from jobbrowser.conf import SHARE_JOBS [as 别名]
# 或者: from jobbrowser.conf.SHARE_JOBS import get [as 别名]
  def filter_jobs(self, user, jobs, **kwargs):
    check_permission = not SHARE_JOBS.get() and not user.is_superuser

    return filter(lambda job:
                  not check_permission or
                  user.is_superuser or
                  job.user == user.username, jobs)
开发者ID:Andrea1988,项目名称:hue,代码行数:9,代码来源:api.py

示例2: filter_jobs

# 需要导入模块: from jobbrowser.conf import SHARE_JOBS [as 别名]
# 或者: from jobbrowser.conf.SHARE_JOBS import get [as 别名]
  def filter_jobs(self, user, jobs, **kwargs):
    check_permission = not SHARE_JOBS.get() and not is_admin(user)

    return filter(lambda job:
                  not check_permission or
                  is_admin(user) or
                  job.user == user.username, jobs)
开发者ID:cloudera,项目名称:hue,代码行数:9,代码来源:api.py

示例3: get_api

# 需要导入模块: from jobbrowser.conf import SHARE_JOBS [as 别名]
# 或者: from jobbrowser.conf.SHARE_JOBS import get [as 别名]
    jobid = kwargs['job']
    try:
      job = get_api(request.user, request.jt).get_job(jobid=jobid)
    except ApplicationNotRunning, e:
      if e.job.get('state', '').lower() == 'accepted' and 'kill' in request.path:
        rm_api = resource_manager_api.get_resource_manager(request.user)
        job = Application(e.job, rm_api)
      else:
        # reverse() seems broken, using request.path but beware, it discards GET and POST info
        return job_not_assigned(request, jobid, request.path)
    except JobExpired, e:
      raise PopupException(_('Job %s has expired.') % jobid, detail=_('Cannot be found on the History Server.'))
    except Exception, e:
      raise PopupException(_('Could not find job %s.') % jobid, detail=e)

    if not SHARE_JOBS.get() and not request.user.is_superuser \
        and job.user != request.user.username and not can_view_job(request.user.username, job):
      raise PopupException(_("You don't have permission to access job %(id)s.") % {'id': jobid})
    kwargs['job'] = job
    return view_func(request, *args, **kwargs)
  return wraps(view_func)(decorate)


def job_not_assigned(request, jobid, path):
  if request.GET.get('format') == 'json':
    result = {'status': -1, 'message': ''}

    try:
      get_api(request.user, request.jt).get_job(jobid=jobid)
      result['status'] = 0
    except ApplicationNotRunning, e:
开发者ID:ronwxy,项目名称:hue,代码行数:33,代码来源:views.py

示例4: Application

# 需要导入模块: from jobbrowser.conf import SHARE_JOBS [as 别名]
# 或者: from jobbrowser.conf.SHARE_JOBS import get [as 别名]
        except ApplicationNotRunning, e:
            if e.job.get("state", "").lower() == "accepted" and "kill" in request.path:
                rm_api = resource_manager_api.get_resource_manager(request.user)
                job = Application(e.job, rm_api)
            else:
                # reverse() seems broken, using request.path but beware, it discards GET and POST info
                return job_not_assigned(request, jobid, request.path)
        except JobExpired, e:
            raise PopupException(_("Job %s has expired.") % jobid, detail=_("Cannot be found on the History Server."))
        except Exception, e:
            msg = "Could not find job %s."
            LOGGER.exception(msg % jobid)
            raise PopupException(_(msg) % jobid, detail=e)

        if (
            not SHARE_JOBS.get()
            and not request.user.is_superuser
            and job.user != request.user.username
            and not can_view_job(request.user.username, job)
        ):
            raise PopupException(_("You don't have permission to access job %(id)s.") % {"id": jobid})
        kwargs["job"] = job
        return view_func(request, *args, **kwargs)

    return wraps(view_func)(decorate)


def job_not_assigned(request, jobid, path):
    if request.GET.get("format") == "json":
        result = {"status": -1, "message": ""}
开发者ID:cquptEthan,项目名称:hue,代码行数:32,代码来源:views.py


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