示例#1
0
def piholeStatus():
    device = oled.getDevice()
    with canvas(device, dither=None) as draw:
        queries = pihole.getQueries()
        blocked = pihole.getBlocked()
        percentage = pihole.getPercentage()

        if pihole.getStatus():
            ph_status = "(Running)"
        else:
            ph_status = "(Stopped)"
        if ((queries == -1) or (blocked == -1) or (percentage == -1)):
            oled.oPrint(oled.center("PiHole") + "\n\n" + oled.center("Fehler"))
        else:
            fnt = oled.getFont()
            draw.text((0, 0),
                      font=fnt,
                      text=oled.center("PiHole " + ph_status))

            draw.text((0, 20), font=fnt, text=oled.concat("Queries:", queries))
            draw.text((0, 30),
                      font=fnt,
                      text=oled.concat("Blocking:", blocked))
            draw.text((0, 40),
                      font=fnt,
                      text=oled.concat("Percent:",
                                       str(percentage) + "%"))

            pct_bar = 127 * (percentage / 100)
            draw.rectangle((pct_bar, 63, 0, 50), fill="white")
            draw.rectangle((127, 63, 0, 50), outline="grey")

    time.sleep(INTERVALL)
示例#2
0
def piholeStatus():
    if (DEBUG):
        print('piHole Status')

    device = oled.getDevice()

    try:
        piholeip = cfg['pihole']['ip']
    except Exception as e:
        oled.scPrint(oled.center('Error [PiHole]'), '',
                     oled.center('Could not'), oled.center('find config!'))
        time.sleep(INTERVALL)
        return

    for i in range(0, INTERVALL):  #refresh every second for INTERVALL times
        with canvas(device, dither=None) as draw:
            queries = pihole.getQueries(piholeip)
            blocked = pihole.getBlocked(piholeip)
            percentage = pihole.getPercentage(piholeip)

            if pihole.getStatus(piholeip):
                ph_status = "(Active)"
            else:
                ph_status = "(STOPPED)"
            if ((queries == -1) or (blocked == -1) or (percentage == -1)):
                oled.oPrint(
                    oled.center("PiHole") + "\n\n" + oled.center("Fehler"))
            else:
                fnt = oled.getFont()
                draw.text((0, 0),
                          font=fnt,
                          text=oled.center("PiHole " + ph_status))

                draw.text((0, 20),
                          font=fnt,
                          text=oled.concat("Queries:", queries))
                draw.text((0, 30),
                          font=fnt,
                          text=oled.concat("Blocking:", blocked))
                draw.text((0, 40),
                          font=fnt,
                          text=oled.concat("Percentage:",
                                           str(percentage) + "%"))

                pct_bar = 127 * (percentage / 100)
                draw.rectangle((pct_bar, 63, 0, 50), fill="white")
                draw.rectangle((127, 63, 0, 50), outline="grey")

        time.sleep(1)
示例#3
0
def pistatus():
    temp = os.popen('vcgencmd measure_temp').read()
    tempprint = temp[(temp.rfind("=") + 1):]
    tempprint = tempprint[:4]

    try:
        ip = url.urlopen('http://api.ipify.org').read()
    except:
        ip = "Offline"

    temp = os.popen('vcgencmd measure_volts').read()
    voltprint = temp[(temp.rfind("=") + 1):]
    voltprint = voltprint[:7]
    oled.oPrint(
        oled.center("Pi Status") + "\n\n" +
        oled.concat("CPU-Temp: ", str(tempprint + degreeSymbol)) + "\n" +
        oled.concat("CPU-Volt: ", str(voltprint)) + "\n" +
        oled.concat("IP: ", str(ip)))
    time.sleep(INTERVALL)
示例#4
0
def __oldPiholeStatus():
    queries = pihole.getQueries()
    blocked = pihole.getBlocked()
    percentage = pihole.getPercentage()
    if pihole.getStatus():
        ph_status = "(Running)"
    else:
        ph_status = "(Stopped)"
    if ((queries == -1) or (blocked == -1) or (percentage == -1)):
        oled.oPrint(
            oled.center("PiHole " + chr(4)) + "\n\n" + oled.center("Fehler"))
    else:
        oled.oPrint(
            oled.center("PiHole " + ph_status) + "\n" +
            oled.concat("Queries: ", str(queries)) + "\n" +
            oled.concat("Blocked: ", str(blocked)) + "\n" +
            oled.concat("Percentage: ",
                        str(percentage) + "%"))
    time.sleep(INTERVALL)
示例#5
0
def timetable():
    haltestelle = "Koeln Hbf"
    try:
        fplan = fpl.getFahrplan()
    except Exception as e:
        oled.oPrint("\n" + oled.center("FEHLER (Fahrplan)") + "\n" + str(e))
        time.sleep(INTERVALL)
    else:
        if fplan:
            for i in range(0, len(fplan)):
                if ((fplan[i].dest == "") or
                    (fplan[i].train == "")):  #Fehlerhafte Daten nicht anzeigen
                    continue

                depart = fplan[i].timeDepart
                if (fplan[i].delay > 0):
                    depart = "(+" + str(
                        fplan[i].delay) + ")" + fplan[i].timeDepart
                oled.oPrint(
                    oled.concat(haltestelle, fplan[i].platform) +
                    "\n---------------------\n" +
                    oled.concat(fplan[i].train, depart) + "\n" + fplan[i].via +
                    "\n" + fplan[i].dest + "\n" + fplan[i].messages)
                time.sleep(INTERVALL / 2)
        else:
            oled.oPrint(haltestelle + "\n---------------------\n\n" +
                        oled.center("Keine Abfahrten") + "\n" +
                        oled.center("gefunden!"))
            time.sleep(INTERVALL / 2)
示例#6
0
def weather():
    try:
        w_in = open("weather.wtd", "r")

        #Wetter 1
        name1 = oled.center("")
        temp1 = w_in.readline().rstrip()
        condition1 = oled.center(umlaute(w_in.readline().rstrip()))
        #Wetter 2
        name2 = oled.center("")
        temp2 = w_in.readline().rstrip()
        condition2 = oled.center(umlaute(w_in.readline().rstrip()))
        w_in.close()
        if not condition1:
            condition1 = oled.center("Fehler!")
        if not condition2:
            condition2 = oled.center("Fehler!")

        oled.oPrint(
            oled.center("Wetter") + "\n\n" + name1 + "\n" + condition1 + "\n" +
            oled.center(temp1 + degreeSymbol))
        time.sleep(INTERVALL / 2)
        oled.oPrint(
            oled.center("Wetter") + "\n\n" + name2 + "\n" + condition2 + "\n" +
            oled.center(temp2 + degreeSymbol))
        time.sleep(INTERVALL / 2)
    except Exception as e:
        print(e)
        oled.oPrint("\n" + oled.center("Wetter") + "\n" +
                    oled.center("Fehler"))
        time.sleep(INTERVALL)
示例#7
0
def pistatus():
    if (DEBUG):
        print('PiStatus')

    temp = os.popen('vcgencmd measure_temp').read()
    tempprint = temp[(temp.rfind("=") + 1):]
    tempprint = tempprint[:4]

    try:
        ip = url.urlopen('https://api.ipify.org').read()

#ip = "-"
    except:
        ip = "Offline"

    temp = os.popen('vcgencmd measure_volts').read()
    voltprint = temp[(temp.rfind("=") + 1):]
    voltprint = voltprint[:7]
    oled.oPrint(
        oled.center("Pi Status") + "\n\n" +
        oled.concat("CPU-Temp: ", str(tempprint + '°C')) + "\n" +
        oled.concat("CPU-Volt: ", str(voltprint)) + "\n" +
        oled.concat("IP: ", str(ip.decode('utf-8'))))
    time.sleep(INTERVALL)
示例#8
0
def storm():
    if (DEBUG):
        print('Storm')
    try:
        u_in = open("storm.wtd", "r")
    except Exception as e:
        oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" + str(e))
        u_in.close()
    else:

        #Amtliche Warnung
        try:
            w_count = u_in.readline().rstrip()
        except Exception as e:
            oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                        oled.center(str(e)))
            time.sleep(INTERVALL)
        else:
            try:
                int(w_count)
            except:
                return
            if (str(w_count) == 'error'):
                oled.oPrint(
                    oled.center("Unwetter") + "\n\n" +
                    oled.center("Fehler beim Abrufen!"))
                time.sleep(INTERVALL / 2)
                return
            if int(w_count) > 0:
                try:
                    w_region = umlaute(u_in.readline().rstrip())
                    for i in range(0, int(w_count)):
                        w_headline = umlaute(u_in.readline().rstrip())
                        w_description = umlaute(u_in.readline().rstrip())
                        w_start = u_in.readline().rstrip()
                        w_end = u_in.readline().rstrip()

                        oled.oPrint(
                            w_region + "\n\n" + w_headline + "\n" +
                            w_description + "\n" + oled.concat('', w_start) +
                            "\n" +
                            oled.concat('(' + str(i + 1) + "|" + w_count +
                                        ")", w_end))
                        time.sleep(INTERVALL / 2)
                except Exception as e:
                    oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                                oled.center(str(e)))

                    time.sleep(INTERVALL)

        #Vorwarnung
        try:
            v_count = u_in.readline().rstrip()
        except Exception as e:
            oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                        oled.center(str(e)))
            time.sleep(INTERVALL)
        else:
            if int(v_count) > 0:
                try:
                    v_region = umlaute(u_in.readline().rstrip())
                    for i in range(0, int(v_count)):
                        v_headline = umlaute(u_in.readline().rstrip())
                        v_description = umlaute(u_in.readline().rstrip())
                        oled.oPrint(v_region + "\n\n" + v_headline + "\n" +
                                    v_description + "\n\n(" + str(i + 1) +
                                    "|" + v_count + ")")
                        time.sleep(INTERVALL / 2)
                except Exception as e:
                    oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                                oled.center(str(e)))

                    time.sleep(INTERVALL)
示例#9
0
def storm():
    try:
        u_in = open("storm.wtd", "r")
    except:
        oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                    oled.center("O"))
        w_in.close()
    else:

        #Amtliche Warnung
        try:
            w_count = u_in.readline().rstrip()
        except Exception as e:
            oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                        oled.center(str(e)))
            time.sleep(INTERVALL)
        else:
            if w_count > 0:
                try:
                    w_region = umlaute(u_in.readline().rstrip())
                    for i in range(0, int(w_count)):
                        w_headline = umlaute(u_in.readline().rstrip())
                        w_description = umlaute(u_in.readline().rstrip())
                        oled.oPrint(w_region + "\n\n" + w_headline + "\n" +
                                    w_description + "\n\n(" + str(i + 1) +
                                    "|" + w_count + ")")
                        time.sleep(INTERVALL / 2)
                except Exception as e:
                    oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                                oled.center(str(e)))
                    time.sleep(INTERVALL)

        #Vorwarnung
        try:
            v_count = u_in.readline().rstrip()
        except Exception as e:
            oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                        oled.center(str(e)))
            time.sleep(INTERVALL)
        else:
            if v_count > 0:
                try:
                    v_region = umlaute(u_in.readline().rstrip())
                    for i in range(0, int(v_count)):
                        v_headline = umlaute(u_in.readline().rstrip())
                        v_description = umlaute(u_in.readline().rstrip())
                        oled.oPrint(v_region + "\n\n" + v_headline + "\n" +
                                    v_description + "\n\n(" + str(i + 1) +
                                    "|" + v_count + ")")
                        time.sleep(INTERVALL / 2)
                except Exception as e:
                    oled.oPrint("\n" + oled.center("Fehler Unwetter") + "\n" +
                                oled.center(str(e)))
                    time.sleep(INTERVALL)