Skip to content

Commit

Permalink
Client: refactor constructor to improve static type checking; rucio#6588
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio committed Mar 25, 2024
1 parent bed3f05 commit b3227b1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/rucio/client/baseclient.py
Expand Up @@ -93,9 +93,7 @@ def __init__(self, rucio_host=None, auth_host=None, account=None, ca_cert=None,
:param logger: Logger object to use. If None, use the default LOG created by the module
"""

self.host = rucio_host
self.list_hosts = []
self.auth_host = auth_host
self.logger = logger or LOG
self.session = Session()
self.user_agent = "%s/%s" % (user_agent, version.version_string()) # e.g. "rucio-clients/0.2.13"
Expand All @@ -104,9 +102,17 @@ def __init__(self, rucio_host=None, auth_host=None, account=None, ca_cert=None,
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])
Expand Down Expand Up @@ -295,9 +301,12 @@ def _get_exception(self, headers, status_code=None, data=None):
: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'
Expand Down

0 comments on commit b3227b1

Please sign in to comment.