From f4349333700403164f068c30e534f68346d37647 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 10 2020 14:45:30 +0000 Subject: [PATCH 1/2] Display params also for malformed tasks in webui Previously web ui failed in displaying tasks with unexpected parameters, display them now in raw variant with warning message. Fixes: https://pagure.io/koji/issue/1484 --- diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index e080ca5..07f911e 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -706,6 +706,10 @@ def taskinfo(environ, taskID): else: values['perms'] = [] + try: + values['params_parsed'] = _genHTML(environ, 'taskinfo_params.chtml') + except: + values['params_parsed'] = None return _genHTML(environ, 'taskinfo.chtml') def taskstatus(environ, taskID): diff --git a/www/kojiweb/taskinfo.chtml b/www/kojiweb/taskinfo.chtml index 56f5761..ca8bf9a 100644 --- a/www/kojiweb/taskinfo.chtml +++ b/www/kojiweb/taskinfo.chtml @@ -1,7 +1,6 @@ #import koji #from kojiweb import util #from six.moves.urllib.parse import quote -#import cgi #import datetime #def printValue($key, $value, $sep=', ') @@ -76,224 +75,12 @@ $value Parameters - #if $task.method == 'buildSRPMFromSCM' - SCM URL: $params[0]
- #if $len($params) > 1 - Build Tag: $buildTag
- #end if - #if $len($params) > 2 - $printOpts($params[2]) - #end if - #elif $task.method == 'buildSRPMFromCVS' - CVS URL: $params[0] - #elif $task.method == 'buildArch' - SRPM: $params[0]
- Build Tag: $buildTag
- Arch: $params[2]
- Keep SRPM? #if $params[3] then 'yes' else 'no'#
- #if $len($params) > 4 - $printOpts($params[4]) - #end if - #elif $task.method == 'tagBuild' - Destination Tag: $destTag.name
- Build: $koji.buildLabel($build) - #elif $task.method == 'buildNotification' - #set $build = $params[1] - #set $buildTarget = $params[2] - Recipients: $printValue('', $params[0])
- Build: $koji.buildLabel($build)
- #if $buildTarget - Build Target: $buildTarget.name
- #else - Build Target: (no build target)
- #end if - Web URL: $params[3] - #elif $task.method == 'tagNotification' - Recipients: $printValue('', $params[0])
- Successful?: #if $params[1] then 'yes' else 'no'#
- #if $destTag - Tagged Into: $destTag.name
- #end if - #if $srcTag - #if $destTag then 'Moved From:' else 'Untagged From:'# $srcTag.name
- #end if - Build: $koji.buildLabel($build)
- #if $destTag then 'Tagged By:' else 'Untagged By:'# $user.name
- Ignore Success?: #if $params[6] then 'yes' else 'no'#
- #if $params[7] - Failure Message: $params[7] - #end if - #elif $task.method == 'build' - Source: $params[0]
- Build Target: $params[1]
- $printOpts($params[2]) - #elif $task.method == 'maven' - SCM URL: $params[0]
- Build Target: $params[1]
- $printOpts($params[2]) - #elif $task.method == 'buildMaven' - SCM URL: $params[0]
- Build Tag: $buildTag.name
- #if $len($params) > 2 - $printOpts($params[2]) - #end if - #elif $task.method == 'wrapperRPM' - Spec File URL: $params[0]
- #if 'locked' in $buildTarget - #set $buildTag = $buildTarget.name - Build Tag: $buildTag
- #else - Build Target: $buildTarget.name
- #end if - #if $params[2] - Build: $koji.buildLabel($params[2])
- #end if - #if $params[3] - Task: $koji.taskLabel($wrapTask)
- #end if - #if $len($params) > 4 - $printOpts($params[4]) - #end if - #elif $task.method == 'chainmaven' - Builds:
- - #for $key, $val in $params[0].items() - - #end for -
$key:$printMap($val)
- Build Target: $params[1]
- #if $len($params) > 2 - $printOpts($params[2]) - #end if - #elif $task.method == 'livecd' or $task.method == 'appliance' or $task.method == 'livemedia' - Name: $params[0]
- Version: $params[1]
- Arch: $params[2]
- Build Target: $params[3]
- Kickstart File: $params[4]
- $printOpts($params[5]) - #elif $task.method == 'image' - Arches: #echo ', '.join($params[2])#
- Build Target: $params[3]
- Installation Tree: $params[4]
- $printOpts($params[5]) - #elif $task.method == 'createLiveCD' or $task.method == 'createAppliance' or $task.method == 'createLiveMedia' - #if $len($params) > 4: - ## new method signature - Arch: $params[3]
- Kickstart File: $params[7]
- #if $len($params) > 8 - $printOpts($params[8]) - #end if - #else - ## old method signature - Arch: $params[0]
- Build Target: $params[1]
- Kickstart File: $params[2]
- #if $len($params) > 3 - $printOpts($params[3]) - #end if - #end if - #elif $task.method == 'createImage' - #set $target = $params[4] - Build Target: $target.name
- Install Tree: $params[7]
- $printOpts($params[8]) - #elif $task.method == 'winbuild' - VM: $params[0]
- SCM URL: $params[1]
- Build Target: $params[2]
- #if $len($params) > 3 - $printOpts($params[3]) - #end if - #elif $task.method == 'vmExec' - VM: $params[0]
- Exec Params:
- #for $info in $params[1] - #if $isinstance($info, dict) - $printMap($info, '    ') - #else -   $info
- #end if - #end for - #if $len($params) > 2 - $printOpts($params[2]) - #end if - #elif $task.method == 'newRepo' - Tag: $tag.name
- #if $len($params) > 1 - $printOpts($params[1]) - #end if - #elif $task.method == 'distRepo' - Tag: $tag.name
- Repo ID: $params[1]
- Keys: $printValue(0, $params[2])
- $printOpts($params[3]) - #elif $task.method == 'prepRepo' - Tag: $params[0].name - #elif $task.method == 'createrepo' - Repo ID: $params[0]
- Arch: $params[1]
- #set $oldrepo = $params[2] - #if $oldrepo - Old Repo ID: $oldrepo.id
- Old Repo Creation: $koji.formatTimeLong($oldrepo.creation_time)
- #end if - #if $len($params) > 4 and $params[4] - External Repos: $printValue(None, [ext['external_repo_name'] for ext in $params[3]])
- #end if - #elif $task.method == 'createdistrepo' - Tag: $tag.name
- Repo ID: $params[1]
- Arch: $printValue(0, $params[2])
- Keys: $printValue(0, $params[3])
- Options: $printMap($params[4], '    ') - #elif $task.method == 'dependantTask' - Dependant Tasks:
- #for $dep in $deps -   $koji.taskLabel($dep)
- #end for - Subtasks:
- #for $subtask in $params[1] -   Method: $subtask[0]
-   Parameters: #echo ', '.join([$str($subparam) for $subparam in $subtask[1]])#
- #if $len($subtask) > 2 and $subtask[2] -   Options:
- $printMap($subtask[2], '    ') - #end if -
- #end for - #elif $task.method == 'chainbuild' - Build Groups:
- #set $groupNum = 0 - #for $urls in $params[0] - #set $groupNum += 1 -   $groupNum: #echo ', '.join($urls)#
- #end for - Build Target: $params[1]
- $printOpts($params[2]) - #elif $task.method == 'waitrepo' - Build Tag: $params[0]
- #if $params[1] - Newer Than: $params[1]
- #end if - #if $params[2] - NVRs: $printValue('', $params[2]) - #end if - #elif $task.method == 'restart' - Host: $params[0].name
- #elif $task.method == 'restartVerify' - Host: $params[1].name
- Restart Task: - $koji.taskLabel($rtask)
- #elif $task.method == 'runroot' - Build Tag: $params[0]
- Arch: $params[1]
- $printOpts($params[3]) - Commands: $params[2]
- #else - $params - #end if + #if $params_parsed + $params_parsed + #else +
Parameters are not correct for this method.
+ $params + #end if diff --git a/www/kojiweb/taskinfo_params.chtml b/www/kojiweb/taskinfo_params.chtml new file mode 100644 index 0000000..67f399b --- /dev/null +++ b/www/kojiweb/taskinfo_params.chtml @@ -0,0 +1,221 @@ +#import koji +#from kojiweb import util + +#if $task.method == 'buildSRPMFromSCM' +SCM URL: $params[0]
+#if $len($params) > 1 +Build Tag:: $buildTag.name
+#end if +#if $len($params) > 2 +$printOpts($params[2]) +#end if +#elif $task.method == 'buildSRPMFromCVS' +CVS URL: $params[0] +#elif $task.method == 'buildArch' +SRPM: $params[0]
+Build Tag: $buildTag.name
+Arch: $params[2]
+Keep SRPM? #if $params[3] then 'yes' else 'no'#
+#if $len($params) > 4 +$printOpts($params[4]) +#end if +#elif $task.method == 'tagBuild' +Destination Tag: $destTag.name
+Build: $koji.buildLabel($build) +#elif $task.method == 'buildNotification' +#set $build = $params[1] +#set $buildTarget = $params[2] +Recipients: $printValue('', $params[0])
+Build: $koji.buildLabel($build)
+#if $buildTarget +Build Target: $buildTarget.name
+#else +Build Target: (no build target)
+#end if +Web URL: $params[3] +#elif $task.method == 'tagNotification' +Recipients: $printValue('', $params[0])
+Successful?: #if $params[1] then 'yes' else 'no'#
+#if $destTag +Tagged Into: $destTag.name
+#end if +#if $srcTag +#if $destTag then 'Moved From:' else 'Untagged From:'# $srcTag.name
+#end if +Build: $koji.buildLabel($build)
+#if $destTag then 'Tagged By:' else 'Untagged By:'# $user.name
+Ignore Success?: #if $params[6] then 'yes' else 'no'#
+#if $params[7] +Failure Message: $params[7] +#end if +#elif $task.method == 'build' +Source: $params[0]
+Build Target: $params[1]
+$printOpts($params[2]) +#elif $task.method == 'maven' +SCM URL: $params[0]
+Build Target: $params[1]
+$printOpts($params[2]) +#elif $task.method == 'buildMaven' +SCM URL: $params[0]
+Build Tag: $buildTag.name
+#if $len($params) > 2 +$printOpts($params[2]) +#end if +#elif $task.method == 'wrapperRPM' +Spec File URL: $params[0]
+#if 'locked' in $buildTarget +#set $buildTag = $buildTarget +Build Tag: $buildTag.name
+#else +Build Target: $buildTarget.name
+#end if +#if $params[2] +Build: $koji.buildLabel($params[2])
+#end if +#if $params[3] +Task: $koji.taskLabel($wrapTask)
+#end if +#if $len($params) > 4 +$printOpts($params[4]) +#end if +#elif $task.method == 'chainmaven' +Builds:
+ +#for $key, $val in $params[0].items() + +#end for +
$key:$printMap($val)
+Build Target: $params[1]
+#if $len($params) > 2 +$printOpts($params[2]) +#end if +#elif $task.method == 'livecd' or $task.method == 'appliance' or $task.method == 'livemedia' +Name: $params[0]
+Version: $params[1]
+Arch: $params[2]
+Build Target: $params[3]
+Kickstart File: $params[4]
+$printOpts($params[5]) +#elif $task.method == 'image' +Arches: #echo ', '.join($params[2])#
+Build Target: $params[3]
+Installation Tree: $params[4]
+$printOpts($params[5]) +#elif $task.method == 'createLiveCD' or $task.method == 'createAppliance' or $task.method == 'createLiveMedia' +#if $len($params) > 4: +## new method signature +Arch: $params[3]
+Kickstart File: $params[7]
+#if $len($params) > 8 +$printOpts($params[8]) +#end if +#else +## old method signature +Arch: $params[0]
+Build Target: $params[1]
+Kickstart File: $params[2]
+#if $len($params) > 3 +$printOpts($params[3]) +#end if +#end if +#elif $task.method == 'createImage' +#set $target = $params[4] +Build Target: $target.name
+Install Tree: $params[7]
+$printOpts($params[8]) +#elif $task.method == 'winbuild' +VM: $params[0]
+SCM URL: $params[1]
+Build Target: $params[2]
+#if $len($params) > 3 +$printOpts($params[3]) +#end if +#elif $task.method == 'vmExec' +VM: $params[0]
+Exec Params:
+#for $info in $params[1] +#if $isinstance($info, dict) +$printMap($info, '    ') +#else +  $info
+#end if +#end for +#if $len($params) > 2 +$printOpts($params[2]) +#end if +#elif $task.method == 'newRepo' +Tag: $tag.name
+#if $len($params) > 1 + $printOpts($params[1]) +#end if +#elif $task.method == 'distRepo' +Tag: $tag.name
+Repo ID: $params[1]
+Keys: $printValue(0, $params[2])
+$printOpts($params[3]) +#elif $task.method == 'prepRepo' +Tag: $params[0].name +#elif $task.method == 'createrepo' +Repo ID: $params[0]
+Arch: $params[1]
+#set $oldrepo = $params[2] +#if $oldrepo + Old Repo ID: $oldrepo.id
+ Old Repo Creation: $koji.formatTimeLong($oldrepo.creation_time)
+#end if +#if $len($params) > 4 and $params[4] + External Repos: $printValue(None, [ext['external_repo_name'] for ext in $params[3]])
+#end if +#elif $task.method == 'createdistrepo' +Tag: $tag.name
+Repo ID: $params[1]
+Arch: $printValue(0, $params[2])
+Keys: $printValue(0, $params[3])
+Options: $printMap($params[4], '    ') +#elif $task.method == 'dependantTask' +Dependant Tasks:
+#for $dep in $deps +  $koji.taskLabel($dep)
+#end for +Subtasks:
+#for $subtask in $params[1] +  Method: $subtask[0]
+  Parameters: #echo ', '.join([$str($subparam) for $subparam in $subtask[1]])#
+#if $len($subtask) > 2 and $subtask[2] +  Options:
+$printMap($subtask[2], '    ') +#end if +
+#end for +#elif $task.method == 'chainbuild' +Build Groups:
+#set $groupNum = 0 +#for $urls in $params[0] +#set $groupNum += 1 +  $groupNum: #echo ', '.join($urls)#
+#end for +Build Target: $params[1]
+$printOpts($params[2]) +#elif $task.method == 'waitrepo' +Build Target: $params[0]
+#if $params[1] +Newer Than: $params[1]
+#end if +#if $params[2] +NVRs: $printValue('', $params[2]) +#end if +#elif $task.method == 'restart' +Host: $params[0].name
+#elif $task.method == 'restartVerify' +Host: $params[1].name
+Restart Task: + $koji.taskLabel($rtask)
+#elif $task.method == 'runroot' +Build Tag: $params[0]
+Arch: $params[1]
+$printOpts($params[3]) +Commands: $params[2]
+#else +$params +#end if From 08baa31a8b2f61d44842e97afc92353287cea034 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 10 2020 14:46:18 +0000 Subject: [PATCH 2/2] fix rebase --- diff --git a/www/kojiweb/taskinfo_params.chtml b/www/kojiweb/taskinfo_params.chtml index 67f399b..b9992eb 100644 --- a/www/kojiweb/taskinfo_params.chtml +++ b/www/kojiweb/taskinfo_params.chtml @@ -4,7 +4,7 @@ #if $task.method == 'buildSRPMFromSCM' SCM URL: $params[0]
#if $len($params) > 1 -Build Tag:: $buildTag.name
+Build Tag: $buildTag
#end if #if $len($params) > 2 $printOpts($params[2]) @@ -13,7 +13,7 @@ $printOpts($params[2]) CVS URL: $params[0] #elif $task.method == 'buildArch' SRPM: $params[0]
-Build Tag: $buildTag.name
+Build Tag: $buildTag
Arch: $params[2]
Keep SRPM? #if $params[3] then 'yes' else 'no'#
#if $len($params) > 4 @@ -65,8 +65,8 @@ $printOpts($params[2]) #elif $task.method == 'wrapperRPM' Spec File URL: $params[0]
#if 'locked' in $buildTarget -#set $buildTag = $buildTarget -Build Tag: $buildTag.name
+#set $buildTag = $buildTarget.name +Build Tag: $buildTag
#else Build Target: $buildTarget.name
#end if @@ -198,7 +198,7 @@ $printMap($subtask[2], '    ') Build Target: $params[1]
$printOpts($params[2]) #elif $task.method == 'waitrepo' -Build Target: $params[0]
+Build Tag: $params[0]
#if $params[1] Newer Than: $params[1]
#end if