refactor
This commit is contained in:
parent
3b82594a32
commit
d1ab4ed287
3 changed files with 69 additions and 44 deletions
|
|
@ -15,7 +15,7 @@ allowed_methods = None
|
|||
|
||||
|
||||
@export
|
||||
def saveFailedTree(taskID, full=False, **opts):
|
||||
def saveFailedTree(buildrootID, full=False, **opts):
|
||||
"""Create saveFailedTree task
|
||||
|
||||
If arguments are invalid, error message is returned. Otherwise task id of
|
||||
|
|
@ -23,7 +23,7 @@ def saveFailedTree(taskID, full=False, **opts):
|
|||
global config, allowed_methods
|
||||
|
||||
# let it raise errors
|
||||
taskID = int(taskID)
|
||||
buildrootID = int(buildrootID)
|
||||
full = bool(full)
|
||||
|
||||
# read configuration only once
|
||||
|
|
@ -34,6 +34,8 @@ def saveFailedTree(taskID, full=False, **opts):
|
|||
if len(allowed_methods) == 1 and allowed_methods[0] == '*':
|
||||
allowed_methods = '*'
|
||||
|
||||
brinfo = kojihub.get_buildroot(buildrootID, strict=True)
|
||||
taskID = brinfo['task_id']
|
||||
task_info = kojihub.Task(taskID).getInfo()
|
||||
if task_info['state'] != koji.TASK_STATES['FAILED']:
|
||||
raise koji.PreBuildError("Task %s has not failed. Only failed tasks can upload their buildroots." % taskID)
|
||||
|
|
@ -45,8 +47,8 @@ def saveFailedTree(taskID, full=False, **opts):
|
|||
elif not kojihub.get_host(task_info['host_id'])['enabled']:
|
||||
raise koji.PreBuildError("Host is disabled.")
|
||||
|
||||
args = koji.encode_args(taskID, full, **opts)
|
||||
args = koji.encode_args(buildrootID, full, **opts)
|
||||
taskopts = {
|
||||
'assign': task_info['host_id'],
|
||||
'assign': brinfo['host_id'],
|
||||
}
|
||||
return kojihub.make_task('saveFailedTree', args, **taskopts)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue