1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-25 17:36:13 +01:00

Remove duplicated --debug and --verbose options

Additional changes:
* rename getbinaries --debug to --debuginfo to avoid conflicts
* switch conf['verbose'] from int to bool

The changes were needed because the new argparser behaves differently
and commands such as `osc ls` ran in verbose mode by default.
This commit is contained in:
Daniel Mach 2022-08-04 10:09:10 +02:00
parent 84c97ab625
commit 6cb7412749
3 changed files with 20 additions and 45 deletions

View File

@ -95,9 +95,10 @@ class Osc(cmdln.Cmdln):
help='disable usage of desktop keyring system')
optparser.add_argument('--no-gnome-keyring', action='store_true',
help='disable usage of GNOME Keyring')
optparser.add_argument('-v', '--verbose', dest='verbose', action='count', default=0,
verbose_group = optparser.add_mutually_exclusive_group()
verbose_group.add_argument('-v', '--verbose', action='store_true',
help='increase verbosity')
optparser.add_argument('-q', '--quiet', dest='verbose', action='store_const', const=-1,
verbose_group.add_argument('-q', '--quiet', action='store_true',
help='be quiet, not verbose')
def post_argparse(self):
@ -225,9 +226,7 @@ class Osc(cmdln.Cmdln):
help='expand linked package (only for sources)')
@cmdln.option('-u', '--unexpand', action='store_true',
help='always work with unexpanded (source) packages')
@cmdln.option('-v', '--verbose', action='store_true',
help='print extra information')
@cmdln.option('-l', '--long', action='store_true', dest='verbose',
@cmdln.option('-l', '--long', dest='verbose', action='store_true',
help='print extra information')
@cmdln.option('-D', '--deleted', action='store_true',
help='show only the former deleted projects or packages')
@ -383,9 +382,6 @@ class Osc(cmdln.Cmdln):
print(prj)
elif len(args) == 1:
if opts.verbose:
if self.options.verbose:
print('Sorry, the --verbose option is not implemented for projects.', file=sys.stderr)
for pkg in meta_get_packagelist(apiurl, project, deleted = opts.deleted, expand = opts.expand):
print(pkg)
@ -4662,10 +4658,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
self.argparse_error("Incorrect number of arguments.")
@cmdln.option('-q', '--quiet', action='store_true',
help='print as little as possible')
@cmdln.option('-v', '--verbose', action='store_true',
help='print extra information')
@cmdln.option('-e', '--show-excluded', action='store_true',
help='also show files which are excluded by the ' \
'"exclude_glob" config option')
@ -4699,9 +4691,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc status [OPTS] [PATH...]
"""
if opts.quiet and opts.verbose:
raise oscerr.WrongOptions('\'--quiet\' and \'--verbose\' are mutually exclusive')
args = parseargs(args)
lines = []
excl_states = (' ',)
@ -4855,8 +4844,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='force commit, even if there were no changes')
@cmdln.option('--skip-validation', default=False, action="store_true",
help='deprecated, don\'t use it')
@cmdln.option('-v', '--verbose', default=False, action="store_true",
help='Run the source services with verbose information')
@cmdln.option('--skip-local-service-run', '--noservice', default=False, action="store_true",
help='Skip service run of configured source services for local run')
def do_commit(self, subcmd, opts, *args):
@ -5356,8 +5343,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='Show results only for specified architecture(s)')
@cmdln.option('-b', '--brief', action='store_true',
help='show the result in "pkgname repo arch result". Default for -f')
@cmdln.option('-v', '--verbose', action='store_true', default=False,
help='more verbose output')
@cmdln.option('--no-multibuild', action='store_true', default=False,
help='Disable results for all direct affect packages inside of the project')
@cmdln.option('-M', '--multibuild-package', metavar='FLAVOR', action='append', default=[],
@ -5967,8 +5952,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print(" ", dep.text)
@cmdln.option('-d', '--debug', action='store_true',
help='verbose output of build dependencies')
@cmdln.option('--alternative-project', metavar='PROJECT',
help='specify the build target project')
@cmdln.option('-M', '--multibuild-package', metavar='FLAVOR',
@ -6502,8 +6485,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='only fetch packages from the api')
@cmdln.option('--oldpackages', metavar='DIR',
help='take previous build from DIR (special values: _self, _link)')
@cmdln.option('--verbose', metavar='VERBOSE',
help='set a verbose mode, arguments can be "all" or "vm"')
@cmdln.option('--wipe', action='store_true',
help=SUPPRESS_HELP)
@cmdln.option('--shell', action='store_true',
@ -7381,8 +7362,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print(wipebinaries(apiurl, project, package, opts.arch, opts.repo, code))
@cmdln.option('-q', '--quiet', action='store_true',
help='do not show downloading progress')
@cmdln.option('-d', '--destdir', default='./binaries', metavar='DIR',
help='destination directory')
@cmdln.option('-M', '--multibuild-package', metavar="FLAVOR", action='append',
@ -7390,7 +7369,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
' It is meant for use from a package checkout when it is not possible to specify package:flavor.')
@cmdln.option('--sources', action="store_true",
help='also fetch source packages')
@cmdln.option('--debug', action="store_true",
@cmdln.option('--debuginfo', action="store_true",
help='also fetch debug packages')
@cmdln.option('--ccache', action="store_true",
help='allow fetching ccache archive')
@ -7491,7 +7470,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if not opts.sources and (i.name.endswith('.src.rpm') or i.name.endswith('.sdeb')):
continue
# skip debuginfo rpms
if not opts.debug and ('-debuginfo-' in i.name or '-debugsource-' in i.name):
if not opts.debuginfo and ('-debuginfo-' in i.name or '-debugsource-' in i.name):
continue
if package_specified:
@ -7529,8 +7508,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='search for USER instead of yourself')
@cmdln.option('--exclude-project', action='append',
help='exclude requests for specified project')
@cmdln.option('-v', '--verbose', action='store_true',
help='verbose listing')
@cmdln.option('--maintained', action='store_true',
help='limit search results to packages with maintained attribute set.')
def do_my(self, subcmd, opts, *args):
@ -7765,8 +7742,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='search for matches in the \'description\' element')
@cmdln.option('-a', '--limit-to-attribute', metavar='ATTRIBUTE',
help='match only when given attribute exists in meta data')
@cmdln.option('-v', '--verbose', action='store_true',
help='show more information')
@cmdln.option('-V', '--version', action='store_true',
help='show package version, revision, and srcmd5. CAUTION: This is slow and unreliable')
@cmdln.option('-i', '--involved', action='store_true',
@ -8226,8 +8201,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.option('--nodevelproject', action='store_true',
help='do not follow a defined devel project ' \
'(primary project where a package is developed)')
@cmdln.option('-v', '--verbose', action='store_true',
help='show more information')
@cmdln.option('-D', '--devel-project', metavar='devel_project',
help='define the project where this package is primarily developed')
@cmdln.option('-a', '--add', metavar='user',

View File

@ -128,7 +128,7 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org',
'http_debug': '0',
'http_full_debug': '0',
'http_retries': '3',
'verbose': '1',
'verbose': '0',
'no_preinstallimage': '0',
'traceback': '0',
'post_mortem': '0',
@ -870,13 +870,15 @@ def get_config(override_conffile=None,
if config['plaintext_passwd']:
print('The \'plaintext_passwd\' option is deprecated and will be ignored', file=sys.stderr)
config['verbose'] = int(config['verbose'])
config['verbose'] = bool(int(config['verbose']))
# override values which we were called with
if override_verbose:
config['verbose'] = override_verbose + 1
if override_verbose is not None:
config['verbose'] = bool(override_verbose)
config['debug'] = bool(int(config['debug']))
if override_debug is not None:
config['debug'] = bool(override_debug)
if override_debug:
config['debug'] = override_debug
if override_http_debug:
config['http_debug'] = override_http_debug
if override_http_full_debug:

View File

@ -452,7 +452,7 @@ class Serviceinfo:
raise oscerr.PackageNotInstalled("obs-service-%s" % cmd[0])
cmd[0] = "/usr/lib/obs/service/"+cmd[0]
cmd = cmd + [ "--outdir", temp_dir ]
if conf.config['verbose'] > 1 or verbose or conf.config['debug']:
if conf.config['verbose'] or verbose or conf.config['debug']:
print("Run source service:", ' '.join(cmd))
r = run_external(*cmd)
@ -3334,7 +3334,7 @@ def makeurl(baseurl, l, query=[]):
function. In case of a list not -- this is to be backwards compatible.
"""
if conf.config['verbose'] > 1:
if conf.config['verbose']:
print('makeurl:', baseurl, l, query)
if isinstance(query, type(list())):
@ -4368,7 +4368,7 @@ def get_review_list(apiurl, project='', package='', byuser='', bygroup='', bypro
xpath_base = xpath_join(xpath_base, 'action/source/@%(kind)s=\'%(val)s\'', op='or', inner=True)
xpath = xpath_join(xpath, xpath_base % {'kind': kind, 'val': val}, op='and', nexpr_parentheses=True)
if conf.config['verbose'] > 1:
if conf.config['verbose']:
print('[ %s ]' % xpath)
res = search(apiurl, request=xpath)
collection = res['request']
@ -4420,7 +4420,7 @@ def get_exact_request_list(apiurl, src_project, dst_project, src_package=None, d
if req_type:
xpath += " and action/@type=\'%s\'" % req_type
if conf.config['verbose'] > 1:
if conf.config['verbose']:
print('[ %s ]' % xpath)
res = search(apiurl, request=xpath)
@ -4459,7 +4459,7 @@ def get_request_list(apiurl, project='', package='', req_who='', req_state=('new
for i in exclude_target_projects:
xpath = xpath_join(xpath, '(not(action/target/@project=\'%(prj)s\'))' % {'prj': i}, op='and')
if conf.config['verbose'] > 1:
if conf.config['verbose']:
print('[ %s ]' % xpath)
queries = {}
if withfullhistory:
@ -5012,7 +5012,7 @@ def checkout_package(apiurl, project, package,
root_dots = '.'
if conf.config['checkout_rooted']:
if prj_dir[:1] == '/':
if conf.config['verbose'] > 1:
if conf.config['verbose']:
print("checkout_rooted ignored for %s" % prj_dir)
# ?? should we complain if not is_project_dir(prj_dir) ??
else: