def update(): raw = get_data() if raw: (data, data_forecast, unread, news, cal) = raw image_weather = image.load( "images/weather/" + data_forecast["list"][0]["weather"][0]["icon"] + ".png") color_surface(image_weather, hex_to_rgb(conf["general"]["front_color"])) background.fill(hex_to_rgb(conf["general"]["back_color"])) background.blit(image_weather, image_weather.get_rect()) render.render(datetime.today().strftime("%H:%M"), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 120, 320, 120) table.update([{ "image": image_temp, "data": str(round(data_forecast["list"][0]["temp"]["day"], 1)) }, { "image": image_rise, "data": datetime.fromtimestamp(data["sys"]["sunrise"]).strftime("%H:%M") }, { "image": image_rise, "data": datetime.fromtimestamp(data["sys"]["sunset"]).strftime("%H:%M") }, { "image": image_mail, "data": str(unread[0]) }, { "image": image_news, "data": str(news) }, { "image": image_cal, "data": str(cal[0]) }]) screen.blit(background, (0, 0)) display.flip() else: render.render(get_ip_address('eth0'), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 0, 320, 240) screen.blit(background, (0, 0)) display.flip()
def update(): raw = get_data() if raw : (data, data_forecast, unread, news, cal) = raw image_weather = image.load("images/weather/" + data_forecast["list"][0]["weather"][0]["icon"] + ".png") color_surface(image_weather, hex_to_rgb(conf["general"]["front_color"])) background.fill(hex_to_rgb(conf["general"]["back_color"])) background.blit(image_weather, image_weather.get_rect()) render.render(datetime.today().strftime("%H:%M"), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 120, 320, 120) table.update([{"image": image_temp, "data": str(round(data_forecast["list"][0]["temp"]["day"], 1))}, {"image": image_rise, "data": datetime.fromtimestamp(data["sys"]["sunrise"]).strftime("%H:%M")}, {"image": image_rise, "data": datetime.fromtimestamp(data["sys"]["sunset"]).strftime("%H:%M")}, {"image": image_mail, "data": str(unread[0])}, {"image": image_news, "data": str(news)}, {"image": image_cal, "data": str(cal[0])}]) screen.blit(background, (0, 0)) display.flip() else : render.render(get_ip_address('eth0'), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 0, 320, 240) screen.blit(background, (0, 0)) display.flip()
def show_menu(background, back_color): dt = datetime.today() data = jload(urlopen("http://127.0.0.1/functions/cron.php?next")) dr = datetime.fromtimestamp(data["heure"]) i = 0 while True: s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect("mastersocket") s.send(jdumps({"request": "get_delta"})) delta = int(s.recv(4096)) s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect("mastersocket") s.send(jdumps({"request": "get_sw_state"})) sw_state = int(s.recv(4096)) background.fill(back_color) render.render(get_ip_address('eth0'), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 0, 320, 60) if i == 0: render.render(dt.strftime("%H:%M"), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 60, 320, 120) dt = dt.replace(minute=(dt.minute + delta) % 60, hour=dt.hour + int(floor( (dt.minute + delta) / 60))) elif i == 1: render.render(dr.strftime("%H:%M"), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 60, 320, 120) dr = dr.replace(minute=(dr.minute + delta) % 60, hour=dr.hour + int(floor( (dr.minute + delta) / 60))) if sw_state: i += 1 screen.blit(background, (0, 0)) display.flip() sleep(0.1) if i >= 2: _linux_set_time(dt.timetuple()) urlopen("http://127.0.0.1/functions/cron.php?change=" + dr.strftime("%s")).read() break
def show_menu(background, back_color): dt = datetime.today() data = jload(urlopen("http://127.0.0.1/functions/cron.php?next")) dr = datetime.fromtimestamp(data["heure"]) i = 0 while True : s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect("mastersocket") s.send(jdumps({"request": "get_delta"})) delta = int(s.recv(4096)) s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect("mastersocket") s.send(jdumps({"request": "get_sw_state"})) sw_state = int(s.recv(4096)) background.fill(back_color) render.render(get_ip_address('eth0'), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 0, 320, 60) if i == 0 : render.render(dt.strftime("%H:%M"), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 60, 320, 120) dt = dt.replace(minute = (dt.minute + delta) % 60, hour = dt.hour + int(floor((dt.minute + delta) / 60))) elif i == 1 : render.render(dr.strftime("%H:%M"), font, background, hex_to_rgb(conf["general"]["front_color"]), 0, 60, 320, 120) dr = dr.replace(minute = (dr.minute + delta) % 60, hour = dr.hour + int(floor((dr.minute + delta) / 60))) if sw_state : i+= 1 screen.blit(background, (0, 0)) display.flip() sleep(0.1) if i >= 2 : _linux_set_time(dt.timetuple()) urlopen("http://127.0.0.1/functions/cron.php?change=" + dr.strftime("%s")).read() break
'2': '\033[00;37m2', '3': '\033[00;37m3', '4': '\033[00;37m4', '5': '\033[00;37m5', '6': '\033[00;37m6', '7': '\033[00;37m7', '8': '\033[00;37m8', '9': '\033[00;37m9', } drawCondition(position) currenctPlayer = 'X' while True: render(currenctPlayer, position) for case in winCases: winCondition(case[0], case[1], case[2], position, 'X', 'O') drawCondition(position) choice = input("\n-> ") if validateChoice(currenctPlayer, choice, position): position[choice] = currenctPlayer if currenctPlayer == 'X': currenctPlayer = 'O' elif currenctPlayer == 'O': currenctPlayer = 'X'