diff --git a/src/DIRAC/Core/Security/DiracX.py b/src/DIRAC/Core/Security/DiracX.py index d5f8214436d..3d0f726d08e 100644 --- a/src/DIRAC/Core/Security/DiracX.py +++ b/src/DIRAC/Core/Security/DiracX.py @@ -74,6 +74,8 @@ def DiracXClient() -> _DiracClient: proxyLocation = getDefaultProxyLocation() diracxToken = diracxTokenFromPEM(proxyLocation) + if not diracxToken: + raise ValueError(f"No dirax token in the proxy file {proxyLocation}") with NamedTemporaryFile(mode="wt") as token_file: token_file.write(json.dumps(diracxToken)) diff --git a/src/DIRAC/FrameworkSystem/scripts/dirac_diracx_whoami.py b/src/DIRAC/FrameworkSystem/scripts/dirac_diracx_whoami.py index 7f425a879ea..c24c4e6dc8c 100644 --- a/src/DIRAC/FrameworkSystem/scripts/dirac_diracx_whoami.py +++ b/src/DIRAC/FrameworkSystem/scripts/dirac_diracx_whoami.py @@ -13,9 +13,12 @@ def main(): Script.parseCommandLine() - with DiracXClient() as api: - user_info = api.auth.userinfo() - print(json.dumps(user_info.as_dict(), indent=2)) + try: + with DiracXClient() as api: + user_info = api.auth.userinfo() + print(json.dumps(user_info.as_dict(), indent=2)) + except Exception as e: + print(f"Failed to access DiracX: {e}") if __name__ == "__main__":