Package Ganga :: Package Lib :: Package MonitoringServices :: Package Dashboard :: Module FormatUtil
[hide private]
[frames] | no frames]

Module FormatUtil

source code

Formatting utilities.

These utilities are not Ganga-specific and may be externalized.

N.B. This code is under development and should not generally be used or relied upon.

Functions [hide private]
 
dictToWlcg(msg, include_microseconds=True)
Converts the given dictionary to WLCG message format.
source code
Variables [hide private]
  DETAILS_DATA_KEY = 'detailsData'
  __package__ = None
hash(x)
Function Details [hide private]

dictToWlcg(msg, include_microseconds=True)

source code 

Converts the given dictionary to WLCG message format.

Parameters:
  • msg - A dictionary of key value pairs.
  • include_microseconds - If microseconds should be included in the date format, default True.

    The keys and values are converted to strings using str() with the following exceptions:

    • if key is 'detailsData' and the value is a list or tuple, then its value is converted to a multi-line string using str() for each item and the WLCG-specified line separator.
    • if value is None, then it is converted to an empty string.
    • if value is an instance of datetime.datetime, and it is naive (i.e. it contains no timezone info), then it is assumed to be UTC and converted to the WLCG date format. i.e. YYYY-MM-DDTHH:MM:SS.mmmmmmZ or YYYY-MM-DDTHH:MM:SSZ if include_microseconds is False.

    Apart from detailsData, which is by definition the final entry, the entries are sorted according to natural ordering.

    See also:

    • WLCG message format. https://twiki.cern.ch/twiki/bin/view/LCG/GridMonitoringProbeSpecification#Message_Formats
    • WLCG date format. https://twiki.cern.ch/twiki/bin/view/LCG/GridMonitoringProbeSpecification#Date_Formats