Skip to content

Commit 7f42dc0

Browse files
committed
fix: host_credentials can be a list
1 parent 177b5e0 commit 7f42dc0

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/DIRAC/__init__.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@
5454
- getPlatformTuple(): DIRAC platform tuple for current host
5555
5656
"""
57-
import os
5857
import importlib.metadata
58+
import os
5959
import re
6060
import sys
61-
import warnings
61+
from collections.abc import Sequence
6262
from pkgutil import extend_path
6363
from typing import Any, Optional, Union
6464

65-
6665
__path__ = extend_path(__path__, __name__)
6766

6867
# Set the environment variable such that openssl accepts proxy cert
@@ -181,8 +180,7 @@ def initialize(
181180
log_level: Optional[LogLevel] = None,
182181
extra_config_files: Optional[list[os.PathLike]] = None,
183182
extra_config: Optional[dict[str, Any]] = None,
184-
host_credentials: Optional[tuple[os.PathLike, os.PathLike]] = None,
185-
use_server_cert: bool = False,
183+
host_credentials: Optional[Union[Sequence[os.PathLike], bool]] = None,
186184
) -> None:
187185
"""Prepare the global state so that DIRAC clients can be used.
188186
@@ -226,13 +224,11 @@ def initialize(
226224
cfg.loadFromDict(extra_config)
227225
gConfigurationData.mergeWithLocal(cfg)
228226

229-
if use_server_cert:
230-
gConfigurationData.setOptionInCFG("/DIRAC/Security/UseServerCertificate", "yes")
231-
232227
if host_credentials:
233228
gConfigurationData.setOptionInCFG("/DIRAC/Security/UseServerCertificate", "yes")
234-
gConfigurationData.setOptionInCFG("/DIRAC/Security/CertFile", str(host_credentials[0]))
235-
gConfigurationData.setOptionInCFG("/DIRAC/Security/KeyFile", str(host_credentials[1]))
229+
if isinstance(host_credentials, Sequence) and len(host_credentials) == 2:
230+
gConfigurationData.setOptionInCFG("/DIRAC/Security/CertFile", str(host_credentials[0]))
231+
gConfigurationData.setOptionInCFG("/DIRAC/Security/KeyFile", str(host_credentials[1]))
236232

237233
if log_level:
238234
gLogger.setLevel(log_level)

0 commit comments

Comments
 (0)