本文整理汇总了Python中bkr.server.model.Task.license方法的典型用法代码示例。如果您正苦于以下问题:Python Task.license方法的具体用法?Python Task.license怎么用?Python Task.license使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Task
的用法示例。
在下文中一共展示了Task.license方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_task
# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import license [as 别名]
def create_task(name=None, exclude_arches=None, exclusive_arches=None,
exclude_osmajors=None, exclusive_osmajors=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, avg_time=1200):
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(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 = avg_time
task.license = u'GPLv99+'
if type:
for t in type:
task.types.append(TaskType.lazy_create(type=t))
if exclude_arches:
for arch in exclude_arches:
task.excluded_arches.append(Arch.by_name(arch))
if exclusive_arches:
for arch in exclusive_arches:
task.exclusive_arches.append(Arch.by_name(arch))
if exclude_osmajors:
for osmajor in exclude_osmajors:
task.excluded_osmajors.append(OSMajor.lazy_create(osmajor=osmajor))
if exclusive_osmajors:
for osmajor in exclusive_osmajors:
task.exclusive_osmajors.append(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))
session.add(task)
session.flush()
log.debug('Created task %s', task.name)
return task