From d7dbd1bc0bcee205cb68e0c94e39d61b3a07474a Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Fri, 30 Jul 2021 21:05:05 +0200 Subject: [PATCH] Do not crash when running "osc search --binary --verbose foo" The old code does not support the --binary option in combination with the --verbose option. Specifying --binary and --verbose at the same time results in a crash (because the binary listing contains no ... element). In order to fix this, do not try to access a ... element when --binary and --verbose are both specified. Instead, in this case, include information about the repo, arch, version, and release of the corresponding binary element. Fixes: #933 ("osc se -v -B crash") --- osc/commandline.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 76eb7e5d..4a9c797b 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -7960,10 +7960,16 @@ Please submit there instead, or use --nodevelproject to force direct submission. result.append(s) if opts.verbose: - title = node.findtext('title').strip() - if len(title) > 60: - title = title[:61] + '...' - result.append(title) + if opts.binary: + result.append(node.get('repository') or '-') + result.append(node.get('arch') or '-') + result.append(node.get('version') or '-') + result.append(node.get('release') or '-') + else: + title = node.findtext('title').strip() + if len(title) > 60: + title = title[:61] + '...' + result.append(title) if opts.repos_baseurl: # FIXME: no hardcoded URL of instance @@ -7995,7 +8001,11 @@ Please submit there instead, or use --nodevelproject to force direct submission. headline.append('Rev') headline.append('Srcmd5') if opts.verbose: - headline.append('# Title') + if opts.binary: + headline.extend(['# Repository', '# Arch', '# Version', + '# Release']) + else: + headline.append('# Title') if opts.repos_baseurl: headline.append('# URL') if opts.binary: