本文整理汇总了Python中bkr.server.model.Task.lazy_create方法的典型用法代码示例。如果您正苦于以下问题:Python Task.lazy_create方法的具体用法?Python Task.lazy_create怎么用?Python Task.lazy_create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Task
的用法示例。
在下文中一共展示了Task.lazy_create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_task
# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import lazy_create [as 别名]
def create_task(name=None, exclude_arch=None, exclude_osmajor=None, version=u'1.0-1',
uploader=None, owner=None, priority=u'Manual', valid=None, path=None,
description=None, requires=None, runfor=None, type=None):
if name is None:
name = unique_name(u'/distribution/test_task_%s')
if path is None:
path = u'/mnt/tests/%s' % name
if description is None:
description = unique_name(u'description%s')
if uploader is None:
uploader = create_user(user_name=u'task-uploader%s' % name.replace('/', '-'))
if owner is None:
owner = u'task-owner%[email protected]' % name.replace('/', '-')
if valid is None:
valid = True
rpm = u'example%s-%s.noarch.rpm' % (name.replace('/', '-'), version)
task = Task.lazy_create(name=name)
task.rpm = rpm
task.version = version
task.uploader = uploader
task.owner = owner
task.priority = priority
task.valid = valid
task.path = path
task.description = description
task.avg_time = 1200
if type:
for t in type:
task.types.append(TaskType.lazy_create(type=t))
if exclude_arch:
for arch in exclude_arch:
task.excluded_arch.append(TaskExcludeArch(arch_id=Arch.by_name(arch).id))
if exclude_osmajor:
for osmajor in exclude_osmajor:
task.excluded_osmajor.append(TaskExcludeOSMajor(osmajor=OSMajor.lazy_create(osmajor=osmajor)))
if requires:
for require in requires:
tp = TaskPackage.lazy_create(package=require)
task.required.append(tp)
if runfor:
for run in runfor:
task.runfor.append(TaskPackage.lazy_create(package=run))
return task