From cd51a420d79eacaca09c6b9d2cefb7c2bf092487 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Thu, 6 May 2010 14:23:27 +0200 Subject: [PATCH] less verbose results output by default especially factoy results often fill the screen with lots of "blocked" errors. So don't display the details by default unless --verbose is given --- osc/commandline.py | 17 +++++++---------- osc/core.py | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 24992c7b..9e291676 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3207,6 +3207,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='Show results only for specified repo(s)') @cmdln.option('-a', '--arch', action='append', default = [], help='Show results only for specified architecture(s)') + @cmdln.option('-v', '--verbose', action='store_true', default=False, + help='more verbose output') @cmdln.option('', '--xml', action='store_true', default=False, help='generate output in XML (former results_meta)') @cmdln.option('', '--csv', action='store_true', default=False, @@ -3254,19 +3256,14 @@ Please submit there instead, or use --nodevelproject to force direct submission. if opts.xml and opts.csv: raise oscerr.WrongOptions("--xml and --csv are mutual exclusive") + args = [ apiurl, project, package, opts.last_build, opts.repo, opts.arch ] if opts.xml: - func = show_results_meta - delim = '' + return show_results_meta(*args) elif opts.csv: - def _func(*args): - return format_results(get_package_results(*args), opts.format) - func = _func - delim = '\n' + return '\n'.join(format_results(get_package_results(*args), opts.format)) else: - func = get_results - delim = '\n' - - print delim.join(func(apiurl, project, package, opts.last_build, opts.repo, opts.arch)) + args.append(opts.verbose) + return '\n'.join(get_results(*args)) # WARNING: this function is also called by do_results. You need to set a default there # as well when adding a new option! diff --git a/osc/core.py b/osc/core.py index e8eb1d01..f7bc1d0b 100644 --- a/osc/core.py +++ b/osc/core.py @@ -3737,16 +3737,24 @@ def format_results(results, format): """apply selected format on each dict in results and return it as a list of strings""" return [format % r for r in results] -def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]): +def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], verbose=False): r = [] result_line_templ = '%(rep)-20s %(arch)-10s %(status)s' for res in get_package_results(apiurl, prj, package, lastbuild, repository, arch): res['status'] = res['code'] - if res['details'] != '': - res['status'] += ': %s' % (res['details'], ) + if verbose and res['details'] != '': + if res['status'] in ('unresolvable', 'expansion error'): + lines = res['details'].split(',') + res['status'] += ': ' + '\n '.join(lines) + + else: + res['status'] += ': %s' % (res['details'], ) if res['dirty']: - res['status'] = 'state is outdated (was: %s)' % res['status'] + if verbose: + res['status'] = 'state is outdated (was: %s)' % res['status'] + else: + res['status'] += '*' r.append(result_line_templ % res)