예제 #1
0
        t = j.json()['siteCurrentPowerFlow']['STORAGE']

        c = int(t['chargeLevel'])

        # output selection control structure, tuple addressing

        graph.value = c / 100

        wait = 900
        while wait > 0:
            try:
                print(wait)
                time.sleep(1)
                wait -= 1
            except KeyboardInterrupt:
                graph.close()
                sys.exit()
    except requests.packages.urllib3.exceptions.NewConnectionError:
        print('urk')
    except requests.exceptions.ConnectionError:
        print('-e-r-r-o-r-')
    except requests.exceptions.ReadTimeout:
        print('red tim out')
    except requests.exceptions.ConnectTimeout:
        print('con tim out')
    except ConnectionError:
        print('-error-')
    except ConnectionResetError:
        print('Reset')
    except KeyboardInterrupt:
        graph.close()
예제 #2
0
        day = now.strftime('%A')
        show_text(day)
    else:
        chars = [
            str(hour / 10),
            str(hour % 10),
            str(minute / 10),
            str(minute % 10)
        ]
        dots[1] = (second % 2 == 0)
        sleep(.1)


render_thread = Thread(target=render)
display_seconds_thread = Thread(target=display_seconds)

try:
    render_thread.start()
    display_seconds_thread.start()
    while running:
        update()
except (KeyboardInterrupt, SystemExit):
    pass
finally:
    running = False
    render_thread.join()
    display_seconds_thread.join()
    coms.close()
    segs.close()
    bargraph.close()