(line)
return d
Parse logs from dvbv5-zap and convert to the monitoring format

    The monitoring format is the format accepted by the monitor.py module.
Parse logs from dvbv5-zap and convert to the monitoring format
Parse logs from dvbv5 - zap and convert to the monitoring format
def _parse_log(line):
    """Parse logs from dvbv5-zap and convert to the monitoring format

    The monitoring format is the format accepted by the monitor.py module.

    """
    if (line is None or line == "\n"):
        return

    # Don't process the "Layer A" lines
    if ("Layer" in line):
        return

    # Only process lines containing "Signal"
    if ("Signal" not in line):
        return
    d = {}
    elements = line.split()
    n_elem = len(elements)
    d['lock'] = ("Lock" in line, None)
    for i, elem in enumerate(elements):
        # Each metric is printed as "name=value"
        if (elem[-1] == "=" and (i + 1) <= n_elem):
            key = elem[:-1]
            raw_value = elements[i + 1]

            # Convert key to the nomenclature adopted on monitor.py
            key = log_key_map[key]

            # Fix any scientific notation
            if ("^" in raw_value):
                raw_value = raw_value.replace("x10^", "e")

            # Parse value and unit
            unit = None
            if ("%" in raw_value):
                unit = "%"
                val = float(raw_value[:-1].replace(",", "."))
            elif (raw_value[-2:] == "dB"):
                val = float(raw_value[:-2].replace(",", "."))
                unit = "dB"
            elif (raw_value[-3:] == "dBm"):
                val = float(raw_value[:-3].replace(",", "."))
                unit = "dBm"
            else:
                val = float(raw_value.replace(",", "."))

            d[key] = (val, unit)

    return d
def _parse_log ( line ) : if ( line is None or line == "\n" ) : return # Don't process the "Layer A" lines if ( "Layer" in line ) : return # Only process lines containing "Signal" if ( "Signal" not in line ) : return d = { } elements = line . split ( ) n_elem = len ( elements ) d [ 'lock' ] = ( "Lock" in line , None ) for i , elem in enumerate ( elements ) : # Each metric is printed as "name=value" if ( elem [ - 1 ] == "=" and ( i + 1 ) <= n_elem ) : key = elem [ : - 1 ] raw_value = elements [ i + 1 ] # Convert key to the nomenclature adopted on monitor.py key = log_key_map [ key ] # Fix any scientific notation if ( "^" in raw_value ) : raw_value = raw_value . replace ( "x10^" , "e" ) # Parse value and unit unit = None if ( "%" in raw_value ) : unit = "%" val = float ( raw_value [ : - 1 ] . replace ( "," , "." ) ) elif ( raw_value [ - 2 : ] == "dB" ) : val = float ( raw_value [ : - 2 ] . replace ( "," , "." ) ) unit = "dB" elif ( raw_value [ - 3 : ] == "dBm" ) : val = float ( raw_value [ : - 3 ] . replace ( "," , "." ) ) unit = "dBm" else : val = float ( raw_value . replace ( "," , "." ) ) d [ key ] = ( val , unit ) return d