From 32fccff65d8ade6d7371eca01d30c5ce6cb8f162 Mon Sep 17 00:00:00 2001 From: "Mr.Servo" Date: Sun, 11 Oct 2026 16:12:52 +0200 Subject: [PATCH 1/5] [LCD4linux] V5.0-r41 end of Python2 support - major code changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Impact on users: - new option in weather and weather2 in the "On"/"Media"/"Idle" modes (with or without the suffix "°C" instead of the previously used "°") for displaying the temperature - improved placement of weather report elements Impact on the code: - end of Python2 support: completely rewritten and optimized Py3 code according PEP guidelines - current check Methods for internet access - all SIX Py2/3 compatibility libraries have been removed and replaced with the current Py3 libraries - complete transition to f-strings - a lot of custom programming for compatibility features that have long since become obsolete (e.g., to accommodate the quirks of Dreambox images) - many code optimizations NOTE: LCD4linux no longer runs on Python 2 as of this version --- lcd4linux/src/Photoframe.py | 124 +- lcd4linux/src/WebConfigSite.py | 375 +- lcd4linux/src/WebSite.py | 130 +- lcd4linux/src/__init__.py | 3 +- lcd4linux/src/bluesound.py | 26 +- lcd4linux/src/dpf.py | 8 +- lcd4linux/src/module.py | 45 +- lcd4linux/src/ping.py | 171 +- lcd4linux/src/plugin.py | 5536 ++++++++++++++------- lcd4linux/src/renderer/PixmapLcd4linux.py | 46 +- lcd4linux/src/utils.py | 2 - lcd4linux/src/ymc.py | 21 +- 12 files changed, 4148 insertions(+), 2339 deletions(-) diff --git a/lcd4linux/src/Photoframe.py b/lcd4linux/src/Photoframe.py index 53a78f8..da247e5 100644 --- a/lcd4linux/src/Photoframe.py +++ b/lcd4linux/src/Photoframe.py @@ -1,11 +1,9 @@ -# -*- coding: UTF-8 -*- - from time import time, sleep from usb.core import find from usb.util import get_string from PIL import Image from struct import pack -from io import StringIO +from io import BytesIO def write_jpg2frame(dev, pic): @@ -20,85 +18,83 @@ def write_jpg2frame(dev, pic): endpoint = 0x02 # send to device in packages of = 2^16 psize = 65536 - for p in range(int(len(tdata) / psize)): + for p in range(len(tdata) // psize): pdata = tdata[p * psize:(p + 1) * psize] dev.write(endpoint, pdata) def get_known_devices(): - # Return a dict of photo frames - dlist = [] - # listed as: Name, idVendor, idProduct, [width , height - in pixel if applicable] - - # 0,1 Samsung SPF-75H/76H (23) - dlist.append({'name': "SPF75H/76H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x200f, 'width': 800, 'height': 480}) - dlist.append({'name': "SPF75H/76H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x200e}) - - # 2,3 Samsung SPF-87H (24) - dlist.append({'name': "SPF87H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2034, 'width': 800, 'height': 480}) - dlist.append({'name': "SPF87H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2033}) + # Return a list of supported photo frames. + # Each entry lists: Name, idVendor, idProduct, [width, height]. + return [ + # 0,1 Samsung SPF-75H/76H (23) + {'name': "SPF75H/76H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x200f, 'width': 800, 'height': 480}, + {'name': "SPF75H/76H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x200e}, - # 4,5 Samsung SPF-87Hold (25) - dlist.append({'name': "SPF87Hold Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2026, 'width': 800, 'height': 480}) - dlist.append({'name': "SPF87Hold Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2025}) + # 2,3 Samsung SPF-87H (24) + {'name': "SPF87H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2034, 'width': 800, 'height': 480}, + {'name': "SPF87H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2033}, - # 6,7 Samsung SPF-83H (26) - dlist.append({'name': "SPF83H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x200d, 'width': 800, 'height': 600}) - dlist.append({'name': "SPF83H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x200c}) + # 4,5 Samsung SPF-87Hold (25) + {'name': "SPF87Hold Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2026, 'width': 800, 'height': 480}, + {'name': "SPF87Hold Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2025}, - # 8,9 Samsung SPF-107H (27) - dlist.append({'name': "SPF107H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2036, 'width': 1024, 'height': 600}) - dlist.append({'name': "SPF107H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2035}) + # 6,7 Samsung SPF-83H (26) + {'name': "SPF83H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x200d, 'width': 800, 'height': 600}, + {'name': "SPF83H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x200c}, - # 10,11 Samsung SPF-105P (28) - dlist.append({'name': "SPF105P Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x201b, 'width': 1024, 'height': 600}) - dlist.append({'name': "SPF105P Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x201c}) + # 8,9 Samsung SPF-107H (27) + {'name': "SPF107H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2036, 'width': 1024, 'height': 600}, + {'name': "SPF107H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2035}, - # 12,13 Samsung SPF-85H/86H (29) - dlist.append({'name': "SPF85H/86H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2013, 'width': 800, 'height': 600}) - dlist.append({'name': "SPF85H/86H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2012}) + # 10,11 Samsung SPF-105P (28) + {'name': "SPF105P Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x201b, 'width': 1024, 'height': 600}, + {'name': "SPF105P Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x201c}, - # 14,15 Samsung SPF-72H (210) - dlist.append({'name': "SPF72H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x200b, 'width': 800, 'height': 480}) - dlist.append({'name': "SPF72H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x200a}) + # 12,13 Samsung SPF-85H/86H (29) + {'name': "SPF85H/86H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2013, 'width': 800, 'height': 600}, + {'name': "SPF85H/86H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2012}, - # 16,17 Samsung SPF-700T (211) - dlist.append({'name': "SPF700T Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2050, 'width': 800, 'height': 600}) - dlist.append({'name': "SPF700T Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x204f}) + # 14,15 Samsung SPF-72H (210) + {'name': "SPF72H Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x200b, 'width': 800, 'height': 480}, + {'name': "SPF72H Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x200a}, - # 18,19 Samsung SPF-85P/86P (212) - dlist.append({'name': "SPF85P/86P Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2017, 'width': 800, 'height': 600}) - dlist.append({'name': "SPF85P/86P Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2016}) + # 16,17 Samsung SPF-700T (211) + {'name': "SPF700T Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2050, 'width': 800, 'height': 600}, + {'name': "SPF700T Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x204f}, - # 20,21 Samsung SPF-107Hold (213) - dlist.append({'name': "SPF107Hold Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2028, 'width': 1024, 'height': 600}) - dlist.append({'name': "SPF107Hold Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2027}) + # 18,19 Samsung SPF-85P/86P (212) + {'name': "SPF85P/86P Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2017, 'width': 800, 'height': 600}, + {'name': "SPF85P/86P Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2016}, - # 22,23 Samsung SPF-1000P (214) - dlist.append({'name': "SPF1000P Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2040, 'width': 1024, 'height': 600}) - dlist.append({'name': "SPF1000P Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2039}) + # 20,21 Samsung SPF-107Hold (213) + {'name': "SPF107Hold Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2028, 'width': 1024, 'height': 600}, + {'name': "SPF107Hold Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2027}, - # 24,25 Samsung SPF-800P (215) - dlist.append({'name': "SPF800P Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2038, 'width': 800, 'height': 480}) - dlist.append({'name': "SPF800P Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2037}) + # 22,23 Samsung SPF-1000P (214) + {'name': "SPF1000P Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2040, 'width': 1024, 'height': 600}, + {'name': "SPF1000P Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2039}, - # 26,27 Samsung SPF-800W (216) - dlist.append({'name': "SPF800W Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x204c, 'width': 800, 'height': 600}) - dlist.append({'name': "SPF800W Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x204b}) + # 24,25 Samsung SPF-800P (215) + {'name': "SPF800P Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x2038, 'width': 800, 'height': 480}, + {'name': "SPF800P Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x2037}, - # 28,29 Samsung SPF-1000W (217) - dlist.append({'name': "SPF1000W Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x204e, 'width': 1024, 'height': 768}) - dlist.append({'name': "SPF1000W Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x204d}) + # 26,27 Samsung SPF-800W (216) + {'name': "SPF800W Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x204c, 'width': 800, 'height': 600}, + {'name': "SPF800W Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x204b}, - # Amazon Fire 7 (9th Generation 2019) - dlist.append({'name': "Amazon Fire 7 Mini Monitor", 'idVendor': 0x1949, 'idProduct': 0x03C3, 'width': 1024, 'height': 600}) - dlist.append({'name': "Amazon Fire 7 Mass Storage", 'idVendor': 0x1949, 'idProduct': 0x03C1}) + # 28,29 Samsung SPF-1000W (217) + {'name': "SPF1000W Mini Monitor", 'idVendor': 0x04e8, 'idProduct': 0x204e, 'width': 1024, 'height': 768}, + {'name': "SPF1000W Mass Storage", 'idVendor': 0x04e8, 'idProduct': 0x204d}, - # Pearl DPF for Testing - dlist.append({'name': "Pearl DPF", 'idVendor': 0x1908, 'idProduct': 0x0102, 'width': 320, 'height': 240}) - dlist.append({'name': "Pearl DPF", 'idVendor': 0x1908, 'idProduct': 0x0102, 'width': 320, 'height': 240}) + # 30, 31 Amazon Fire 7 (9th Generation 2019) + {'name': "Amazon Fire 7 Mini Monitor", 'idVendor': 0x1949, 'idProduct': 0x03C3, 'width': 1024, 'height': 600}, + {'name': "Amazon Fire 7 Mass Storage", 'idVendor': 0x1949, 'idProduct': 0x03C1}, - return dlist + # 32, 33 Pearl DPF for Testing + {'name': "Pearl DPF", 'idVendor': 0x1908, 'idProduct': 0x0102, 'width': 320, 'height': 240}, + {'name': "Pearl DPF", 'idVendor': 0x1908, 'idProduct': 0x0102, 'width': 320, 'height': 240}, + ] def find_device(anzahl, device, device2): @@ -116,7 +112,7 @@ def find_device(anzahl, device, device2): except Exception: from traceback import format_exc print("[LCD4linux] find exception") - print("Error: %s" % format_exc()) + print(f"Error: {format_exc()}") d = None return d @@ -127,7 +123,7 @@ def init_device(anzahl, device0, device1): if dev is not None: # found it, trying to init it - print("[LCD4linux] Find frame device: %s" % dev) + print(f"[LCD4linux] Find frame device: {dev}") if dev.idProduct == device0["idProduct"]: print("[LCD4linux] init Device") frame_init(dev) @@ -212,7 +208,7 @@ def main(): # rotate # crop image = image.resize((800, 480)) - output = StringIO.StringIO() + output = BytesIO() image.save(output, "JPEG", quality=94) pic = output.getvalue() output.close() diff --git a/lcd4linux/src/WebConfigSite.py b/lcd4linux/src/WebConfigSite.py index 83cbe26..9cbbb1d 100644 --- a/lcd4linux/src/WebConfigSite.py +++ b/lcd4linux/src/WebConfigSite.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- from glob import glob from os import stat from os.path import isfile, join, basename +from pathlib import Path from time import time from twisted.web import resource, http from html import unescape as _unescape @@ -18,8 +18,12 @@ from .configOptions import L1, L2, L3, L4 -DPKG = False -M = [_("OSD"), _("Screen"), _("Picture"), _("Weather"), _("Netatmo"), _("Popup-Text"), _("FritzCall"), _("Font"), _("Mail"), _("Calendar"), _("Remote Box"), _("WWW Converter"), _("WebIF"), _("MJPEG Stream"), _("Box-Skin-LCD"), _("Tuner"), _("Key"), _("BlueSound"), _("Sonos"), _("MusicCast")] +M = [ + _("OSD"), _("Screen"), _("Picture"), _("Weather"), _("Netatmo"), _("Popup-Text"), _("FritzCall"), _("Font"), _("Mail"), _("Calendar"), + _("Remote Box"), _("WWW Converter"), _("WebIF"), _("MJPEG Stream"), _("Box-Skin-LCD"), _("Tuner"), _("Key"), _("BlueSound"), _("Sonos"), + _("MusicCast") + ] + Mode = "1" ModeOld = "" Element = "" @@ -29,28 +33,15 @@ L4LElement = L4Lelement() -def ensure_binary(s): - if isinstance(s, str): - return s.encode("utf-8") - return s - - -def ensure_str(s): - if isinstance(s, bytes): - return s.decode("utf-8") - return s - - def _exec(command): variable = command.split(" ", 1)[0] - exec("global %s;%s" % (variable, command)) + exec(f"global {variable};{command}") def _l(st): if isinstance(st, bytes): st = st.decode("utf-8", "ignore") - st = st.replace(" [ok]>", "").encode('ascii', 'xmlcharrefreplace') - return ensure_str(st) + return st.replace(" [ok]>", "").encode('ascii', 'xmlcharrefreplace').decode() def AktiveMode(Test, R): @@ -92,6 +83,13 @@ def restartTimer(self): self.StatusTimer.stop() self.StatusTimer.startLongTimer(60) + def sendTextFile(self, req, disposition, fileName): + req.setHeader('Content-type', 'text/plain') + req.setHeader('Content-Disposition', disposition) + req.setHeader('Content-Length', str(stat(fileName).st_size)) + req.setHeader('charset', 'UTF-8') + return Path(fileName).read_bytes() + def render_GET(self, request): L4logE("GET received", request.args) return self.action(request) @@ -102,12 +100,11 @@ def render_POST(self, request): def action(self, req): global Mode, ModeOld, Element, ElementList, ExeMode, StatusMode - IP = ensure_str(req.getClientIP()) - IP = IP.split(":")[-1] + IP = req.getClientIP() L4logE("IP1:", IP) if IP is None: L4logE("IP2:", req.client.host) - IP = None if IP.find(".") == -1 else req.client.host.split(":")[-1] + IP = req.client.host.split(":")[-1] if "." in req.client.host else None else: IP = IP.split(":")[-1] if IP is None: @@ -135,27 +132,29 @@ def action(self, req): html += "\n" html += "\n" html += "" - html += "Config-WebIF Access Deny ( IP: %s )
\n" % IP - html += "Please check Setting in Global > %s\n" % _l(_("WebIF IP Allow")) + html += f"Config-WebIF Access Deny ( IP: {IP} )
\n" + html += "Please check Setting in Global > {}\n".format(_l(_("WebIF IP Allow"))) html += "Default is: 127. 192.168. 172. 10.\n" html += "\n" html += "\n" - return ensure_binary(html) + return html.encode() + if len(L1) == 0: + ParseCode() req.setResponseCode(http.OK) req.setHeader('Content-type', 'text/html') req.setHeader('charset', 'UTF-8') - command = req.args.get(b"cmd", None) - _command = ensure_str(command[0]) if command != None else "" - ex = req.args.get(b"ex", None) - _ex = ensure_str(ex[0]) if ex != None else req.args.get(b"ex", None) - mo = req.args.get(b"Mode", None) - el = req.args.get(b"Element", None) + command = req.args.get(b"cmd") + _command = command[0].decode() if command else "" + ex = req.args.get(b"ex") + _ex = ex[0].decode() if ex else None + mo = req.args.get(b"Mode") + el = req.args.get(b"Element") self.restartTimer() - L4log("Command received %s" % (command), ex) + L4log(f"Command received '{command}', '{ex}'") if self.CurrentMode == ("-", "-"): self.CurrentMode = (getConfigStandby(), getisMediaPlayer()) - if mo is not None: - Mode = ensure_str(mo[0]) + if mo: + Mode = mo[0].decode() setConfigMode(True) if Mode in ["1", "2"]: setisMediaPlayer("") @@ -170,25 +169,19 @@ def action(self, req): self.resetWeb() getBilder() html = "" - if el is not None: - Element = ensure_str(el[0]) - if req.args.get(b"save.y", None) is not None: + if el: + Element = el[0].decode() + if req.args.get(b"save.y"): L4log("WebIF: save Config-File") LCD4linux.save() LCD4linux.saveToFile(LCD4config) ConfTimeCheck() - if req.args.get(b"download.y", None) is not None: + if req.args.get(b"download.y"): L4log("WebIF: download Config") req.setResponseCode(http.OK) lcd4config = resolveFilename(SCOPE_CONFIG) + "lcd4config" - req.setHeader('Content-type', 'text/plain') - req.setHeader('Content-Disposition', 'attachment;filename=lcd4config') - req.setHeader('Content-Length', str(stat(lcd4config).st_size)) - req.setHeader('charset', 'UTF-8') - with open(lcd4config) as f: - html = f.read() - return ensure_binary(html) - if req.args.get(b"upload.y", None) is not None: + return self.sendTextFile(req, 'attachment;filename=lcd4config', lcd4config) + if req.args.get(b"upload.y"): L4log("WebIF: upload Config") lcd4config = "/tmp/test" data = req.args[b"uploadName"][0] @@ -200,28 +193,21 @@ def action(self, req): else: L4log("WebIF: Error upload") html += "\n" - if req.args.get(b"logdel.y", None) is not None: + if req.args.get(b"logdel.y"): L4log("WebIF: delete Logfile") rmFile("/tmp/L4log.txt") - if req.args.get(b"logdownload.y", None) is not None: + if req.args.get(b"logdownload.y"): L4log("WebIF: download Logfile") lcd4config = "/tmp/L4log.txt" if isfile(lcd4config): - req.setResponseCode(http.OK) - req.setHeader('Content-type', 'text/plain') - req.setHeader('Content-Disposition', 'attachment;filename=l4log.txt') - req.setHeader('Content-Length', str(stat(lcd4config).st_size)) - req.setHeader('charset', 'UTF-8') - with open(lcd4config) as f: - html = f.read() - return ensure_binary(html) + return self.sendTextFile(req, 'attachment;filename=l4log.txt', lcd4config) if command is None: L4logE("no command") - elif _command == "exec" and ex is not None: - L4logE("exec: %s" % _ex) - exec(str(_ex)) # FIXME PY3 + elif _command == "exec" and ex: + L4logE(f"exec: {_ex}") + exec(_ex) elif _command == "enable": ExeMode = True elif _command == "status": @@ -241,16 +227,16 @@ def action(self, req): L4LElement.setRefresh() elif _command == "crashdel": rmFile(CrashFile) - elif _command == "add" and ex is not None: + elif _command == "add" and ex: L4LElement.web(_ex) - elif _command == "delete" and ex is not None: + elif _command == "delete" and ex: L4LElement.delete(_ex) elif _command == "refresh": L4LElement.setRefresh() elif _command == "hold": setScreenActive("0") setSaveEventListChanged(not getSaveEventListChanged()) - elif _command == "screen" and ex is not None: + elif _command == "screen" and ex: exs = _ex.split(",") if len(exs) == 1: L4LElement.setScreen(exs[0]) @@ -258,29 +244,29 @@ def action(self, req): L4LElement.setScreen(exs[0], exs[1]) elif len(exs) == 3: L4LElement.setScreen(exs[0], exs[1], exs[2] == "True") - elif _command == "brightness" and ex is not None: + elif _command == "brightness" and ex: exs = _ex.split(",") if len(exs) == 1: L4LElement.setBrightness(exs[0]) elif len(exs) == 2: L4LElement.setBrightness(exs[0], exs[1] == "True") - elif _command == "getbrightness" and ex is not None: + elif _command == "getbrightness" and ex: if int(_ex) < 1 or int(_ex) > 3: return "0" else: return str(L4LElement.getBrightness(int(_ex))) - elif _command == "getmjpeg" and ex is not None: + elif _command == "getmjpeg" and ex: if int(_ex) < 1 or int(_ex) > 3: return "0" else: return str(getMJPEGreader(_ex)) - elif _command == "getexec" and ex is not None: + elif _command == "getexec" and ex: L4logE("getexec", _ex) - _exec("getexec = %s" % _ex) # FIXME PY3 + _exec(f"getexec = {_ex}") return str(_ex) elif _command == "copyMP": for a in req.args.keys(): - _a = ensure_str(a) + _a = a.decode() if ".Standby" in _a: b = _a.replace(".Standby", ".MP") if (" " + b) in list(zip(*L3))[2]: @@ -295,7 +281,7 @@ def action(self, req): objb.value = obja.value elif _command == "copyIdle": for a in req.args.keys(): - _a = ensure_str(a) + _a = a.decode() if ".MP" in _a: b = _a.replace(".MP", ".Standby") if (" " + b) in list(zip(*L4))[2]: @@ -310,7 +296,7 @@ def action(self, req): objb.value = obja.value elif _command == "copyOn": for a in req.args.keys(): - _a = ensure_str(a) + _a = a.decode() if ".MP" in _a: b = _a.replace(".MP", ".") if (" " + b) in list(zip(*L2))[2]: @@ -329,51 +315,42 @@ def action(self, req): ##################### elif _command == "config": Cfritz = False - Cwetter = False +# Cwetter = False Cpicon = False Ccal = False Cwww = False for a in req.args.keys(): - _a = ensure_str(a) + _a = a.decode() if _a.find(".") > 0: val = req.args.get(a, "")[0] - val = ensure_str(val) -# ConfigSelection + val = val.decode() ConfObj = eval(_a) if isinstance(ConfObj, ConfigSelection): ConfObj.value = val - else: -# ConfigYesNo - if isinstance(ConfObj, ConfigYesNo): - val = req.args.get(a, "") - ConfObj.value = True if len(val) == 2 else False - else: -# ConfigText - if isinstance(ConfObj, ConfigText): - V = _l(val) - try: - V = _unescape(V) - except Exception: - L4log("WebIF Error: Parse Text") - ConfObj.value = V - else: -# ConfigSlider - if isinstance(ConfObj, ConfigSlider): - if val.isdigit(): - ConfObj.value = val - else: -# ConfigClock - if isinstance(ConfObj, ConfigClock): - t = val.split(":") - if len(t) == 2 and t[0].isdigit() and t[1].isdigit(): - ConfObj.value = [int(t[0]), int(t[1])] + elif isinstance(ConfObj, ConfigYesNo): + val = req.args.get(a, "") + ConfObj.value = True if len(val) == 2 else False + elif isinstance(ConfObj, ConfigText): + V = _l(val) + try: + V = _unescape(V) + except Exception: + L4log("WebIF Error: Parse Text") + ConfObj.value = V + elif isinstance(ConfObj, ConfigSlider): + if val.isdigit(): + ConfObj.value = val + elif isinstance(ConfObj, ConfigClock): + t = val.split(":") + if len(t) == 2 and t[0].isdigit() and t[1].isdigit(): + ConfObj.value = [int(t[0]), int(t[1])] if ConfObj.isChanged(): ConfObj.save() L4log("Changed", a) if _a.find("Fritz") > 0: Cfritz = True - elif _a.find("Wetter") > 0: - Cwetter = True +# elif _a.find("Wetter") > 0: +# Cwetter = True elif _a.find("Picon") > 0: Cpicon = True elif _a.find(".Cal") > 0 or _a.find(".MPCal") > 0 or _a.find(".StandbyCal") > 0: @@ -414,9 +391,8 @@ def action(self, req): rmFile(WWWpic % "1p") if Cfritz: rmFile(PICfritz) - if Cwetter: -# resetWetter(None) # action after changing weather parameters - pass +# if Cwetter: +# resetWetter(None) # action after changing weather parameters if Cpicon: if len(LCD4linux.PiconCache.value) > 2: rmFiles(join(LCD4linux.PiconCache.value, "*.png")) @@ -443,7 +419,7 @@ def action(self, req): html += "function fensterchen() {\n" html += "fens1=window.open(\"\", \"Crashlog\",\"width=500,height=300,resizable=yes\");\n" for line in open(CrashFile).readlines(): - html += "fens1.document.write('%s');\n" % line.replace("\n", "
").replace("'", "\\'") + html += "fens1.document.write('{}');\n".format(line.replace("\n", "
").replace("'", "\\'")) html += "} \n" html += "\n" - if L4LElement.getRefresh() == True: + if L4LElement.getRefresh() is True: GI = getINFO().split() GR = min(int(float(GI[6])) + 1, 6) if len(GI) > 6 else 6 html += f"\n" @@ -661,7 +660,7 @@ def action(self, req): html += "\n" html += "\n".format(_l(_("Exec"))) html += "\n" - if StatusMode == True: + if StatusMode is True: html += "
\n" html += f"Screen: {str(getScreenActive(True))}
\n" html += f"Hold/HoldKey: {str(getSaveEventListChanged())}/{str(L4LElement.getHoldKey())}
\n" diff --git a/lcd4linux/src/plugin.py b/lcd4linux/src/plugin.py index 2ef175b..39b09a7 100644 --- a/lcd4linux/src/plugin.py +++ b/lcd4linux/src/plugin.py @@ -47,7 +47,7 @@ from struct import unpack from textwrap import TextWrapper, wrap from threading import Thread -from time import strftime, strptime, localtime, mktime, time, sleep, gmtime, timezone, altzone, daylight +from time import strftime, strptime, localtime, mktime, time, sleep, timezone, altzone, daylight from traceback import format_exc, print_stack from twisted.internet.reactor import callInThread, callFromThread from twisted.internet.threads import deferToThread @@ -102,7 +102,6 @@ pngutil = None try: if exists("/dev/lcd2"): - from fcntl import ioctl from pngutil import png_util pngutil = png_util.PNGUtil() pngutilconnect = pngutil.connect() @@ -401,19 +400,20 @@ FontType = [("0", _("Global")), ("1", _("1")), ("2", _("2")), ("3", _("3")), ("4", _("4")), ("5", _("5"))] DayType = [("0", _("all")), ("1", _("1")), ("2", _("2")), ("3", _("3")), ("7", _("7")), ("14", _("14")), ("30", _("30"))] RecordType = [("1", _("Corner")), ("1t", _("Corner+Timeshift")), ("2", _("Picon")), ("2t", _("Picon+Timeshift"))] -ProgressType = [("1", _("only Progress Bar")), -("2", _("with Remaining Minutes")), ("21", _("with Remaining Minutes (Size 1.5)")), ("22", _("with Remaining Minutes (Size 2)")), -("3", _("with Percent")), ("31", _("with Percent (Size 1.5)")), ("32", _("with Percent (Size 2)")), -("4", _("with Remaining Minutes (above)")), ("41", _("with Remaining Minutes (above/Size 1.5)")), ("42", _("with Remaining Minutes (above/Size 2)")), -("5", _("with Percent (above)")), ("51", _("with Percent (above/Size 1.5)")), ("52", _("with Percent (above/Size 2)")), -("6", _("with Remaining Minutes (below)")), ("61", _("with Remaining Minutes (below/Size 1.5)")), ("62", _("with Remaining Minutes (below/Size 2)")), -("7", _("with Percent (below)")), ("71", _("with Percent (below/Size 1.5)")), ("72", _("with Percent (below/Size 2)")), -("8", _("with Current 00:00")), ("81", _("with Current 00:00 (Size 1.5)")), ("82", _("with Current 00:00 (Size 2)")), -("9", _("with Current 00:00 (above)")), ("91", _("with Current 00:00 (above/Size 1.5)")), ("92", _("with Current 00:00 (above/Size 2)")), -("A", _("with Current 00:00 (below)")), ("A1", _("with Current 00:00 (below/Size 1.5)")), ("A2", _("with Current 00:00 (below/Size 2)")), -("B", _("with Percent Minutes / Total (above)")), ("B1", _("with Percent Minutes / Total (above/Size 1.5)")), ("B2", _("with Percent Minutes / Total (above/Size 2)")), -("C", _("with absolute Endtime")), ("C1", _("with absolute Endtime (Size 1.5)")), ("C2", _("with absolute Endtime (Size 2)")), -("D", _("with Minutes Total / Endtime (above)")), ("D1", _("with Minutes Total / Endtime (above/Size 1.5)")), ("D2", _("with Minutes Total / Endtime (above/Size 2)")), +ProgressType = [ + ("1", _("only Progress Bar")), + ("2", _("with Remaining Minutes")), ("21", _("with Remaining Minutes (Size 1.5)")), ("22", _("with Remaining Minutes (Size 2)")), + ("3", _("with Percent")), ("31", _("with Percent (Size 1.5)")), ("32", _("with Percent (Size 2)")), + ("4", _("with Remaining Minutes (above)")), ("41", _("with Remaining Minutes (above/Size 1.5)")), ("42", _("with Remaining Minutes (above/Size 2)")), + ("5", _("with Percent (above)")), ("51", _("with Percent (above/Size 1.5)")), ("52", _("with Percent (above/Size 2)")), + ("6", _("with Remaining Minutes (below)")), ("61", _("with Remaining Minutes (below/Size 1.5)")), ("62", _("with Remaining Minutes (below/Size 2)")), + ("7", _("with Percent (below)")), ("71", _("with Percent (below/Size 1.5)")), ("72", _("with Percent (below/Size 2)")), + ("8", _("with Current 00:00")), ("81", _("with Current 00:00 (Size 1.5)")), ("82", _("with Current 00:00 (Size 2)")), + ("9", _("with Current 00:00 (above)")), ("91", _("with Current 00:00 (above/Size 1.5)")), ("92", _("with Current 00:00 (above/Size 2)")), + ("A", _("with Current 00:00 (below)")), ("A1", _("with Current 00:00 (below/Size 1.5)")), ("A2", _("with Current 00:00 (below/Size 2)")), + ("B", _("with Percent Minutes / Total (above)")), ("B1", _("with Percent Minutes / Total (above/Size 1.5)")), ("B2", _("with Percent Minutes / Total (above/Size 2)")), + ("C", _("with absolute Endtime")), ("C1", _("with absolute Endtime (Size 1.5)")), ("C2", _("with absolute Endtime (Size 2)")), + ("D", _("with Minutes Total / Endtime (above)")), ("D1", _("with Minutes Total / Endtime (above/Size 1.5)")), ("D2", _("with Minutes Total / Endtime (above/Size 2)")), ] now = localtime() begin = mktime((now.tm_year, now.tm_mon, now.tm_mday, 6, 00, 0, now.tm_wday, now.tm_yday, now.tm_isdst)) @@ -2636,11 +2636,15 @@ def setPopText(w): PopText[1] = Code_utf8(w) -def resetWetter(): +def resetWetter(w=None): global wwwWetter global PICwetter - wwwWetter = ["", ""] - PICwetter = [None, None] + if w: + wwwWetter[w] = "" + PICwetter[w] = None + else: + wwwWetter = ["", ""] + PICwetter = [None, None] def resetCal(): @@ -2662,7 +2666,7 @@ def L4LoadNewConfig(cfg): L4log("Config-Load for 'Vu+ duo²'", cfg) LCD4linux.loadFromFile(cfg) LCD4linux.load() - if LCD4linux.ConfigWriteAll.value == False: + if LCD4linux.ConfigWriteAll.value is False: LCD4linux.ConfigPath.value = P1 LCD4linux.PiconPath.value = P2 LCD4linux.PiconPathAlt.value = P3 @@ -2870,7 +2874,7 @@ def setFB2(value): def getFB2(check): - return isfile("/proc/stb/fb/sd_detach") and (LCD4linux.SwitchToFB2.value == True) if check else isfile("/proc/stb/fb/sd_detach") + return isfile("/proc/stb/fb/sd_detach") and (LCD4linux.SwitchToFB2.value is True) if check else isfile("/proc/stb/fb/sd_detach") def BRI(w1, w2): @@ -2891,7 +2895,7 @@ def virtBRI(LCD): def SensorRead(dat, isTemp=False): T = 0 - if isfile(dat) == True: + if isfile(dat) is True: lines = "" i = 0 with open(dat) as f: @@ -2947,7 +2951,7 @@ def ICSdownloads(): return ICSdownrun = True ICS.clear() - if LCD4linux.CalPlanerFS.value == True: + if LCD4linux.CalPlanerFS.value is True: try: from Plugins.Extensions.PlanerFS.PFSl4l import l4l_export liste = l4l_export().planerfs_liste @@ -2957,7 +2961,7 @@ def ICSdownloads(): liste = [] PlanerFSok = False L4logE("PlanerFS not registered") - if PlanerFSok == True: + if PlanerFSok is True: for Icomp in liste: DT = Icomp[0] L4logE(Icomp) @@ -3166,7 +3170,7 @@ def find_dev(Anzahl, idVendor, idProduct): gefunden = True else: gefunden = True - elif USBok == True: + elif USBok is True: try: L4logE(f"usb.core {list(core.find(idVendor=idVendor, find_all=True))}") if len(list(core.find(idVendor=idVendor, idProduct=idProduct, find_all=True))) >= Anzahl: @@ -3245,7 +3249,7 @@ def getpiconres(x, y, full, picon, channelname, channelname2, P2, P2A, P2C): if str(LCD4linux.PiconTransparenz.value) == "2": pil_image = pil_image.convert("RGBA") xx, yy = pil_image.size - if full == False: + if full is False: y = int(float(x) / xx * yy) if str(LCD4linux.BilderQuality.value) == "0": pil_image = pil_image.resize((x, y)) @@ -3361,7 +3365,7 @@ def writeHelligkeit(hell, night, STOP): LCDdisplay.setBright(h3) except Exception: L4logE("Error LCD:", format_exc()) - if PNGutilOK == True: + if PNGutilOK is True: H = -1 if LCD4linux.LCDType1.value[0] == "9": H = h1 @@ -3385,15 +3389,15 @@ def doDPF(dev, im, s): global SamsungDevice global SamsungDevice2 global SamsungDevice3 - if dev == 1 and dpf.showImage(SamsungDevice, s.im[im]) == False: + if dev == 1 and dpf.showImage(SamsungDevice, s.im[im]) is False: L4log("Error writing DPF Device") dpf.close(SamsungDevice) SamsungDevice = None - elif dev == 2 and dpf.showImage(SamsungDevice2, s.im[im]) == False: + elif dev == 2 and dpf.showImage(SamsungDevice2, s.im[im]) is False: L4log("Error writing DPF2 Device") dpf.close(SamsungDevice2) SamsungDevice2 = None - elif dev == 3 and dpf.showImage(SamsungDevice3, s.im[im]) == False: + elif dev == 3 and dpf.showImage(SamsungDevice3, s.im[im]) is False: L4log("Error writing DPF3 Device") dpf.close(SamsungDevice3) SamsungDevice3 = None @@ -3403,11 +3407,11 @@ def writeLCD1(s, im, quality, SAVE=True): global SamsungDevice global MJPEGreader pic = None - if s.imWrite[im] == True: + if s.imWrite[im] is True: L4log("Ignore ImWrite", im) return s.imWrite[im] = True - if LCD4linux.LCDType1.value[0] in ["2", "3"] and virtBRI(1) not in [0, 10] and SAVE == True and LCD4linux.MJPEGvirtbri1.value == True: + if LCD4linux.LCDType1.value[0] in ["2", "3"] and virtBRI(1) not in [0, 10] and SAVE is True and LCD4linux.MJPEGvirtbri1.value is True: s.tmp[im] = ImageEnhance.Brightness(s.im[im]).enhance(virtBRI(1)) s.im[im] = s.tmp[im] bild = f"{PICtmp}.png" @@ -3415,7 +3419,7 @@ def writeLCD1(s, im, quality, SAVE=True): if SamsungDevice is not None: L4log("writing to DPF Device") doDPF(1, im, s) - if "1" in LCD4linux.SavePicture.value and SAVE == True: + if "1" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate1.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value), expand=True) try: @@ -3437,7 +3441,7 @@ def writeLCD1(s, im, quality, SAVE=True): L4log("writing TFT-LCD") try: s.im[im].save("/tmp/usbtft-bmp", "BMP") - if "1" in LCD4linux.SavePicture.value and SAVE == True: + if "1" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate1.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value), expand=True) s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") @@ -3448,7 +3452,7 @@ def writeLCD1(s, im, quality, SAVE=True): elif LCD4linux.LCDType1.value[0] == "5": L4log("writing Internal-LCD") try: - if "1" in LCD4linux.SavePicture.value and SAVE == True: + if "1" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate1.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value), expand=True) s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") @@ -3523,11 +3527,11 @@ def writeLCD2(s, im, quality, SAVE=True): global SamsungDevice2 global MJPEGreader pic = None - if s.imWrite[im] == True: + if s.imWrite[im] is True: L4log("Ignore ImWrite", im) return s.imWrite[im] = True - if LCD4linux.LCDType2.value[0] in ["2", "3"] and virtBRI(2) not in [0, 10] and SAVE == True and LCD4linux.MJPEGvirtbri2.value == True: + if LCD4linux.LCDType2.value[0] in ["2", "3"] and virtBRI(2) not in [0, 10] and SAVE is True and LCD4linux.MJPEGvirtbri2.value is True: s.tmp[im] = ImageEnhance.Brightness(s.im[im]).enhance(virtBRI(2)) s.im[im] = s.tmp[im] bild = f"{PIC2tmp}.png" @@ -3535,7 +3539,7 @@ def writeLCD2(s, im, quality, SAVE=True): if SamsungDevice2 is not None: L4log("writing to DPF2 Device") doDPF(2, im, s) - if "2" in LCD4linux.SavePicture.value and SAVE == True: + if "2" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate2.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value), expand=True) try: @@ -3557,7 +3561,7 @@ def writeLCD2(s, im, quality, SAVE=True): L4log("writing TFT-LCD2") try: s.im[im].save("/tmp/usbtft-bmp", "BMP") - if "2" in LCD4linux.SavePicture.value and SAVE == True: + if "2" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate2.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value), expand=True) s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") @@ -3568,7 +3572,7 @@ def writeLCD2(s, im, quality, SAVE=True): elif LCD4linux.LCDType2.value[0] == "5": L4log("writing Internal-LCD2") try: - if "2" in LCD4linux.SavePicture.value and SAVE == True: + if "2" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate2.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value), expand=True) s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") @@ -3617,7 +3621,7 @@ def writeLCD2(s, im, quality, SAVE=True): except Exception: SamsungDevice2 = None L4log("Samsung 2 write Error") - if "2" in LCD4linux.SavePicture.value and SAVE == True: + if "2" in LCD4linux.SavePicture.value and SAVE is True: try: datei = f"{PIC2tmp}.jpg" if str(LCD4linux.LCDRotate2.value) != "0": @@ -3643,11 +3647,11 @@ def writeLCD3(s, im, quality, SAVE=True): global SamsungDevice3 global MJPEGreader pic = None - if s.imWrite[im] == True: + if s.imWrite[im] is True: L4log("Ignore ImWrite", im) return s.imWrite[im] = True - if LCD4linux.LCDType3.value[0] in ["2", "3"] and virtBRI(3) not in [0, 10] and SAVE == True and LCD4linux.MJPEGvirtbri3.value == True: + if LCD4linux.LCDType3.value[0] in ["2", "3"] and virtBRI(3) not in [0, 10] and SAVE is True and LCD4linux.MJPEGvirtbri3.value is True: s.tmp[im] = ImageEnhance.Brightness(s.im[im]).enhance(virtBRI(3)) s.im[im] = s.tmp[im] bild = f"{PIC3tmp}.png" @@ -3655,7 +3659,7 @@ def writeLCD3(s, im, quality, SAVE=True): if SamsungDevice3 is not None: L4log("writing to DPF3 Device") doDPF(3, im, s) - if "3" in LCD4linux.SavePicture.value and SAVE == True: + if "3" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate3.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value), expand=True) try: @@ -3677,7 +3681,7 @@ def writeLCD3(s, im, quality, SAVE=True): L4log("writing TFT-LCD3") try: s.im[im].save("/tmp/usbtft-bmp", "BMP") - if "3" in LCD4linux.SavePicture.value and SAVE == True: + if "3" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate3.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value), expand=True) s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") @@ -3688,7 +3692,7 @@ def writeLCD3(s, im, quality, SAVE=True): elif LCD4linux.LCDType3.value[0] == "5": L4log("writing Internal-LCD3") try: - if "3" in LCD4linux.SavePicture.value and SAVE == True: + if "3" in LCD4linux.SavePicture.value and SAVE is True: if str(LCD4linux.LCDRotate3.value) != "0": s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value), expand=True) s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") @@ -3737,7 +3741,7 @@ def writeLCD3(s, im, quality, SAVE=True): except Exception: SamsungDevice3 = None L4log("Samsung 3 write Error") - if "3" in LCD4linux.SavePicture.value and SAVE == True: + if "3" in LCD4linux.SavePicture.value and SAVE is True: try: datei = f"{PIC3tmp}.jpg" if str(LCD4linux.LCDRotate3.value) != "0": @@ -3766,7 +3770,7 @@ def isMediaDisplay(player): def NextScreen(PRESS): global ScreenActive global ScreenTime - if SaveEventListChanged == True: + if SaveEventListChanged is True: L4logE("Event Change Aktive") return if (Standby.inStandby or ConfigStandby) and not isMediaDisplay(isMediaPlayer): @@ -3811,7 +3815,7 @@ def NextScreen(PRESS): ST = LCD4linux.ScreenTime9.value else: ST = "1" - if ScreenTime >= int(ST) and int(ST) > 0 or PRESS == True: + if ScreenTime >= int(ST) and int(ST) > 0 or PRESS is True: ScreenTime = 0 ScreenActive[0] = str(int(ScreenActive[0]) + 1) if (Standby.inStandby or ConfigStandby) and not isMediaDisplay(isMediaPlayer): @@ -3872,7 +3876,7 @@ def getBilder(): if isdir(BilderOrt[0]): L4log("read Pictures0") BilderIndex[0] = 0 - if LCD4linux.BilderRecursiv.value == False: + if LCD4linux.BilderRecursiv.value is False: for EXT in SuchExt: Bilder[0] += glob(f"{normpath(BilderOrt[0])}/{EXT}") else: @@ -3886,7 +3890,7 @@ def getBilder(): if isdir(BilderOrt[1]): L4log("read Pictures1") BilderIndex[1] = 0 - if LCD4linux.BilderRecursiv.value == False: + if LCD4linux.BilderRecursiv.value is False: for EXT in SuchExt: Bilder[1] += glob(f"{normpath(BilderOrt[1])}/{EXT}") else: @@ -3900,7 +3904,7 @@ def getBilder(): if isdir(BilderOrt[2]): L4log("read Pictures2") BilderIndex[2] = 0 - if LCD4linux.BilderRecursiv.value == False: + if LCD4linux.BilderRecursiv.value is False: for EXT in SuchExt: Bilder[2] += glob(f"{normpath(BilderOrt[2])}/{EXT}") else: @@ -4117,19 +4121,19 @@ def MJPEG_serve3(port): def MJPEG_start(): global MJPEGreader - if LCD4linux.MJPEGenable1.value == True and MJPEG[0][1] == "1": + if LCD4linux.MJPEGenable1.value is True and MJPEG[0][1] == "1": MJPEG[0] = MJPEG[0].replace("1", "A") MJPEGreader[1] = 0 th1 = Thread(target=MJPEG_serve1, args=[int(LCD4linux.MJPEGport1.value)]) th1.setDaemon(True) th1.start() - if LCD4linux.MJPEGenable2.value == True and MJPEG[0][2] == "2": + if LCD4linux.MJPEGenable2.value is True and MJPEG[0][2] == "2": MJPEG[0] = MJPEG[0].replace("2", "B") MJPEGreader[2] = 0 th2 = Thread(target=MJPEG_serve2, args=[int(LCD4linux.MJPEGport2.value)]) th2.setDaemon(True) th2.start() - if LCD4linux.MJPEGenable3.value == True and MJPEG[0][3] == "3": + if LCD4linux.MJPEGenable3.value is True and MJPEG[0][3] == "3": MJPEG[0] = MJPEG[0].replace("3", "C") MJPEGreader[3] = 0 th3 = Thread(target=MJPEG_serve3, args=[int(LCD4linux.MJPEGport3.value)]) @@ -4151,7 +4155,7 @@ def MJPEG_stop(force): try: if MJPEGserver[1] is not None: MJPEGrun[1] = 0 - if LCD4linux.LCDshutdown.value == True and force == 9: + if LCD4linux.LCDshutdown.value is True and force == 9: MAX_W, MAX_H = getResolution(LCD4linux.LCDType1.value, LCD4linux.LCDRotate1.value) MAX_W = int(MAX_W) MAX_H = int(MAX_H) @@ -4169,7 +4173,7 @@ def MJPEG_stop(force): try: if MJPEGserver[2] is not None: MJPEGrun[2] = 0 - if LCD4linux.LCDshutdown.value == True and force == 9: + if LCD4linux.LCDshutdown.value is True and force == 9: MAX_W, MAX_H = getResolution(LCD4linux.LCDType2.value, LCD4linux.LCDRotate2.value) MAX_W = int(MAX_W) MAX_H = int(MAX_H) @@ -4187,7 +4191,7 @@ def MJPEG_stop(force): try: if MJPEGserver[3] is not None: MJPEGrun[3] = 0 - if LCD4linux.LCDshutdown.value == True and force == 9: + if LCD4linux.LCDshutdown.value is True and force == 9: MAX_W, MAX_H = getResolution(LCD4linux.LCDType3.value, LCD4linux.LCDRotate3.value) MAX_W = int(MAX_W) MAX_H = int(MAX_H) @@ -4370,7 +4374,6 @@ def xmlDelete(Num): L4log("enable Screen", xl[i2]) xmlList[i] = xmlList[i].replace(f"\"L4L{xl[i2]}\"", f"\"{xl[i2]}\"") i = 0 - aa = 0 while i < len(xmlList): if xmlList[i].startswith(f"