1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

Add --watch for osc prjresults --xml

Like: osc results --watch
This commit is contained in:
Jan Zerebecki 2018-11-05 22:57:14 +01:00
parent a5e967efb3
commit 5e03ffcec9
No known key found for this signature in database
GPG Key ID: 94D2D0D2432ED7CC
3 changed files with 26 additions and 3 deletions

View File

@ -5152,7 +5152,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='Disable results for all direct affect packages inside of the project')
@cmdln.option('-M', '--multibuild-package', action='append', default=[],
help='Only show results for the specified multibuild package')
@cmdln.option('-w', '--watch', action='store_true', default=False,
@cmdln.option('-w', '--watch', action='store_true',
help='watch the results until all finished building')
@cmdln.option('', '--xml', action='store_true', default=False,
help='generate output in XML (former results_meta)')
@ -5235,6 +5235,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# as well when adding a new option!
@cmdln.option('-q', '--hide-legend', action='store_true',
help='hide the legend')
@cmdln.option('-w', '--watch', action='store_true',
help='watch the results until all finished building, only supported with --xml')
@cmdln.option('-c', '--csv', action='store_true',
help='csv output')
@cmdln.option('', '--xml', action='store_true', default=False,
@ -5273,9 +5275,20 @@ Please submit there instead, or use --nodevelproject to force direct submission.
project = store_read_project(wd)
if opts.xml:
print(''.join(show_prj_results_meta(apiurl, project, opts.repo, opts.arch)))
kwargs = {}
if opts.repo:
kwargs['repository'] = opts.repo
if opts.arch:
kwargs['arch'] = opts.arch
kwargs['wait'] = opts.watch
for results in get_package_results(apiurl, project, **kwargs):
print(results)
return
if opts.watch:
print('Please implement support for osc prjresults --watch without --xml.')
return 2
print('\n'.join(get_prj_results(apiurl, project, hide_legend=opts.hide_legend, \
csv=opts.csv, status_filter=opts.status_filter, \
name_filter=opts.name_filter, repo=opts.repo, \

View File

@ -5735,7 +5735,7 @@ def get_results(apiurl, project, package, verbose=False, printJoin='', *args, **
return r
def get_package_results(apiurl, project, package, wait=False, *args, **kwargs):
def get_package_results(apiurl, project, package=None, wait=False, *args, **kwargs):
"""generator that returns a the package results as an xml structure"""
xml = ''
waiting_states = ('blocked', 'scheduled', 'dispatching', 'building',

View File

@ -33,6 +33,12 @@ class TestResults(OscTestCase):
out = self._run_osc('prjresults', '--xml', 'testproject')
self.assertEqualMultiline(out, self._get_fixture('result.xml')+'\n')
@GET('http://localhost/build/testproject/_result', file='result-dirty.xml')
@GET('http://localhost/build/testproject/_result?oldstate=c57e2ee592dbbf26ebf19cc4f1bc1e83', file='result.xml')
def testPrjresultsWatch(self):
out = self._run_osc('prjresults', '--watch', '--xml', 'testproject')
self.assertEqualMultiline(out, self._get_fixture('result-dirty.xml')+'\n'+self._get_fixture('result.xml')+'\n')
@GET('http://localhost/build/testproject/_result?package=python-MarkupSafe&multibuild=1&locallink=1', file='result.xml')
def testResults(self):
out = self._run_osc('results', '--xml', 'testproject', 'python-MarkupSafe')
@ -44,3 +50,7 @@ class TestResults(OscTestCase):
out = self._run_osc('results', '--watch', '--xml', 'testproject', 'python-MarkupSafe')
self.assertEqualMultiline(out, self._get_fixture('result-dirty.xml')+self._get_fixture('result.xml'))
if __name__ == '__main__':
import unittest
unittest.main()