Exemplo n.º 1
0
def main():
    p = argparse.ArgumentParser()
    p.add_argument('--posX', '-x', type=int, default=0, help="X position of the start of the text")
    p.add_argument('--posY', '-y', type=int, default=0, help="Y position of the start of the text")
    p.add_argument('--fsize', '-s',type=int , default=12, help="Font size to use for the text")
    p.add_argument('--rotation', '-r',type=int , default=0, help="Rotation one of 0, 90, 180, 270")
    p.add_argument('--invert', '-i', type=bool, default=False, help="Invert the display of the text")
    args = p.parse_args()
    args.content = "at some point I will figure out why this is a required variable but until then I'll just nail it up like this"

    with open('trains.xml') as fd:
         doc = xmltodict.parse(fd.read(), xml_attribs=True)

         iterCount = 0
         numDisplayed = 0

         if args.content:
            for iterCount in range(30):
                dest = doc['ActueleVertrekTijden']['VertrekkendeTrein'][iterCount]['EindBestemming']
                time = doc['ActueleVertrekTijden']['VertrekkendeTrein'][iterCount]['VertrekTijd']
                plat = doc['ActueleVertrekTijden']['VertrekkendeTrein'][iterCount]['VertrekSpoor']['#text']
                spc = "    "
                print(dest + spc + time[11:16] + spc + plat)
                if (dest == "Enkhuizen" and numDisplayed <= 1) or (dest == "Breda" and numDisplayed <= 1):
                    if dest == "Den Helder":
                        dest = "HDR"
                    elif dest == "Schagen":
                        dest = "SGN"
                    if numDisplayed == 0:
#                        Xpos = 0
#                        Ypos = 0
                        disp = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 1:
#                        Xpos = 25
#                        Ypos = 25
                        disp2 = dest + spc + time[11:16] + spc + "Spoor " + plat
                    numDisplayed += 1
                    dest = str(dest)
#                    text = PapirusTextPos(False, rotation=args.rotation)
                    #text = PapirusTextPos(rotation=args.rotation)
#                    text.partial_update()
#                    text.AddText(disp, args.posX, args.posY, args.fsize, invert=args.invert)
                    text = PapirusTextPos(False, rotation=args.rotation)
                    text.AddText("Vertrek van de treinen\n\n", 10, 0, 13, Id="Header")
                    text.AddText(disp, 0, 20, 18, Id="opt1")
                    try:
                        disp2
                    except NameError:
                        disp2_exists = False
                    else:
                        disp2_exists = True
                    if disp2_exists == True:
                        text.AddText(disp2, 0, 40, 18, Id="opt2")
    if numDisplayed == 0:
	text = PapirusTextPos(False, rotation=args.rotation)
        text.AddText("Vertrek van de treinen\n\n", 10, 0, 13, Id="Header")
        text.AddText("Apparently there are no trains.", 0, 35, 18, Id="errtxt")
    text.WriteAll()
Exemplo n.º 2
0
class Screen:
    def __init__(self, rotation=0):
        self.text = PapirusTextPos(False, rotation=rotation)
        self.text.AddText("",
                          x=0,
                          y=5,
                          size=36,
                          Id="title",
                          font_path=sans_font)
        self.text.AddText("",
                          x=7,
                          y=55,
                          size=16,
                          Id="body",
                          font_path=sans_font)
        self.text.AddText("",
                          x=7,
                          y=75,
                          size=16,
                          Id="footer",
                          font_path=sans_font)

    def update_header(self, text):
        self.text.UpdateText("title", text, font_path=sans_font)

    def update_body(self, text):
        self.text.UpdateText("body", text, font_path=bold_sans_font)

    def update_footer(self, text):
        self.text.UpdateText("footer", text, font_path=bold_sans_font)

    def write(self):
        self.text.WriteAll()

    def clear(self):
        self.text.Clear()
Exemplo n.º 3
0
def main():
    # TODO: load config from somewhere - config.py? Path from environment variable?
    # TODO: concept of ... pages? tabs? that are loaded in and registered.
    # TODO: instead of trying to use the tiny buttons on the papirus, is there
    #       like a row of 5 keyboard keys? maybe nice cherry switches.

    # TODO: Parameterize lat/long in config; this is Ann Arbor, MI.
    latitude = 42.22
    longitude = -83.74

    timezone = tzlocal()

    rotation = 180
    text = PapirusTextPos(autoUpdate=False, rotation=rotation)

    # TODO: Bitmap support requires using PapirusComposite instead of
    #       PapirusTextPos.
    text.AddText("Today is", 0, 0, size=17, Id="date")
    text.AddText("Startup...", 93, 20, size=19, Id="startup")
    text.AddText("\u2600rise:", 0, 35, size=23, Id="sunrise_label")
    text.AddText("\u2600set:", 0, 57, size=23, Id="sunset_label")
    text.AddText("", 87, 35, size=23, Id="sunrise")
    text.AddText("", 87, 57, size=23, Id="sunset")
    text.AddText("Temp", 0, 80, size=14, Id="temp")
    text.WriteAll()

    text.RemoveText("startup")

    first_display = True
    while True:
        today = datetime.date.today()

        # TODO: Accommodate lack of sunrise/sunset like as far north as
        #       Utqiaġvik - the city formerly known as Barrow, Alaska.
        #       get_sunrise_sunset() returns those as None.
        sunrise_time, sunset_time = get_sunrise_sunset(latitude, longitude,
                                                       today, timezone)

        text.UpdateText("date",
                        "Today is {}".format(today.strftime("%A, %Y-%m-%d")))
        text.UpdateText("sunrise", sunrise_time.strftime("%I:%M %p"))
        text.UpdateText("sunset", sunset_time.strftime("%I:%M %p"))
        # For testing the longest English day name.
        #text.UpdateText("date", "Today is {}".format(today.strftime("Wednesday, %Y-%m-%d")))

        text.UpdateText(
            "temp",
            "Temp {}".format(get_temperature_forecast(latitude, longitude)))

        # Do a partial update on startup, and a full update each following hour.
        text.WriteAll(first_display)
        first_display = False

        # Wait until the next hour.
        now = datetime.datetime.now()
        next_hour = (now + datetime.timedelta(hours=1)).replace(microsecond=0,
                                                                second=0,
                                                                minute=0)
        wait_seconds = (next_hour - now).total_seconds()
        print("waiting {} seconds until next hour".format(wait_seconds))
        time.sleep(wait_seconds)
Exemplo n.º 4
0
    def handle_data(self, data):
        # Take the contents of the first <pre> section.
        if not self.is_pre:
            return

        if self.pre_data is None:
            self.pre_data = data
        elif data.rstrip():
            print("Warn: found multiple non-empty <pre> sections")

    def error(self, message):
        print("Parsing error: {}".format(message))
        exit(1)


if __name__ == "__main__":
    try:
        main()
    except Exception as e:
        # Display abnormal errors, but not SystemExit or KeyboardInterrupt.
        # TODO: how to get config from here?
        text = PapirusTextPos(autoUpdate=False, rotation=180)
        text.AddText("Error {} {}: {}".format(
            datetime.datetime.now().strftime("%Y-%m-%d %I:%M %p"),
            type(e).__name__,
            e,
        ))
        text.WriteAll(partialUpdate=True)
        raise
Exemplo n.º 5
0
def main():
    p = argparse.ArgumentParser()
    p.add_argument('--posX',
                   '-x',
                   type=int,
                   default=0,
                   help="X position of the start of the text")
    p.add_argument('--posY',
                   '-y',
                   type=int,
                   default=0,
                   help="Y position of the start of the text")
    p.add_argument('--fsize',
                   '-s',
                   type=int,
                   default=12,
                   help="Font size to use for the text")
    p.add_argument('--rotation',
                   '-r',
                   type=int,
                   default=0,
                   help="Rotation one of 0, 90, 180, 270")
    p.add_argument('--invert',
                   '-i',
                   type=bool,
                   default=False,
                   help="Invert the display of the text")
    args = p.parse_args()
    args.content = "at some point I will figure out why this is a required variable but until then I'll just nail it up like this"

    with open('/tmp/trains.xml') as fd:
        doc = xmltodict.parse(fd.read(), xml_attribs=True)

        iterCount = 0
        numDisplayed = 0

        if args.content:
            for iterCount in range(30):
                dest = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['EindBestemming']
                time = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['VertrekTijd']
                plat = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['VertrekSpoor']['#text']
                spc = "    "
                print(dest + spc + time[11:16] + spc + plat)
                if (dest == "qeq"
                        and numDisplayed <= 3) or (dest == "wew   "
                                                   and numDisplayed <= 3):
                    if dest == "Wormerveer":
                        dest = "WRM"
                        print("!! HIT")
                    elif dest == "Rotterdam Centraal":
                        dest = "RDC"
                        print("!! HIT")
                    if numDisplayed == 0:
                        disp = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 1:
                        disp2 = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 2:
                        disp3 = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 3:
                        disp4 = dest + spc + time[11:16] + spc + "Spoor " + plat
                    numDisplayed += 1
                    #                    dest = str(dest)
                    text = PapirusTextPos(False, rotation=args.rotation)
                    text.AddText("Vertrek van de treinen\n\n",
                                 12,
                                 0,
                                 13,
                                 Id="Header")
                    text.AddText(disp, 0, 19, 18, Id="opt1")
                    try:
                        disp2
                    except NameError:
                        disp2_exists = False
                    else:
                        disp2_exists = True
                    if disp2_exists == True:
                        text.AddText(disp2, 0, 39, 18, Id="opt2")
                    try:
                        disp3
                    except NameError:
                        disp3_exists = False
                    else:
                        disp3_exists = True
                    if disp3_exists == True:
                        text.AddText(disp3, 0, 59, 18, Id="opt3")

                    try:
                        disp4
                    except NameError:
                        disp4_exists = False
                    else:
                        disp4_exists = True
                    if disp4_exists == True:
                        text.AddText(disp3, 0, 79, 18, Id="opt4")

    if numDisplayed == 0:
        print(
            "\nNo hits for configured stations. Assuming storing. Exception handler goes here."
        )
        text = PapirusTextPos(False, rotation=args.rotation)
        text.AddText("Vertrek van de treinen\n\n", 10, 0, 13, Id="Header")
        text.AddText(train6, 11, 10, 13, Id="train6")
        text.AddText(train7, 1, 25, 13, Id="train7")
        text.AddText(train8, 0, 40, 13, Id="train8")
        text.AddText(train9, 0, 55, 13, Id="train9")
        #        text.AddText("Apparently there", 15, 35, 18, Id="errtxt1")
        #        text.AddText("are no trains.", 25, 55, 18, Id="errtxt2")
        text.AddText("Apparently there are no trains", 15, 80, 9, Id="errtxt")


#assbag git
    text.WriteAll()
Exemplo n.º 6
0
def main():
    p = argparse.ArgumentParser()
    p.add_argument('--posX',
                   '-x',
                   type=int,
                   default=0,
                   help="X position of the start of the text")
    p.add_argument('--posY',
                   '-y',
                   type=int,
                   default=0,
                   help="Y position of the start of the text")
    p.add_argument('--fsize',
                   '-s',
                   type=int,
                   default=12,
                   help="Font size to use for the text")
    p.add_argument('--rotation',
                   '-r',
                   type=int,
                   default=0,
                   help="Rotation one of 0, 90, 180, 270")
    p.add_argument('--invert',
                   '-i',
                   type=bool,
                   default=False,
                   help="Invert the display of the text")
    args = p.parse_args()
    args.content = " "

    with open('/tmp/trains.xml') as fd:
        doc = xmltodict.parse(fd.read(), xml_attribs=True)

        iterCount = 0
        numDisplayed = 0

        ## CONFIGURABLE ITEM
        ## Depending on the time of day, and the size of your station, there will
        ## be a varying number of results returned in the 'trains.xml' file. If
        ## range(VALUE) exceeds the number of results contained in the file, the
        ## script will die. I realize that this sucks, and I will work on fixing
        ## it. For now, set the range(VALUE) to something that works for you.
        ## 30 seems to be safe for Amsterdam Centraal most of the time.
        #for iterCount in range(0, len(doc), not_fucked_up=True, dont_always_return_1=True):
        if args.content:
            for iterCount in range(30):
                ## I'm only grabbing the end station, departure time, and
                ## departure platform at start station to display.
                ## There are more things you can retrieve-- paw through trains.xml
                ## +read xmltodict docs to understand how to retrieve them.
                ## I found this page useful:
                ## http://omz-software.com/pythonista/docs/ios/xmltodict.html
                dest = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['EindBestemming']
                time = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['VertrekTijd']
                plat = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['VertrekSpoor']['#text']
                spc = "    "

                print(dest + spc + time[11:16] + spc +
                      plat)  ## print each row on CLI

                ## CONFIGURABLE ITEM
                ## Currently the script outputs the next four trains matching your
                ## destination. Reduce the max value on both below checks of
                ## numDisplayed to get fewer results.
                if (dest == destStation1
                        and numDisplayed <= 3) or (dest == destStation2
                                                   and numDisplayed <= 3):
                    ## Shortening names to 3-letter codes to fit screen.
                    ## I *may* automate and elegantize this later.
                    if dest == "Schagen":
                        dest = "SGN"
                        print("!! HIT")  ## flagging matches on CLI for debug
                    elif dest == "Den Helder":
                        dest = "HLD"
                        print("!! HIT")  ## flagging matches on CLI for debug
                    ## save each extracted row to its own variable because
                    ## I can't quite grasp how to do this better.
                    if numDisplayed == 0:
                        ## chars [11:16] is where the time lives.
                        ## the raw var contains e.g.
                        ## 2017-07-01T21:07:00+0200
                        disp = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 1:
                        disp2 = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 2:
                        disp3 = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 3:
                        disp4 = dest + spc + time[11:16] + spc + "Spoor " + plat
                    numDisplayed += 1
                    #                    dest = str(dest)
                    #initialize screen buffer var "text" without displaying anything
                    text = PapirusTextPos(False, rotation=args.rotation)
                    #Append the first bit of text to the screen buffer, top centered.
                    #X position 12, Y position 0, font size 13, Id="Header"
                    #text.AddText("Text", Xpos, Xpos, fontSize, Id="freeformElementID")
                    text.AddText("Vertrek van de treinen",
                                 12,
                                 0,
                                 13,
                                 Id="Header")
                    text.AddText(disp, 0, 19, 18, Id="opt1")

                    ## The next three stanzas are merely an attempt to gracefully
                    ## handle fewer than the maximum allowed number of results.
                    ## The results, if they exist, are presented roughly centered
                    ## in a stack starting from the top, as you can see from the
                    ## increasing Y values in text.AddText.
                    try:
                        disp2
                    except NameError:
                        disp2_exists = False
                    else:
                        disp2_exists = True
                    if disp2_exists == True:
                        text.AddText(disp2, 0, 39, 18, Id="opt2")

                    try:
                        disp3
                    except NameError:
                        disp3_exists = False
                    else:
                        disp3_exists = True
                    if disp3_exists == True:
                        text.AddText(disp3, 0, 59, 18, Id="opt3")

                    try:
                        disp4
                    except NameError:
                        disp4_exists = False
                    else:
                        disp4_exists = True
                    if disp4_exists == True:
                        text.AddText(disp3, 0, 79, 18, Id="opt4")

    ## Exception handling. If we got all the way here and there was
    ## nothing to display, print something on the screen and the CLI
    ## to alert the user.
    if numDisplayed == 0:
        print(
            "\nNo hits for configured stations. Assuming disruption. Exception handler goes here."
        )
        text = PapirusTextPos(False, rotation=args.rotation)
        text.AddText("Vertrek van de treinen\n\n", 10, 0, 13, Id="Header")
        ## this is the small Choo-Choo #404 from above, appearing
        ## shortly on your PaPiRus :)
        text.AddText(train6, 87, 15, 13, Id="train6")
        text.AddText(train7, 28, 27, 13, Id="train7")
        text.AddText(train8, 20, 40, 13, Id="train8")
        text.AddText(train9, 15, 53, 13, Id="train9")
        #        text.AddText("Apparently there", 15, 35, 18, Id="errtxt1")
        #        text.AddText("are no trains.", 25, 55, 18, Id="errtxt2")
        text.AddText("Apparently there are no trains", 8, 80, 10, Id="errtxt")
        ## And here's another Choo-Choo #404 to keep your terminal company
        print(train1)
        print(train2)
        print(train3)
        print(train4)
        print(train5 + "\n")

    ## Finally, the grand finale! Up until now, every text.AddText()
    ## operation was merely adding data to the buffer for the screen,
    ## not actually displaying it. text.WriteAll() dumps everything
    ## to the screen all at once, as befits an ePaper display. We
    ## only have to call this once per run of the entire script,
    # which is why it's at the end. d3rp.
    text.WriteAll()
Exemplo n.º 7
0
class get_text(Resource):
    def get(self):
        return jsonify({'data': lines})


class commit_text(Resource):
    def get(self):
        for i in range(0, 9):
            papirus_text.UpdateText(ids[i], lines[i])
        papirus_text.WriteAll()
        return jsonify({'data': lines})


api.add_resource(get_text, "/status")
api.add_resource(set_text, '/<index>/<text>')  # Dynamic route
api.add_resource(clear_text, '/<index>/')
api.add_resource(commit_text, '/commit/')


# Routes
@app.route('/')
def index():
    return render_template("index.html")


if __name__ == '__main__':
    for i in range(0, 9):
        papirus_text.AddText(lines[i], 0, i * 14, Id=ids[i], size=12)
    papirus_text.WriteAll()
    app.run(host='0.0.0.0', port=5555)
Exemplo n.º 8
0
disp_text = "wifi- "
if console_display: print(disp_text)
text.AddText(disp_text, 0, vert_spacing * 1, font_size, Id="wifi")
disp_text = "wlan- "
if console_display: print(disp_text)
text.AddText(disp_text, 0, vert_spacing * 2, font_size, Id="wlan0")
disp_text = "wan - "
if console_display: print(disp_text)
text.AddText(disp_text, 0, vert_spacing * 3, font_size, Id="Pub")
disp_text = "VPN is "
if console_display: print(disp_text)
text.AddText(disp_text, 0, vert_spacing * 4, font_size, Id="VPN")
disp_text = text_time
if console_display: print(disp_text)
text.AddText(disp_text, 0, vert_spacing * 5, font_size, Id="date")
text.WriteAll()
tunnel_up = False
clear_time = False
tunnel_went_down = False
have_inet = True
first_run = True
last_loop = time.time()
while True:
    diff = time.time() - last_loop
    if first_run:
        first_run = False
        diff = 2.0
    if diff < 1.5:
        time.sleep(2)
        continue
    tunnel_up = False
Exemplo n.º 9
0
def main():
    p = argparse.ArgumentParser()
    p.add_argument('--posX',
                   '-x',
                   type=int,
                   default=0,
                   help="X position of the start of the text")
    p.add_argument('--posY',
                   '-y',
                   type=int,
                   default=0,
                   help="Y position of the start of the text")
    p.add_argument('--fsize',
                   '-s',
                   type=int,
                   default=12,
                   help="Font size to use for the text")
    p.add_argument('--rotation',
                   '-r',
                   type=int,
                   default=0,
                   help="Rotation one of 0, 90, 180, 270")
    p.add_argument('--invert',
                   '-i',
                   type=bool,
                   default=False,
                   help="Invert the display of the text")
    args = p.parse_args()
    args.content = "at some point I will figure out why this is a required variable but until then I'll just nail it up like this"

    with open('oldtrains.xml') as fd:
        doc = xmltodict.parse(fd.read(), xml_attribs=True)

        iterCount = 0
        numDisplayed = 0

        if args.content:
            for iterCount in range(30):
                text = PapirusTextPos(False, rotation=args.rotation)
                text.AddText("Vertrek van de treinen\n\n",
                             10,
                             0,
                             13,
                             Id="Header")
                dest = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['EindBestemming']
                time = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['VertrekTijd']
                plat = doc['ActueleVertrekTijden']['VertrekkendeTrein'][
                    iterCount]['VertrekSpoor']['#text']
                spc = "    "
                print(dest + spc + time[11:16] + spc + plat)
                if (dest == "Den Helder"
                        and numDisplayed <= 1) or (dest == "Schagen"
                                                   and numDisplayed <= 1):
                    if dest == "Den Helder":
                        dest = "HLD"
                        print("YUP, " + dest + "!")
                    elif dest == "Schagen":
                        dest = "SGN"
                        print(dest + ", YEEHA!")

                    if numDisplayed == 0:
                        print("numDisplayed == 0")
                        disp = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 1:
                        print("numDisplayed == 1")
                        disp2 = dest + spc + time[11:16] + spc + "Spoor " + plat
                    elif numDisplayed == 2:
                        disp3 = dest + spc + time[11:16] + spc + "Spoor " + plat

                    print("incrementing numDisplayed from ")
                    print(numDisplayed)
                    print(" to ")
                    numDisplayed += 1
                    print(numDisplayed)

                    print("adding 1st dest to screen buffer")
                    text.AddText(disp, 0, 25, 18, Id="opt1")
                    try:
                        disp2
                    except NameError:
                        disp2_exists = False
                    else:
                        disp2_exists = True
                    if disp2_exists == True:
                        print("adding 2nd dest to screen buffer")
                        text.AddText(disp2, 0, 50, 18, Id="opt2")

                    try:
                        disp3
                    except NameError:
                        disp3_exists = False
                    else:
                        disp3_exists = True
                    if disp3_exists == True:
                        text.AddText(disp3, 0, 75, 18, Id="opt3")
    if numDisplayed == 0:
        text.AddText("Apparently there are no trains.", 0, 35, 18, Id="errtxt")
    print("writing buffer to screen")
    text.WriteAll()
Exemplo n.º 10
0
def main(argv):
    global SIZE

    GPIO.setmode(GPIO.BCM)

    GPIO.setup(SW1, GPIO.IN)
    GPIO.setup(SW2, GPIO.IN)
    GPIO.setup(SW3, GPIO.IN)
    GPIO.setup(SW4, GPIO.IN)
    if SW5 != -1:
        GPIO.setup(SW5, GPIO.IN)

    papirus = PapirusTextPos(False,
                             rotation=int(argv[0]) if len(sys.argv) > 1 else 0)

    cdrom = ''
    i = 0
    files = []

    papirus.AddText('USB Gadget ISO Loader\n\nREDRAW CDROM UP DOWN SELECT',
                    0,
                    0,
                    Id='browser',
                    size=12)
    papirus.AddText('Status Unknown', 0, 55, Id='status', size=20)
    papirus.AddText('', 160, 55, Id='cdrom', size=12)
    papirus.AddText('Please select a disk.', 0, 80, Id='selected', size=12)
    papirus.WriteAll()
    while True:
        press = False

        if GPIO.input(SW5) == False:
            papirus.WriteAll()

        if GPIO.input(SW4) == False:
            if not cdrom:
                cdrom = ' cdrom=y'
                papirus.UpdateText('cdrom', 'cdrom')
            else:
                cdrom = ''
                papirus.UpdateText('cdrom', '')
            press = True

        if GPIO.input(UP) == False:
            press = True
            i = i - 1

        if GPIO.input(DOWN) == False:
            press = True
            i = i + 1

        if GPIO.input(SELECT) == False:
            os.system('rmmod g_mass_storage')
            status = os.system('modprobe g_mass_storage file="%s" stall=0 %s' %
                               ('/'.join((iso_dir, file)), cdrom))
            papirus.UpdateText('selected', file)
            if cdrom:
                type = 'CDROM '
            else:
                type = 'DISK '
            cdrom = ''
            papirus.UpdateText('cdrom', '')

            if (status == 0):
                papirus.UpdateText('status', type + 'OK')
            else:
                papirus.UpdateText('status', type + 'Fail!')
            papirus.WriteAll(True)

        if press is False:
            sleep(0.1)
            continue

        try:
            file = files[i]
        except IndexError:
            files = natural_sort(os.listdir(iso_dir))
            if (i > 0):
                i = 0
            else:
                i = -1
            if not files:
                papirus.UpdateText('browser', 'No files found')
            file = files[i]

        papirus.UpdateText(
            'browser', '%s\n%s\n%s\n%s' %
            (safe_index(files, i), safe_index(files, i + 1),
             safe_index(files, i + 2), safe_index(files, i + 3)))
        papirus.WriteAll(True)

        sleep(0.1)
Exemplo n.º 11
0
                   Id="OutTemp",
                   font_path=font)
    #    screen.AddText(trend_symbol, 170, 30, 50, font_path=arrow_font)
    screen.AddText('Humidity ' + str(out_humidity) + '%',
                   5,
                   86,
                   12,
                   Id='Humidity',
                   font_path=font)
    screen.AddText('Bedroom', 5, 103, 15, Id='InTitle', font_path=font)
    screen.AddText(bedroom_temp + u"\u00b0",
                   5,
                   115,
                   35,
                   Id='InTemp',
                   font_path=font)
    screen.AddText(forecast_title, 130, 93, 15, Id='FcTitle', font_path=font)
    screen.AddText(forecast_high + u"\u00b0",
                   130,
                   105,
                   35,
                   Id='FcTemp',
                   font_path=font)
    screen.AddText(forecast_text, 130, 143, 12, Id='FcText', font_path=font)
    screen.AddText(data_time, 10, 164, 10, Id='When', font_path=font)
    screen.WriteAll()

    print "Updated at " + now + " with data timed " + data_time

    time.sleep(600)
Exemplo n.º 12
0
class papirus_cont(object):
    def __init__(self):

        self.papi = PapirusTextPos(False)
        self.papi.Clear()

        self.papi.AddText("DATE:", 0, 0, Id="datetext")
        self.papi.AddText("00-00 00:00", 60, 0, Id="date-time")

        self.papi.AddText("TEMP:", 0, 20, Id="temptext")
        self.papi.AddText("00.000", 60, 20, Id="temp")

        self.papi.AddText("HUME:", 0, 40, Id="humtext")
        self.papi.AddText("00.000", 60, 40, Id="hum")

        self.papi.AddText("PRES:", 0, 60, Id="presstxt")
        self.papi.AddText("0000", 60, 60, Id="press")

        self.papi.AddText("Initializing", 0, 80, Id="ip")

        self.papi.WriteAll()

    def set_new_datetime(self):
        self.now_time = datetime.now()
        self.papi.UpdateText("date-time",
                             (self.now_time.strftime('%m-%d %H:%M')))

    def set_temp(self, temp):
        self.papi.UpdateText("temp", "{0:.3f}".format(temp) + "[deg]")

    def set_hum(self, hum):
        self.papi.UpdateText("hum", "{0:.3f}".format(hum) + "[%]")

    def set_press(self, press):
        self.papi.UpdateText("press", "{0:.1f}".format(press) + "[hpa]")

    def set_ipaddress(self):
        self.ip = "0.0.0.0"

        try:
            #socket.AF_INET:IVv4のアドレス, socket.SOCK_DGRAM:UDPネットワークの
            #IPv6の場合はAF_INET→IF_INET6
            self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            #タイムアウトを10秒
            self.s.settimeout(10)
            #ipアドレス8.8.8.8:80に接続します。
            # 8.8.8.8はgoogle Public DNSPCのIP。
            # 外のアドレスなら何でもいいです。
            self.s.connect(("8.8.8.8", 80))
            #今の接続のソケット名を取得します。
            self.ip = self.s.getsockname()[0]
            #IPアドレス表示
            #print(self.ip)

        except socket.error:  #ネットワークがエラーだったり無かったら
            self.ip = 'No Internet'
            #print('No Internet')

        #print(type(self.ip))
        self.papi.UpdateText("ip", self.ip)

    def get_network_state(self):
        return self.ip

    def update(self):
        self.papi.WriteAll()