From 3642ad6f2e9f50e71f18c574b94d0618d91e95bc Mon Sep 17 00:00:00 2001 From: rdimaio Date: Mon, 25 Mar 2024 18:31:17 +0100 Subject: [PATCH] Client: refactor constructor to improve static type checking; #6588 --- lib/rucio/client/baseclient.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/rucio/client/baseclient.py b/lib/rucio/client/baseclient.py index f272a4242f..75059f6b0d 100644 --- a/lib/rucio/client/baseclient.py +++ b/lib/rucio/client/baseclient.py @@ -117,9 +117,17 @@ def __init__(self, if self.script_id == '': # Python interpreter used self.script_id = 'python' try: - if self.host is None: + if rucio_host is not None: + self.host = rucio_host + else: self.host = config_get('client', 'rucio_host') - if self.auth_host is None: + except (NoOptionError, NoSectionError) as error: + raise MissingClientParameter('Section client and Option \'%s\' cannot be found in config file' % error.args[0]) + + try: + if auth_host is not None: + self.auth_host = auth_host + else: self.auth_host = config_get('client', 'auth_host') except (NoOptionError, NoSectionError) as error: raise MissingClientParameter('Section client and Option \'%s\' cannot be found in config file' % error.args[0]) @@ -318,9 +326,12 @@ def _get_exception(self, headers: dict[str, str], status_code: Optional[int] = N :return: A rucio exception class and an error string. """ - try: - data = parse_response(data) - except ValueError: + if data is not None: + try: + data = parse_response(data) + except ValueError: + data = {} + else: data = {} exc_cls = 'RucioException'