DIRAC return dictionary

Message values are converted to string

keys are converted to string


return value on error condition

Arguments are either Errno and ErrorMessage or just ErrorMessage fro backward compatibility

  • errno (int) – Error number
  • message (string) – Error message

return value on success

Parameters:value – value of the ‘Value’
Returns:dictionary { ‘OK’ : True, ‘Value’ : value }
DIRAC.Core.Utilities.ReturnValues.reprReturnErrorStructure(struct, full=False)

Transform the S_OK{Successful/Failed} dictionary convention into an S_OK/S_ERROR return. To be used when a single returned entity is expected from a generally bulk call.

Parameters:dictRes – S_ERROR or S_OK( “Failed” : {}, “Successful” : {})
Returns:S_ERROR or S_OK(value)

The following rules are applied:

  • if dictRes is an S_ERROR: returns it as is
  • we start by looking at the Failed directory
  • if there are several items in a dictionary, we return the first one
  • if both dictionaries are empty, we return S_ERROR
  • For an item in Failed, we return S_ERROR
  • Far an item in Successful we return S_OK

Behavior examples (would be perfect unit test :-) ):

{'Message': 'Kaput', 'OK': False} -> {'Message': 'Kaput', 'OK': False}
{'OK': True, 'Value': {'Successful': {}, 'Failed': {'a': 1}}} -> {'Message': '1', 'OK': False}
{'OK': True, 'Value': {'Successful': {'b': 2}, 'Failed': {}}} -> {'OK': True, 'Value': 2}
{'OK': True, 'Value': {'Successful': {'b': 2}, 'Failed': {'a': 1}}} -> {'Message': '1', 'OK': False}
{'OK': True, 'Value': {'Successful': {'b': 2}, 'Failed': {'a': 1, 'c': 3}}} -> {'Message': '1', 'OK': False}
{'OK': True, 'Value': {'Successful': {'b': 2, 'd': 4}, 'Failed': {}}} -> {'OK': True, 'Value': 2}
{'OK': True, 'Value': {'Successful': {}, 'Failed': {}}} ->
    {'Message': 'returnSingleResult: Failed and Successful dictionaries are empty', 'OK': False}