From 25ead9e12fe17f80eb9fdfe0758869830abe60a1 Mon Sep 17 00:00:00 2001 From: "Mr.Servo" Date: Sat, 19 Jul 2025 19:26:35 +0200 Subject: [PATCH 1/2] [LCD4linux] V5.0-r27 some improvements & bugfixes - code corrected so that it is Python2-compatible again - tiny bugfix for variables WetterType and WetterZoom - some code cleanup HINT: **LCD4linux** is still working under Python2 and Python3 --- lcd4linux/src/WebConfigSite.py | 69 +++++++++++++--------------------- lcd4linux/src/WebSite.py | 2 +- lcd4linux/src/plugin.py | 56 +++++++++++++-------------- 3 files changed, 55 insertions(+), 72 deletions(-) diff --git a/lcd4linux/src/WebConfigSite.py b/lcd4linux/src/WebConfigSite.py index a4bf105..a5dbc97 100644 --- a/lcd4linux/src/WebConfigSite.py +++ b/lcd4linux/src/WebConfigSite.py @@ -4,18 +4,22 @@ from os import stat from os.path import isfile, join, basename from six import PY2, ensure_str, ensure_binary +from time import time +from twisted.web import resource, http if PY2: from HTMLParser import HTMLParser _unescape = HTMLParser().unescape else: from html import unescape as _unescape -from time import time -from twisted.web import resource, http + from enigma import eTimer -from Components.config import ConfigSelection +from Components.config import ConfigSelection, ConfigYesNo, ConfigText, ConfigSlider, ConfigClock, ConfigPassword from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_CONFIG from .module import L4Lelement -from .plugin import * +from .plugin import L4log, L4logE, getScreenActive, setConfigMode, setisMediaPlayer, setConfigStandby, getConfigStandby, getisMediaPlayer, getBilder +from .plugin import L4LoadNewConfig, ConfTimeCheck, rmFile, rmFiles, setPopText, setScreenActive, getSaveEventListChanged, setSaveEventListChanged +from .plugin import getMJPEGreader, xmlRead, xmlWrite, xmlClear, xmlDelete, xmlSkin, MJPEG_stop, MJPEG_start, setFONT, resetWetter, resetCal +from .plugin import getWWW, getINFO, getTMPL, getConfigMode, PopText, Version, WWWpic, PICfritz, LCD4linux, LCD4config, CrashFile from . import _ from .configOptions import L1, L2, L3, L4 @@ -46,20 +50,12 @@ def _l(st): def AktiveMode(Test, R): - Aktiv = "" - Color = "" - if Mode == Test: - Aktiv = "checked" - Color = "style=\"color: #FFCC00\"" + Aktiv, Color = ("checked", 'style=\"color: #FFCC00\"') if Mode == Test else ("", "") return Aktiv, Color, R def AktiveElement(Test): - Aktiv = "" - Color = "" - if Element == Test: - Aktiv = "checked" - Color = "style=\"color: #FFCC00\"" + Aktiv, Color = ("checked", 'style=\"color: #FFCC00\"') if Element == Test else ("", "") return Aktiv, Color @@ -101,12 +97,7 @@ def render_POST(self, request): return self.action(request) def action(self, req): - global Mode - global ModeOld - global Element - global ElementList - global ExeMode - global StatusMode + global Mode, ModeOld, Element, ElementList, ExeMode, StatusMode IP = ensure_str(req.getClientIP()) IP = IP.split(":")[-1] L4logE("IP1:", IP) @@ -190,18 +181,16 @@ def action(self, req): req.setHeader('Content-Disposition', 'attachment;filename=lcd4config') req.setHeader('Content-Length', str(stat(lcd4config).st_size)) req.setHeader('charset', 'UTF-8') - f = open(lcd4config, "r") - html = f.read() - f.close() + with open(lcd4config, "r") as f: + html = f.read() return ensure_binary(html) if req.args.get(b"upload.y", None) is not None: L4log("WebIF: upload Config") lcd4config = "/tmp/test" data = req.args[b"uploadName"][0] if len(data) > 0 and data.startswith(b"config."): - f = open(lcd4config, "wb") - f.write(data) - f.close() + with open(lcd4config, "wb") as f: + f.write(data) if isfile(lcd4config): L4LoadNewConfig(lcd4config) else: @@ -221,9 +210,8 @@ def action(self, req): req.setHeader('Content-Disposition', 'attachment;filename=l4log.txt') req.setHeader('Content-Length', str(stat(lcd4config).st_size)) req.setHeader('charset', 'UTF-8') - f = open(lcd4config, "r") - html = f.read() - f.close() + with open(lcd4config, "r") as f: + html = f.read() return ensure_binary(html) if command is None: L4logE("no command") @@ -373,9 +361,8 @@ def action(self, req): #ConfigClock if isinstance(ConfObj, ConfigClock): t = val.split(":") - if len(t) == 2: - if t[0].isdigit() and t[1].isdigit(): - ConfObj.value = [int(t[0]), int(t[1])] + 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) @@ -459,7 +446,6 @@ def action(self, req): html += "vertical-align: middle; font-size:8px; }\n" html += "\n" if L4LElement.getRefresh() == True: - glob GI = getINFO().split() GR = min(int(float(GI[6])) + 1, 6) if len(GI) > 6 else 6 html += "\n" % GR @@ -551,7 +537,7 @@ def action(self, req): Conf = LL[2].strip() if Mode == "1": Conf = Conf[:13] - if ((LL[1][:1] != "-" and Mode != "1") or (Mode == "1" and Conf not in ElementList)) and LL[3] != 0: + if ((not LL[1].startswith("-") and Mode != "1") or (Mode == "1" and Conf not in ElementList)) and LL[3] != 0: if Element == "" or ModeOld != Mode: Element = "other" ModeOld = Mode @@ -604,14 +590,13 @@ def action(self, req): b = Conf.replace(".MP", ".Standby") if (" " + b) in list(zip(*L4))[2]: isSb = True - elif Mode in "4": - if ".Standby" in Conf: - b = Conf.replace(".Standby", ".") - if (" " + b) in list(zip(*L2))[2]: - isOn = True - b = Conf.replace(".Standby", ".MP") - if (" " + b) in list(zip(*L3))[2]: - isMP = True + elif Mode in "4" and ".Standby" in Conf: + b = Conf.replace(".Standby", ".") + if (" " + b) in list(zip(*L2))[2]: + isOn = True + b = Conf.replace(".Standby", ".MP") + if (" " + b) in list(zip(*L3))[2]: + isMP = True if AktCode == 0: AktCode = LL[3] Curr = ConfObj.value diff --git a/lcd4linux/src/WebSite.py b/lcd4linux/src/WebSite.py index 0283cb3..6e4dc5b 100644 --- a/lcd4linux/src/WebSite.py +++ b/lcd4linux/src/WebSite.py @@ -3,7 +3,7 @@ from os.path import isfile, getmtime from six import ensure_str, ensure_binary from twisted.web import resource -from .plugin import * +from .plugin import getConfigMode, getTMPL, LCD4linux class LCD4linuxweb(resource.Resource): diff --git a/lcd4linux/src/plugin.py b/lcd4linux/src/plugin.py index caf4312..2b90c9d 100644 --- a/lcd4linux/src/plugin.py +++ b/lcd4linux/src/plugin.py @@ -172,11 +172,7 @@ if find_library("usb-0.1") is not None or find_library("usb-1.0") is not None: print("[LCD4linux] libusb found :-)", getEnigmaVersionString()) USBok = True -elif ARCH in ("aarch64"): - get_backend(find_library=lambda x: "/lib64/libusb-1.0.so.0") - print("[LCD4linux] libusb found :-)", getEnigmaVersionString()) - USBok = True -Version = "V5.0-r25" +Version = "V5.0-r27"y L4LElist = L4Lelement() L4LdoThread = True LCD4enigma2config = resolveFilename(SCOPE_CONFIG) # /etc/enigma2/ @@ -233,8 +229,8 @@ OSDdontshow = ["LCD4linux Settings", "Virtual Zap", "InfoBar", "Infobar", "SecondInfoBar", "FanControl2", "Mute", "LCD Text", "UnhandledKey", "QuickZap", "Volume", "PVRState"] OSDdontskin = ["LCDdisplayFile", "VirtualZap", "InfoBar", "Infobar", "InfoBarSummary", "PictureInPicture", "SimpleSummary", "ScreenSummary", "TimeshiftState", "InfoScreen", "Standby", "EMCMediaCenter", "InfoBarMoviePlayerSummary", "PVRState", "ResolutionLabel", "WidgetBackground", "camodogFSScreen2", "camodogFSmini"] wwwWetter = ["", ""] -WetterType = ["", ""] -WetterZoom = [0, 0] +WetterType = "" +WetterZoom = 0 OldTemp_c = -88 OldFeel = -88 OldHum = -88 @@ -1745,7 +1741,7 @@ LCD4linux.MPCover = ConfigSelection(choices=ScreenSelect, default="0") LCD4linux.MPCoverLCD = ConfigSelection(choices=LCDSelect, default="1") LCD4linux.MPCoverPath1 = ConfigText(default="/tmp", fixed_size=False, visible_width=50) -LCD4linux.MPCoverPath2 = ConfigText(default="/tmp", fixed_size=False, visible_width=50) +LCD4linux.MPCoverPath2 = ConfigText(default="/media/hdd/movie/", fixed_size=False, visible_width=50) LCD4linux.MPCoverFile = ConfigText(default="/tmp/lcd4linux.jpg", fixed_size=False, visible_width=50) LCD4linux.MPCoverFile2 = ConfigText(default="/tmp/lcd4linux.jpg", fixed_size=False, visible_width=50) LCD4linux.MPCoverSize = ConfigSlider(default=240, increment=10, limits=(10, 1024)) @@ -9821,17 +9817,17 @@ def downloadWetter(self, ort, wetter): lang = "&lang=%s" % ort.split(".")[0] if "." in ort else "" city = LCD4linux.WetterCity.value if wetter == 0 else LCD4linux.Wetter2City.value if "." in city: # e.g. 'de.ZIPccode' - self.feedurl = "http://api.weatherunlocked.com/api/current/%s%s%s" % (city, apkey, lang) + feedurl = "http://api.weatherunlocked.com/api/current/%s" % city else: - self.feedurl = "http://api.weatherunlocked.com/api/current/%s,%s%s%s" % (self.Long[wetter], self.Lat[wetter], apkey, lang) - L4logE("WU-getcurrentweather%s: %s" % (wetter, self.feedurl)) - callInThread(getPage, self.feedurl, boundFunction(self.downloadWUcallback, wetter), self.downloadListError) - if "." in city: # e.g. 'de.ZIPcode' - self.feedurl = "http://api.weatherunlocked.com/api/forecast/%s%s%s" % (city, apkey, lang) + feedurl = "http://api.weatherunlocked.com/api/current/%s,%s" % (self.Long[wetter], self.Lat[wetter]) + L4logE("WU-getcurrentweather%s: %s" % (wetter, feedurl)) + callInThread(boundFunction(getPage, feedurl, params=params), boundFunction(self.downloadWUcallback, wetter), self.downloadListError) + if "." in ort: # e.g. 'de.ZIPcode' + feedurl = "http://api.weatherunlocked.com/api/forecast/%s" % city else: - self.feedurl = "http://api.weatherunlocked.com/api/forecast/%s,%s%s%s" % (self.Long[wetter], self.Lat[wetter], apkey, lang) - L4logE("WU-getforecastweather%s: %s" % (wetter, self.feedurl)) - callInThread(getPage, self.feedurl, boundFunction(self.downloadWUcallback, wetter), self.downloadListError) + feedurl = "http://api.weatherunlocked.com/api/forecast/%s,%s" % (self.Long[wetter], self.Lat[wetter]) + L4logE("WU-getforecastweather%s: %s" % (wetter, feedurl)) + callInThread(boundFunction(getPage, feedurl, params=params), boundFunction(self.downloadWUcallback, wetter), self.downloadListError) L4log("Wetter%s: downloadstart %s:%s %s %s" % (wetter, LCD4linux.WetterApi.value, ort, language.getLanguage(), la)) else: if self.NetworkConnectionAvailable is not None: @@ -10596,8 +10592,7 @@ def MoonPosition(now=None): def MoonPhase(pos): - index = (pos * float(8)) + float("0.5") - index = floor(index) + index = int(floor(pos * 8 + 0.5)) return { 0: _("New Moon"), 1: _("First Quarter"), @@ -11015,8 +11010,8 @@ def putWetter(workaround, draw, im): UseWetterPath = WetterPath if len(LCD4linux.WetterPath.value) > 2 and isfile(join(LCD4linux.WetterPath.value, "0.png")): UseWetterPath = LCD4linux.WetterPath.value - WetterType[ConfigWWW] = ConfigType - WetterZoom[ConfigWWW] = ConfigZoom + WetterType = ConfigType + WetterZoom = ConfigZoom POSX, POSY = 1, 0 Wmulti = ConfigZoom / 10.0 largesize = not ConfigType.startswith("3") @@ -11049,7 +11044,7 @@ def putWetter(workaround, draw, im): MAX_W = int(55 * 5 * Wmulti) MAX_Wc = int(50 * 2 * Wmulti) - MAX_Wr elif ConfigType == "22": - MAX_W = int(554 * 2 * Wmulti) + MAX_W = int(55 * 2 * Wmulti) MAX_Wc = int(50 * 2 * Wmulti) - MAX_Wr elif ConfigType == "3": MAX_W = int(48 * 2 * Wmulti) - MAX_Wr @@ -11062,16 +11057,19 @@ def putWetter(workaround, draw, im): MAX_Wc = MAX_W POSX = int(54 * 2 * Wmulti) POSY = int(40 * 2 * Wmulti) - imageMode = "RGBA" if LCD4linux.WetterTransparenz.value == "true" else "RGB" - self.im[Wim] = Image.new(imageMode, (MAX_W, MAX_H), (0, 0, 0, 0)) - if LCD4linux.WetterTransparenz.value == "crop": - POSXs = getSplit(ConfigSplit, ConfigAlign, MAX_Wi, MAX_W) - image_Back = self.im[im].crop((POSXs, ConfigPos, POSXs + MAX_W, ConfigPos + MAX_H)) - self.im[Wim].paste(image_Back, (0, 0)) + if LCD4linux.WetterTransparenz.value == "true": + self.im[Wim] = Image.new('RGBA', (MAX_W, MAX_H), (0, 0, 0, 0)) + else: + self.im[Wim] = Image.new('RGB', (MAX_W, MAX_H), (0, 0, 0, 0)) + if LCD4linux.WetterTransparenz.value == "crop": + POSXs = getSplit(ConfigSplit, ConfigAlign, MAX_Wi, MAX_W) + image_Back = self.im[im].crop((POSXs, ConfigPos, POSXs + MAX_W, ConfigPos + MAX_H)) + self.im[Wim].paste(image_Back, (0, 0)) self.draw[Wim] = ImageDraw.Draw(self.im[Wim]) if ConfigType != "3" and not ConfigType.startswith("4"): i = 0 for curr in self.WWeek[ConfigWWW]: + L4logE(str(curr)) if (i < 4 and ConfigType in ["1", "2", "5"]) or (i < 5 and ConfigType in ["11", "21", "51"]) or (i < 2 and ConfigType in ["12", "22"]): i += 1 High = curr.get("High", "0") @@ -11233,7 +11231,7 @@ def putWetter(workaround, draw, im): else: xx = yy = 20 if isfile(join(UseWetterPath, Icon)): - pil_image = Image.open(join(UseWetterPath, Icon)).convert(imageMode) + pil_image = Image.open(join(UseWetterPath, Icon)).convert("RGBA" if LCD4linux.WetterTransparenz.value == "true" else "RGB") xx, yy = pil_image.size if ConfigType.startswith("5"): y = int((int(LCD4linux.WetterIconZoom.value) + 5) * Wmulti / xx * yy) From 3cf3fbff8cd199f6afb972b5973691c6a29b83f4 Mon Sep 17 00:00:00 2001 From: Hains van den Bosch Date: Thu, 24 Jul 2025 08:18:07 +0200 Subject: [PATCH 2/2] LCD4Linux: Fix typo --- lcd4linux/src/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lcd4linux/src/plugin.py b/lcd4linux/src/plugin.py index 2b90c9d..1f2b0f8 100644 --- a/lcd4linux/src/plugin.py +++ b/lcd4linux/src/plugin.py @@ -172,7 +172,7 @@ if find_library("usb-0.1") is not None or find_library("usb-1.0") is not None: print("[LCD4linux] libusb found :-)", getEnigmaVersionString()) USBok = True -Version = "V5.0-r27"y +Version = "V5.0-r27" L4LElist = L4Lelement() L4LdoThread = True LCD4enigma2config = resolveFilename(SCOPE_CONFIG) # /etc/enigma2/