Skip to content

Commit

Permalink
fix (diracx): clearer error message
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Nov 28, 2023
1 parent af7ab51 commit 36dcd20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/DIRAC/Core/Security/DiracX.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 6 additions & 3 deletions src/DIRAC/FrameworkSystem/scripts/dirac_diracx_whoami.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down

0 comments on commit 36dcd20

Please sign in to comment.