示例#1
0
def global_message():
    """Parse the decision tree and return the message
    corresponding to the current threasholds values"""
    # Compute the weight for each item in the tree
    current_thresholds = glances_thresholds.get()
    for i in tree:
        i['weight'] = sum([current_thresholds[t].value() for t in i['thresholds'] if t in current_thresholds])
    themax = max(tree, key=lambda d: d['weight'])
    if themax['weight'] >= themax['thresholds_min']:
        # Check if the weight is > to the minimal threashold value
        return themax['msg']
    else:
        return tree[0]['msg']
示例#2
0
def global_message():
    """Parse the decision tree and return the message.

    Note: message corresponding to the current threasholds values
    """
    # Compute the weight for each item in the tree
    current_thresholds = glances_thresholds.get()
    for i in tree:
        i['weight'] = sum([current_thresholds[t].value() for t in i['thresholds'] if t in current_thresholds])
    themax = max(tree, key=lambda d: d['weight'])
    if themax['weight'] >= themax['thresholds_min']:
        # Check if the weight is > to the minimal threashold value
        return themax['msg']
    else:
        return tree[0]['msg']