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


Python Job.delete_jobs方法代码示例

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


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

示例1: delete_jobs

# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import delete_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])
开发者ID:ustbgaofan,项目名称:beaker,代码行数:45,代码来源:jobs.py

示例2: _delete_job

# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import delete_jobs [as 别名]
 def _delete_job(self, t_id):
     job = TaskBase.get_by_t_id(t_id)
     self._check_job_deletability(t_id, job)
     Job.delete_jobs([job])
     return [t_id]
开发者ID:ustbgaofan,项目名称:beaker,代码行数:7,代码来源:jobs.py


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