Пример #1
0
def printHistDetails(hist=False):
    """ """

    #print("printHistDetails: hist:", hist)
    if hist == False:
        if gglobs.hisConn == None:
            gglobs.exgg.showStatusMessage("No data available")
            return

        fprint(header("Show History Binary Data Details"))
        fprint("from: {}\n".format(gglobs.hisDBPath))

        hist = gsql.DB_readBinblob(gglobs.hisConn)
        if hist == None:
            fprint("No binary data found in this database", error=True)
            return

    histlen = len(
        hist)  # Total length; could be any length e.g. when read from file
    histFF = hist.count(b'\xFF')  # total count of FF bytes

    histRC = hist.rstrip(
        b'\xFF')  # after right-clip FF (removal of all trailing 0xff)
    histRClen = len(histRC)  # total byte count
    histRCFF = histRC.count(b'\xFF')  # total count of FF in right-clipped data

    fprint("Binary data total byte count:", "{} Bytes".format(histlen))
    fprint("Count of data bytes:", "{} Bytes".format(histRClen))
    fprint("Count of FF bytes - Total:", "{} Bytes".format(histFF))
    fprint("Count of FF bytes - Trailing:",
           "{} Bytes".format(histlen - histRClen))
    fprint("Count of FF bytes - Within data:", "{} Bytes".format(histRCFF))
Пример #2
0
def GSshowDatData(*args):
    """Show Gamma-Scout type Dat Data from the database table bin"""

    if gglobs.hisConn == None:
        gglobs.exgg.showStatusMessage("No data available")
        return

    fprint(header("Show History Dat Data"))
    hist = gsql.DB_readBinblob(gglobs.hisConn)
    #print("createLstFromDB: hist:", hist)

    if hist == None:
        fprint("No Dat data found in this database", error=True)
        return

    if isinstance(hist, str):
        gglobs.exgg.setBusyCursor()
        fprint(hist)
        gglobs.exgg.setNormalCursor()

    elif isinstance(hist, bytes):
        gglobs.exgg.setBusyCursor()
        fprint(hist.decode("UTF-8"))
        gglobs.exgg.setNormalCursor()

    else:
        fprint("Cannot read the Dat data; possibly not of Gamma-Scout origin")
Пример #3
0
def GSsaveHistDatData():
    """get the Gamma-Scout data from the database and save to *.dat file"""

    if gglobs.hisConn == None:
        gglobs.exgg.showStatusMessage("No data available")
        return

    fncname = "GSsaveHistDatData: "
    fprint(header("Save History Dump Data to File"))
    fprint("from: {}\n".format(gglobs.hisDBPath))

    hist = gsql.DB_readBinblob(gglobs.hisConn)
    if hist == None:
        fprint("No dump data found in this database", error=True)
        return
    vprint(fncname + "hist: type: ", type(hist))

    newpath = gglobs.hisDBPath + ".dat"
    if isinstance(hist, str):
        gglobs.exgg.setBusyCursor()
        #fprint(hist)
        writeBinaryFile(newpath, bytes(hist, 'utf-8'))
        gglobs.exgg.setNormalCursor()

    elif isinstance(hist, bytes):
        gglobs.exgg.setBusyCursor()
        #fprint(hist.decode("UTF-8"))
        writeBinaryFile(newpath, hist)
        gglobs.exgg.setNormalCursor()

    vprint(fncname + "saved as file: " + newpath)
    fprint("saved as file: " + newpath)
Пример #4
0
def xxxAMsaveHistDatData():
    """get the AmbioMon data from the database and save to *.csv file"""
    # is that needed? can be save to csv anyway

    if gglobs.hisConn == None:
        gglobs.exgg.showStatusMessage("No data available")
        return

    fncname = "AMsaveHistDatData: "
    fprint(header("Save History Raw Data to File"))
    fprint("from: {}\n".format(gglobs.hisDBPath))

    hist = gsql.DB_readBinblob(gglobs.hisConn)
    if hist == None:
        fprint("No data found in this database", error=True)
        return
    #vprint(fncname + "hist: type: ", type(hist))

    newpath = gglobs.hisDBPath + ".csv"
    if isinstance(hist, str):
        gglobs.exgg.setBusyCursor()
        #fprint(hist)
        writeBinaryFile(newpath, bytes(hist, 'utf-8'))
        gglobs.exgg.setNormalCursor()

    elif isinstance(hist, bytes):
        gglobs.exgg.setBusyCursor()
        #fprint(hist.decode("UTF-8"))
        writeBinaryFile(newpath, hist)
        gglobs.exgg.setNormalCursor()

    vprint(fncname + "saved as file: " + newpath)
    fprint("saved as file: " + newpath)
Пример #5
0
def xxxAMshowDatData():
    """Show AmbioMon type Raw Data (=CSV, ASCII data) from the database table bin"""

    if gglobs.hisConn == None:
        gglobs.exgg.showStatusMessage("No data available")
        return

    fprint(header("Show History Raw Data"))
    hist = gsql.DB_readBinblob(gglobs.hisConn)
    #print("createLstFromDB: hist:", hist)
    #print("type Hist data: ", type(hist))

    if hist == None:
        fprint("No Dat data found in this database", error=True)
        return

    if isinstance(hist, str):  # data are of type  <class 'str'>
        gglobs.exgg.setBusyCursor()
        fprint(hist)
        gglobs.exgg.setNormalCursor()

    elif isinstance(hist, bytes):  # data are of type <class byte>
        gglobs.exgg.setBusyCursor()

        histsplit = hist.split(b"\n")
        for a in histsplit:
            try:
                fprint(a.decode("UTF-8"))
            except Exception as e:
                fprint(a)
        gglobs.exgg.setNormalCursor()

    else:
        fprint("Cannot read the Dat data; possibly not of AmbioMon origin")
Пример #6
0
def saveHistBinaryData():
    """get the binary data from the database and save to *.bin file"""

    if gglobs.hisConn == None:
        gglobs.exgg.showStatusMessage("No data available")
        return

    fprint(header("Save History Binary Data to File"))
    fprint("from: {}\n".format(gglobs.hisDBPath))

    hist = gsql.DB_readBinblob(gglobs.hisConn)
    if hist == None:
        fprint("No binary data found in this database", error=True)
        return

    newpath = gglobs.hisDBPath + ".bin"
    writeBinaryFile(newpath, hist)

    fprint("saved as file: " + newpath)