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

Merge pull request #1184 from dirkmueller/cleanups

Cleanups
This commit is contained in:
Daniel Mach 2022-12-05 09:30:48 +01:00 committed by GitHub
commit 0c2238435f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 19 deletions

View File

@ -77,7 +77,7 @@ class Buildinfo:
localpkgs = localpkgs or []
try:
tree = ET.parse(filename)
except:
except ET.ParseError:
print('could not parse the buildinfo:', file=sys.stderr)
print(open(filename).read(), file=sys.stderr)
sys.exit(1)
@ -801,7 +801,7 @@ def main(apiurl, opts, argv):
try:
build_root = build_root % {'repo': repo, 'arch': arch,
'project': prj, 'package': pacname, 'apihost': apihost}
except:
except KeyError:
pass
# We configure sccache after pacname, so that in default cases we can have an sccache for each

View File

@ -186,28 +186,29 @@ if not os.path.isfile('/usr/bin/build') and os.path.isfile('/usr/bin/obs-build')
if not os.path.isfile('/usr/lib/build/vc') and os.path.isfile('/usr/lib/obs-build/vc'):
DEFAULTS['vc-cmd'] = '/usr/lib/obs-build/vc'
boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist',
'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive',
'request_show_source_buildstatus', 'review_inherit_group', 'use_keyring', 'no_verify', 'builtin_signature_check',
'http_full_debug', 'include_request_from_project', 'local_service_run', 'buildlog_strip_time', 'no_preinstallimage',
'status_mtime_heuristic', 'print_web_links', 'ccache', 'sccache', 'build-shell-after-fail']
integer_opts = ['build-jobs']
api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'realname', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj',
'downloadurl', 'sshkey']
_integer_opts = ('build-jobs',)
_boolean_opts = (
'debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist',
'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive',
'request_show_source_buildstatus', 'review_inherit_group', 'use_keyring', 'no_verify', 'builtin_signature_check',
'http_full_debug', 'include_request_from_project', 'local_service_run', 'buildlog_strip_time', 'no_preinstallimage',
'status_mtime_heuristic', 'print_web_links', 'ccache', 'sccache', 'build-shell-after-fail')
def apply_option_types(config, conffile=""):
"""
Return a copy of `config` dictionary with values converted to their expected types
according to the enumerated option types (boolean_opts, integer_opts).
according to the enumerated option types (_boolean_opts, _integer_opts).
"""
config = config.copy()
cp = OscConfigParser.OscConfigParser(config)
cp.add_section("general")
typed_opts = ((boolean_opts, cp.getboolean), (integer_opts, cp.getint))
typed_opts = ((_boolean_opts, cp.getboolean), (_integer_opts, cp.getint))
for opts, meth in typed_opts:
for opt in opts:
try:

View File

@ -14,29 +14,25 @@ class TestConf(unittest.TestCase):
importlib.reload(osc.conf)
def test_bool_opts_defaults(self):
opts = osc.conf.boolean_opts
config = osc.conf.config
for opt in opts:
for opt in osc.conf._boolean_opts:
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
def test_int_opts_defaults(self):
opts = osc.conf.integer_opts
config = osc.conf.config
for opt in opts:
for opt in osc.conf._integer_opts:
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
def test_bool_opts(self):
osc.conf.get_config()
opts = osc.conf.boolean_opts
config = osc.conf.config
for opt in opts:
for opt in osc.conf._boolean_opts:
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
def test_int_opts(self):
osc.conf.get_config()
opts = osc.conf.integer_opts
config = osc.conf.config
for opt in opts:
for opt in osc.conf._integer_opts:
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")