def GetConfiguration()

in get-historical-metrics.py [0:0]


def GetConfiguration():
    global LastRun,ConfigTimeout,DDBTableName,Logger,Table,DataSources,UnitMapping
    
    #
    # We only want to retrieve the configuration for the wallboard if we haven't
    # retrieved it recently or it hasn't previously been loaded.
    #
    Logger.debug("Last run at "+str(LastRun)+", timeout is "+str(ConfigTimeout)+", now is "+str(time.time()))
    
    if time.time() < LastRun+ConfigTimeout:
        Logger.debug("  Within timeout period - no config refresh")
        return
    LastRun = time.time()

    #
    # All relevant wallboard information (how it is to be formatted, threshold
    # details, etc.) all have a primary partition key of the name of the
    # wallboard.
    #
    Expression = Attr("RecordType").begins_with("DataSource")
    try:
        Response = Table.scan(FilterExpression=Expression)
    except ClientError as e:
        Logger.error("DynamoDB error: "+e.response["Error"]["Message"])
        return(False)

    if len(Response["Items"]) == 0:
        Logger.error("Did not get any data sources")
        return

    DataSources = {}
    for Item in Response["Items"]:
        if "Name" not in Item:
            Logger.warning("Data source reference not set for "+Item["RecordType"]+" - ignored")
            continue
        
        Metric = Item["Reference"].split(":")[2]
        if Metric not in MetricUnitMapping: continue # Ignore non-historical metrics
        DataSources[Item["Name"]] = Item["Reference"]

    return