diff --git a/lcd4linux/src/WebConfigSite.py b/lcd4linux/src/WebConfigSite.py index 531101f..a4bf105 100644 --- a/lcd4linux/src/WebConfigSite.py +++ b/lcd4linux/src/WebConfigSite.py @@ -76,10 +76,7 @@ class LCD4linuxConfigweb(resource.Resource): def __init__(self): self.StatusTimer = eTimer() - if DPKG: - self.StatusTimer_conn = self.StatusTimer.timeout.connect(self.resetWeb) - else: - self.StatusTimer.callback.append(self.resetWeb) + self.StatusTimer.callback.append(self.resetWeb) self.CurrentMode = ("-", "-") def resetWeb(self): @@ -328,7 +325,6 @@ def action(self, req): obja = eval(a) objb = eval(b) objb.value = obja.value - elif ".Standby" in _a: b = _a.replace(".Standby", ".") if (" " + b) in list(zip(*L2))[2]: @@ -428,7 +424,8 @@ def action(self, req): if Cfritz: rmFile(PICfritz) if Cwetter: - resetWetter(None) +# resetWetter(None) # action after changing weather parameters + pass if Cpicon: if len(LCD4linux.PiconCache.value) > 2: rmFiles(join(LCD4linux.PiconCache.value, "*.png")) @@ -508,18 +505,14 @@ def action(self, req): html += "\n" % _l(_("Save Config")) html += "\n" html += "
%s\n" % _l(_("Screen")) - html += "\n" for i in range(1, 10): html += "\n" % (i, AktiveScreen(str(i)), i) - Aktiv = "checked" if getSaveEventListChanged() else "" html += "" % ("unchecked") html += "" % (_l(_("stop Screencycle")), "checked", Aktiv) - html += "
\n" html += "\n" - html += "
" html += "
" html += "%s \n" % _l(_("Mode")) @@ -532,7 +525,6 @@ def action(self, req): if str(LCD4linux.Popup.value) != "0": html += "\n" % (AktiveMode("5", "Popup-Text")) html += "
\n" - if Mode != "5": if Mode == "1": L = L1 @@ -595,9 +587,7 @@ def action(self, req): for LL in L: Conf = LL[2].strip() ConfObj = eval(Conf) - if (Conf.startswith(Element) and (LL[3] == AktCode or AktCode == 0)) or (Element == "other" and LL[3] == 0): - if Mode in "2": if "." in Conf: b = Conf.replace(".", ".MP") diff --git a/lcd4linux/src/configOptions.py b/lcd4linux/src/configOptions.py index bcfd19d..a4c90e9 100644 --- a/lcd4linux/src/configOptions.py +++ b/lcd4linux/src/configOptions.py @@ -189,6 +189,7 @@ ['self.list1', 'MJPEG Cycle', ' LCD4linux.MJPEGCycle', 14], ['self.list1', 'MJPEG Restart on Error', ' LCD4linux.MJPEGRestart', 14], ['self.list1', 'MJPEG Header Mode', ' LCD4linux.MJPEGHeader', 14], + ['self.list1', 'Show Streams \'4097; 5001...5003\' in Mode', ' LCD4linux.Streaming', 0], ['self.list1', 'Sonos IP', ' LCD4linux.SonosIP', 19], ['self.list1', 'Sonos Ping Timeout [ms]', ' LCD4linux.SonosPingTimeout', 19], ['self.list1', 'Sonos Play Check', ' LCD4linux.SonosCheckTimer', 19], diff --git a/lcd4linux/src/data/skin_data.xml b/lcd4linux/src/data/skin_data.xml index f473969..672a2e0 100644 --- a/lcd4linux/src/data/skin_data.xml +++ b/lcd4linux/src/data/skin_data.xml @@ -48,6 +48,10 @@ + + + + diff --git a/lcd4linux/src/module.py b/lcd4linux/src/module.py index 0b0a1e9..4d5a0b6 100644 --- a/lcd4linux/src/module.py +++ b/lcd4linux/src/module.py @@ -3,6 +3,7 @@ # by joergm6 @ IHAD # for documentation look at IHAD Support Thread +from __future__ import print_function from os import popen from os.path import isfile, exists @@ -53,7 +54,7 @@ def get(self, element=None): def web(self, EX): try: exec("self.add('%s)" % EX.replace(",", "',", 1)) - except: + except Exception: print("[LCD4linuxE] Error: L4L Web-Elements") def getResolution(self, LCD): @@ -109,7 +110,7 @@ def setScreen(self, S, Lcd="", Hold=False): L4Lelement.Hold = Hold L4Lelement.Refresh = True - def resetBrightness(self, AKT=[]): + def resetBrightness(self, AKT=""): if len(AKT) == 3: L4Lelement.BrightAkt = AKT else: @@ -122,10 +123,10 @@ def setBrightness(self, LCD, BRI=-1): L4Lelement.Refresh = True def getBrightness(self, LCD=0, ORG=True): - if LCD > 0 and LCD < 4: - return L4Lelement.Bright[LCD - 1] if ORG == False else L4Lelement.BrightAkt[LCD - 1] + if int(LCD) > 0 and int(LCD) < 4: + return L4Lelement.Bright[int(LCD) - 1] if ORG == False else L4Lelement.BrightAkt[int(LCD) - 1] else: - return L4Lelement.Bright[0] if ORG == False else L4Lelement.BrightAkt[0] + return L4Lelement.Bright if ORG == False else L4Lelement.BrightAkt def getLcd(self): return L4Lelement.LCD @@ -146,7 +147,7 @@ def getstatusoutput(cmd): sts = 0 if text[-1:] == '\n': text = text[:-1] - except: + except Exception: sts = 1 text = "- -" print("[LCD4linux] Error on os-call") @@ -173,6 +174,6 @@ def L4LVtest(VV): f = open(L4Linfo % (O, P)) OO = f.readline().strip().split()[1].startswith(VV[1:]) f.close() - except: + except Exception: pass return OO diff --git a/lcd4linux/src/plugin.py b/lcd4linux/src/plugin.py index e0f1c88..34e75b7 100644 --- a/lcd4linux/src/plugin.py +++ b/lcd4linux/src/plugin.py @@ -22,7 +22,6 @@ from __future__ import print_function, absolute_import, division from base64 import b64encode from calendar import Calendar, mdays, weekday, weekheader, month_name -from codecs import decode from colorsys import rgb_to_hls, hls_to_rgb from ctypes.util import find_library from datetime import datetime, timedelta, date @@ -48,12 +47,12 @@ from re import findall, sub from requests import post, get, exceptions from simplejson import loads +from six import BytesIO, ensure_binary, ensure_str, PY3 from six.moves.queue import Queue from six.moves.socketserver import ThreadingMixIn from six.moves.urllib.parse import quote, urlparse, urlunparse from six.moves.urllib.request import urlopen, Request, urlretrieve from six.moves.BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler -from six import BytesIO, ensure_binary, ensure_str, PY3 from socket import setdefaulttimeout from struct import unpack from textwrap import TextWrapper, wrap @@ -82,6 +81,7 @@ from Components.Lcd import LCD from Components.MenuList import MenuList from Components.NimManager import nimmanager +from Components.Network import iNetwork from Components.Pixmap import Pixmap from Components.Renderer.Picon import getPiconName from Components.ServiceEventTracker import ServiceEventTracker @@ -97,6 +97,19 @@ from Tools.BoundFunction import boundFunction from Tools.Directories import SCOPE_PLUGINS, SCOPE_CONFIG, SCOPE_FONTS, SCOPE_LIBDIR, SCOPE_SYSETC, resolveFilename + +try: + from Components.SystemInfo import BoxInfo + IMAGEDISTRO = BoxInfo.getItem("distro") + MODEL = BoxInfo.getItem("machinebuild") + ARCH = BoxInfo.getItem("architecture") +except: + from boxbranding import getImageDistro, getBoxType, getImageArch + IMAGEDISTRO = getImageDistro() + MODEL = getBoxType() + ARCH = getImageArch() + + # PLUGIN IMPORTS from . import Photoframe, dpf, _ # for localized messages from .bluesound import BlueSound @@ -120,13 +133,6 @@ else: from html import unescape as _unescape -try: - DPKG = True - from Components.Network import iNetworkInfo -except Exception: - DPKG = False - from Components.Network import iNetwork - try: from enigma import iDVBFrontend feCable = iDVBFrontend.feCable @@ -166,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-r15" +Version = "V5.0-r22" L4LElist = L4Lelement() L4LdoThread = True LCD4enigma2config = resolveFilename(SCOPE_CONFIG) # /etc/enigma2/ @@ -205,7 +211,7 @@ PIC3 = join(TMPL, "dpf3") PIC3tmp = join(TMPL, "dpf3tmp") PICcal = None -PICwetter = [False, False] +PICwetter = [None, None] PICmeteo = join(TMPL, "dpfmeteo.png") PICfritz = join(TMPL, "dpffritz.png") HTTPpic = "%sdpfhttp%%d.jpg" % TMPL @@ -221,10 +227,10 @@ OSDon = 0 OSDtimer = -5 OSDdontshow = ["LCD4linux Settings", "Virtual Zap", "InfoBar", "Infobar", "SecondInfoBar", "FanControl2", "Mute", "LCD Text", "UnhandledKey", "QuickZap", "Volume", "PVRState"] -OSDdontskin = ["LCDdisplayFile", "VirtualZap", "InfoBar", "Infobar", "InfoBarSummary", "PictureInPicture", "SimpleSummary", "TimeshiftState", "InfoScreen", "Standby", "EMCMediaCenter", "InfoBarMoviePlayerSummary", "PVRState", "ResolutionLabel", "WidgetBackground", "camodogFSScreen2", "camodogFSmini"] +OSDdontskin = ["LCDdisplayFile", "VirtualZap", "InfoBar", "Infobar", "InfoBarSummary", "PictureInPicture", "SimpleSummary", "ScreenSummary", "TimeshiftState", "InfoScreen", "Standby", "EMCMediaCenter", "InfoBarMoviePlayerSummary", "PVRState", "ResolutionLabel", "WidgetBackground", "camodogFSScreen2", "camodogFSmini"] wwwWetter = ["", ""] -WetterTypeX = ["", ""] -WetterZoomX = [0, 0] +WetterType = ["", ""] +WetterZoom = [0, 0] OldTemp_c = -88 OldFeel = -88 OldHum = -88 @@ -409,7 +415,7 @@ LCD4linux.ServiceSearch = ConfigSelection(choices=[("0", _("Now/Next")), ("1", _("EPG"))], default="0") LCD4linux.ShowNoMsg = ConfigYesNo(default=True) LCD4linux.SavePicture = ConfigSelection(choices=[("0", _("no"))] + LCDSelect, default="123") -LCD4linux.NETworkCheckEnable = ConfigYesNo(default=True) +LCD4linux.NETworkCheckEnable = ConfigYesNo(default=False) LCD4linux.MJPEGenable1 = ConfigYesNo(default=False) LCD4linux.MJPEGenable2 = ConfigYesNo(default=False) LCD4linux.MJPEGenable3 = ConfigYesNo(default=False) @@ -423,6 +429,7 @@ LCD4linux.MJPEGHeader = ConfigSelection(choices=[("0", _("normal")), ("1", _("reduced"))], default="1") LCD4linux.MJPEGCycle = ConfigSelectionNumber(1, 10, 1, default=2) LCD4linux.MJPEGRestart = ConfigYesNo(default=True) +LCD4linux.Streaming = ConfigSelection(choices=[("0", _("Media")), ("1", _("On"))], default="0") LCD4linux.WebIfRefresh = ConfigSelectionNumber(1, 60, 1, default=3) LCD4linux.WebIfType = ConfigSelection(choices=[("0", _("Javascript")), ("01", _("Javascript no Refresh")), ("1", _("Reload"))], default="0") LCD4linux.WebIfInitDelay = ConfigYesNo(default=False) @@ -446,6 +453,7 @@ LCD4linux.WetterRainColor = ConfigSelection(choices=Farbe, default="silver") LCD4linux.WetterRainColor2use = ConfigSelectionNumber(10, 100, 10, default=80) LCD4linux.WetterRainColor2 = ConfigSelection(choices=Farbe, default="cyan") +LCD4linux.WetterHumColor = ConfigSelection(choices=Farbe, default="cyan") LCD4linux.WetterLine = ConfigSelection(choices=[("false", _("no")), ("true", _("yes, short")), ("trueLong", _("yes, long"))], default="trueLong") LCD4linux.WetterTrendArrows = ConfigYesNo(default=True) LCD4linux.WetterExtra = ConfigYesNo(default=True) @@ -2377,6 +2385,7 @@ def Code_utf8(wert): wert = "" if wert is None else _unescape(wert) return wert.replace('\x86', '').replace('\x87', '') if PY3 else wert.replace('\xc2\x86', '').replace('\xc2\x87', '').decode("utf-8", "ignore") + def L4log(nfo, wert=""): if str(LCD4linux.EnableEventLog.value) != "0": print("[LCD4linux] %s %s" % (nfo, wert)) @@ -2506,12 +2515,8 @@ def setPopText(w): def resetWetter(wetter): global wwwWetter global PICwetter - if wetter is None: - wwwWetter = ["", ""] - PICwetter = [False, False] - else: - wwwWetter[wetter] = "" - PICwetter[wetter] = False + wwwWetter = ["", ""] + PICwetter = [None, None] def resetCal(): @@ -2528,6 +2533,8 @@ def L4LoadNewConfig(cfg): if isfile(LCD4default): LCD4linux.loadFromFile(LCD4default) L4log("Config-Load", cfg) + if MODEL == 'vuduo2': # due to 2 displays, LCD4linux is integrated in this boximage + LCD4linux.loadFromFile("%sdefault.vuduo2" % LCD4data) L4log("Config-Load for 'Vu+ duo²'", cfg) LCD4linux.loadFromFile(cfg) LCD4linux.load() @@ -2830,7 +2837,7 @@ def ICSdownloads(): def getResolution(t, r): MAX_H, MAX_W = (0, 0) - if t[:1] == "5": + if t.startswith("5"): ttt = LCD4linux.xmlLCDType.value.split("x") MAX_W, MAX_H = int(ttt[0]), int(ttt[1]) if int(LCD4linux.xmlOffset.value) != 0: @@ -2863,7 +2870,7 @@ def getResolution(t, r): elif t[1:] == "21": MAX_W, MAX_H = 128, 128 else: - MAX_W, MAX_H = 100, 100 + MAX_W, MAX_H = 132, 64 if r in ["90", "270"]: MAX_W, MAX_H = MAX_H, MAX_W return MAX_W, MAX_H @@ -2975,15 +2982,14 @@ def getpiconres(x, y, full, picon, channelname, channelname2, P2, P2A, P2C): if not PY3: name2 = "%s.png" % channelname.decode("utf-8").encode("latin-1", "ignore") name4 = "%s.png" % channelname.decode("utf-8").encode("utf-8", "ignore") + name3 = "%s.png" % channelname2.replace('\xc2\x87', '').replace('\xc2\x86', '').decode("utf-8").encode("utf-8") + name = normalize('NFKD', unicode(str("" + channelname), 'utf-8', errors='ignore')).encode('ASCII', 'ignore') else: name2 = "%s.png" % channelname name4 = "%s.png" % channelname - name = normalize('NFKD', channelname) - name = sub(r'[^a-z0-9]', '', "%s.png" % str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) - if not PY3: - name3 = "%s.png" % channelname2.replace('\xc2\x87', '').replace('\xc2\x86', '').decode("utf-8").encode("utf-8") - else: name3 = "%s.png" % channelname2.replace('\x87', '').replace('\x86', '') + name = normalize('NFKD', str("" + channelname)) + name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) PIC.append(join(P2, name3)) PIC.append(join(P2, name2)) PIC.append(join(P2, name)) @@ -3098,9 +3104,9 @@ def writeHelligkeit(hell, night, STOP): if h3 == 0: R += "3" AktNight = night - if AktHelligkeit == [h1, h2, h3] + [L4LElist.getBrightness(0, False) and OSDtimer >= 0]: + if AktHelligkeit == [h1, h2, h3] + L4LElist.getBrightness(0, False) and OSDtimer >= 0: return R - AktHelligkeit = "%s %s" % ([h1, h2, h3], L4LElist.getBrightness(0, False)) + AktHelligkeit = [h1, h2, h3] + L4LElist.getBrightness(0, False) L4LElist.resetBrightness([h1, h2, h3]) L4log("write Bright", AktHelligkeit) if SamsungDevice is not None and LCD4linux.LCDType1.value[0] == "1": @@ -3159,8 +3165,8 @@ def writeHelligkeit(hell, night, STOP): try: with open("/dev/lcd2", 'w') as led_fd: ioctl(led_fd, 0x10, H) - except Exception: - L4log("Error LCD Communication") + except Exception as err: + L4log("Error LCD Communication: %s" % str(err)) return R @@ -3205,8 +3211,8 @@ def writeLCD1(s, im, quality, SAVE=True): s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(bild): rename(bild, "%s.png" % PIC) - except Exception: - L4log("Error write Picture") + except Exception as err: + L4log("Error write Picture: %s" % str(err)) elif LCD4linux.LCDType1.value[0] == "3": L4log("writing Picture") try: @@ -3214,8 +3220,8 @@ def writeLCD1(s, im, quality, SAVE=True): s.im[im].save(datei, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(datei): rename(datei, "%s.%s" % (PIC, LCD4linux.BilderTyp.value)) - except Exception: - L4log("Error write Picture") + except Exception as err: + L4log("Error write Picture: %s" % str(err)) elif LCD4linux.LCDType1.value[0] == "4": L4log("writing TFT-LCD") try: @@ -3226,8 +3232,8 @@ def writeLCD1(s, im, quality, SAVE=True): s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(bild): rename(bild, "%s.png" % PIC) - except Exception: - L4log("Error write Picture") + except Exception as err: + L4log("Error write Picture: %s" % str(err)) elif LCD4linux.LCDType1.value[0] == "5": L4log("writing Internal-LCD") try: @@ -3254,16 +3260,16 @@ def writeLCD1(s, im, quality, SAVE=True): s.im[im].save(xmlPICtmp, "PNG") if isfile(xmlPICtmp): rename(xmlPICtmp, xmlPIC) - except Exception: - L4log("Error write Picture") + except Exception as err: + L4log("Error write Picture: %s" % str(err)) elif LCD4linux.LCDType1.value[0] == "9": L4log("writing to Vu+ LCD") try: s.im[im].save(bild, "PNG") if isfile(bild): rename(bild, "%s.png" % PIC) - except Exception: - L4log("Error write Picture") + except Exception as err: + L4log("Error write Picture: %s" % str(err)) if pngutil and pngutilconnect != 0: pngutil.send("%s.png" % PIC) else: @@ -3277,9 +3283,9 @@ def writeLCD1(s, im, quality, SAVE=True): output.close() try: Photoframe.write_jpg2frame(SamsungDevice, pic) - except Exception: + except Exception as err: SamsungDevice = None - L4log("Samsung 1 write Error") + L4log("Samsung 1 write Error: %s" % str(err)) if "1" in LCD4linux.SavePicture.value and SAVE == True: try: datei = "%s.jpg" % PICtmp @@ -3290,8 +3296,8 @@ def writeLCD1(s, im, quality, SAVE=True): open(datei, "wb").write(pic) if isfile(datei): rename(datei, "%s.jpg" % PIC) - except Exception: - L4log("Error write Picture") + except Exception as err: + L4log("Error write Picture: %s" % str(err)) if LCD4linux.MJPEGenable1.value == True: if MJPEG[0][1] == "a": MJPEG_stop(1) @@ -3325,8 +3331,8 @@ def writeLCD2(s, im, quality, SAVE=True): s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(bild): rename(bild, "%s.png" % PIC2) - except Exception: - L4log("Error write Picture2") + except Exception as err: + L4log("Error write Picture2: %s" % str(err)) elif LCD4linux.LCDType2.value[0] == "3": L4log("writing Picture2") try: @@ -3334,8 +3340,8 @@ def writeLCD2(s, im, quality, SAVE=True): s.im[im].save(datei, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(datei): rename(datei, "%s.%s" % (PIC2, LCD4linux.BilderTyp.value)) - except Exception: - L4log("Error write Picture2") + except Exception as err: + L4log("Error write Picture2: %s" % str(err)) elif LCD4linux.LCDType2.value[0] == "4": L4log("writing TFT-LCD2") try: @@ -3346,8 +3352,8 @@ def writeLCD2(s, im, quality, SAVE=True): s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(bild): rename(bild, "%s.png" % PIC2) - except Exception: - L4log("Error write Picture2") + except Exception as err: + L4log("Error write Picture2: %s" % str(err)) elif LCD4linux.LCDType2.value[0] == "5": L4log("writing Internal-LCD2") try: @@ -3374,16 +3380,16 @@ def writeLCD2(s, im, quality, SAVE=True): s.im[im].save(xmlPICtmp, "PNG") if isfile(xmlPICtmp): rename(xmlPICtmp, xmlPIC) - except Exception: - L4log("Error write Picture2") + except Exception as err: + L4log("Error write Picture2: %s" % str(err)) elif LCD4linux.LCDType2.value[0] == "9": L4log("writing to Vu+ LCD2") try: s.im[im].save(bild, "PNG") if isfile(bild): rename(bild, "%s.png" % PIC2) - except Exception: - L4log("Error write Picture2") + except Exception as err: + L4log("Error write Picture2: %s" % str(err)) if pngutil and pngutilconnect != 0: pngutil.send("%s.png" % PIC2) else: @@ -3410,8 +3416,8 @@ def writeLCD2(s, im, quality, SAVE=True): open(datei, "wb").write(pic) if isfile(datei): rename(datei, "%s.jpg" % PIC2) - except Exception: - L4log("Error write Picture2") + except Exception as err: + L4log("Error write Picture2: %s" % str(err)) if LCD4linux.MJPEGenable2.value == True: if MJPEG[0][1] == "b": MJPEG_stop(2) @@ -3445,8 +3451,8 @@ def writeLCD3(s, im, quality, SAVE=True): s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(bild): rename(bild, "%s.png" % PIC3) - except Exception: - L4log("Error write Picture3") + except Exception as err: + L4log("Error write Picture3: %s" % str(err)) elif LCD4linux.LCDType3.value[0] == "3": L4log("writing Picture3") try: @@ -3454,8 +3460,8 @@ def writeLCD3(s, im, quality, SAVE=True): s.im[im].save(datei, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(datei): rename(datei, "%s.%s" % (PIC3, LCD4linux.BilderTyp.value)) - except Exception: - L4log("Error write Picture3") + except Exception as err: + L4log("Error write Picture3: %s" % str(err)) elif LCD4linux.LCDType3.value[0] == "4": L4log("writing TFT-LCD3") try: @@ -3466,8 +3472,8 @@ def writeLCD3(s, im, quality, SAVE=True): s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG") if isfile(bild): rename(bild, "%s.png" % PIC3) - except Exception: - L4log("Error write Picture3") + except Exception as err: + L4log("Error write Picture3: %s" % str(err)) elif LCD4linux.LCDType3.value[0] == "5": L4log("writing Internal-LCD3") try: @@ -3494,16 +3500,16 @@ def writeLCD3(s, im, quality, SAVE=True): s.im[im].save(xmlPICtmp, "PNG") if isfile(xmlPICtmp): rename(xmlPICtmp, xmlPIC) - except Exception: - L4log("Error write Picture3") + except Exception as err: + L4log("Error write Picture3: %s" % str(err)) elif LCD4linux.LCDType3.value[0] == "9": L4log("writing to Vu+ LCD3") try: s.im[im].save(bild, "PNG") if isfile(bild): rename(bild, "%s.png" % PIC3) - except Exception: - L4log("Error write Picture3") + except Exception as err: + L4log("Error write Picture3: %s" % str(err)) if pngutil and pngutilconnect != 0: pngutil.send("%s.png" % PIC3) else: @@ -3530,8 +3536,8 @@ def writeLCD3(s, im, quality, SAVE=True): open(datei, "wb").write(pic) if isfile(datei): rename(datei, "%s.jpg" % PIC3) - except Exception: - L4log("Error write Picture3") + except Exception as err: + L4log("Error write Picture3: %s" % str(err)) if LCD4linux.MJPEGenable3.value == True: if MJPEG[0][1] == "c": MJPEG_stop(3) @@ -4168,8 +4174,9 @@ def xmlClear(): def xmlRead(): global xmlList xmlList = [] - if isfile(join(LCD4enigma2config, "skin_user.xml")): - for i in open(LCD4enigma2config + "skin_user.xml").read().splitlines(): + xmlfile = join(LCD4enigma2config, "skin_user.xml") + if isfile(xmlfile): + for i in open(xmlfile).read().splitlines(): xmlList.append(i) if len(xmlList) > 1: while len(xmlList[-1]) < 2 and len(xmlList) > 1: @@ -4683,6 +4690,8 @@ def dataAvail(self, data): pass # Grab + + def doGrab(i, ConfigFast, ConfigSize): if getFB2(True): setFB2("0") @@ -5210,6 +5219,7 @@ def QuickBild(self, s): except Exception: pass + class LCDdisplayMenu(Screen): skin = """ @@ -5439,34 +5449,21 @@ def __init__(self, session, args=0): self.mtime3 = 0.0 self.toggle = time() - 0.5 # delay in order to avoid GUI-start in mode 'idle' self.picload = ePicLoad() - if DPKG: - self.picload_conn = self.picload.PictureData.connect(self.setPictureCB) - else: - self.picload.PictureData.get().append(self.setPictureCB) + self.picload.PictureData.get().append(self.setPictureCB) sc = AVSwitch().getFramebufferScale() self.picload.setPara((pic_w, pic_h, sc[0], sc[1], False, 1, '#00000000')) self.picload2 = ePicLoad() - if DPKG: - self.picload2_conn = self.picload2.PictureData.connect(self.setPictureCB2) - else: - self.picload2.PictureData.get().append(self.setPictureCB2) + self.picload2.PictureData.get().append(self.setPictureCB2) sc = AVSwitch().getFramebufferScale() self.picload2.setPara((pic_w, pic_h, sc[0], sc[1], False, 1, '#00000000')) self.picload3 = ePicLoad() - if DPKG: - self.picload3_conn = self.picload3.PictureData.connect(self.setPictureCB3) - else: - self.picload3.PictureData.get().append(self.setPictureCB3) + self.picload3.PictureData.get().append(self.setPictureCB3) sc = AVSwitch().getFramebufferScale() self.picload3.setPara((pic_w, pic_h, sc[0], sc[1], False, 1, '#00000000')) ConfigListScreen.__init__(self, self.list, on_change=self.selectionChanged) self.PicTimer = eTimer() - if DPKG: - self.PicTimer_conn = self.PicTimer.timeout.connect(self.showpic) - else: - self.PicTimer.callback.append(self.showpic) - + self.PicTimer.callback.append(self.showpic) self["introduction"] = StaticText() self["Version"] = StaticText((Version if L4LElist.getVersion() == True else Version + "") + " (" + _("Mode") + ": Py" + ("3" if PY3 else "2") + ")") self["LibUSB"] = StaticText() @@ -5477,7 +5474,6 @@ def __init__(self, session, args=0): self["LCD1text"] = StaticText() self["LCD2text"] = StaticText() self["LCD3text"] = StaticText() - self["key_red"] = Button(_("Cancel")) self["key_green"] = Button(_("Save")) self["key_yellow"] = Button(_("Restart Displays")) @@ -5744,10 +5740,11 @@ def SetList(self): self.list1.append(getConfigListEntry(_("- Rain Color"), LCD4linux.WetterRainColor)) self.list1.append(getConfigListEntry(_("- Rain use Color 2 from"), LCD4linux.WetterRainColor2use)) self.list1.append(getConfigListEntry(_("- Rain Color 2"), LCD4linux.WetterRainColor2)) + self.list1.append(getConfigListEntry(_("Weather Humidity Color"), LCD4linux.WetterHumColor)) self.list1.append(getConfigListEntry(_("Weather Lines"), LCD4linux.WetterLine)) self.list1.append(getConfigListEntry(_("Weather Trendarrows"), LCD4linux.WetterTrendArrows)) self.list1.append(getConfigListEntry(_("Weather Extra Infos"), LCD4linux.WetterExtra)) - if LCD4linux.WetterExtra.value == True: + if LCD4linux.WetterExtra.value: self.list1.append(getConfigListEntry(_("- Extra Zoom"), LCD4linux.WetterExtraZoom)) self.list1.append(getConfigListEntry(_("- Show chill temperature from difference"), LCD4linux.WetterExtraFeel)) self.list1.append(getConfigListEntry(_("- Extra Color City"), LCD4linux.WetterExtraColorCity)) @@ -5857,6 +5854,7 @@ def SetList(self): self.list1.append(getConfigListEntry(_("MJPEG Cycle"), LCD4linux.MJPEGCycle)) self.list1.append(getConfigListEntry(_("MJPEG Restart on Error"), LCD4linux.MJPEGRestart)) self.list1.append(getConfigListEntry(_("MJPEG Header Mode"), LCD4linux.MJPEGHeader)) + self.list1.append(getConfigListEntry(_("Show Streams '4097; 5001...5003' in Mode"), LCD4linux.Streaming)) self.list1.append(getConfigListEntry(_("Sonos IP"), LCD4linux.SonosIP)) self.list1.append(getConfigListEntry(_("Sonos Ping Timeout [ms]"), LCD4linux.SonosPingTimeout)) self.list1.append(getConfigListEntry(_("Sonos Play Check"), LCD4linux.SonosCheckTimer)) @@ -7843,7 +7841,7 @@ def keyOK(self): L4log("select File 5") self.session.openWithCallback(self.fileSelected, LCDdisplayFile, text=_("Choose file"), FileName=self["config"].getCurrent()[1].value, showFiles=True) except Exception as err: - L4log("Key-OK Config Fehler: %s" % err) + L4log("Key-OK Config Fehler: %s" % str(err)) def dirSelected(self, dir, dir1): if dir is None or dir1 is None: @@ -8036,12 +8034,12 @@ def selectionChanged(self): LCD4linux.Wetter2Coords.save() L4log("Weather2 city was changed from '%s' to '%s'" % (self.SaveWetter2, LCD4linux.Wetter2City.value)) resetWetter(1) - if LCD4linux.WetterIconZoom.isChanged() or LCD4linux.WetterRain.isChanged() or LCD4linux.WetterRainZoom.isChanged() or LCD4linux.WetterRainColor.isChanged() or LCD4linux.WetterRainColor2.isChanged() or LCD4linux.WetterRainColor2use.isChanged() or LCD4linux.WetterLine.isChanged() or LCD4linux.WetterTrendArrows.isChanged() or LCD4linux.WetterExtra.isChanged() or LCD4linux.WetterExtraColorFeel.isChanged() or LCD4linux.WetterExtraColorCity.isChanged() or LCD4linux.WetterExtraZoom.isChanged() or LCD4linux.WetterExtraFeel.isChanged() or LCD4linux.WetterWind.isChanged() or LCD4linux.WetterWindLines.isChanged() or LCD4linux.WetterLowColor.isChanged() or LCD4linux.WetterHighColor.isChanged() or LCD4linux.WetterTransparenz.isChanged(): - PICwetter = [False, False] + if LCD4linux.WetterIconZoom.isChanged() or LCD4linux.WetterRain.isChanged() or LCD4linux.WetterRainZoom.isChanged() or LCD4linux.WetterRainColor.isChanged() or LCD4linux.WetterRainColor2.isChanged() or LCD4linux.WetterRainColor2use.isChanged() or LCD4linux.WetterLine.isChanged() or LCD4linux.WetterTrendArrows.isChanged() or LCD4linux.WetterExtra.isChanged() or LCD4linux.WetterExtraColorFeel.isChanged() or LCD4linux.WetterExtraColorCity.isChanged() or LCD4linux.WetterExtraZoom.isChanged() or LCD4linux.WetterExtraFeel.isChanged() or LCD4linux.WetterWind.isChanged() or LCD4linux.WetterWindLines.isChanged() or LCD4linux.WetterLowColor.isChanged() or LCD4linux.WetterHighColor.isChanged() or LCD4linux.WetterTransparenz.isChanged() or LCD4linux.WetterHumColor.isChanged() or LCD4linux.WetterExtra.isChanged(): + PICwetter = [None, None] if LCD4linux.WetterZoom.isChanged() or LCD4linux.StandbyWetterZoom.isChanged() or LCD4linux.MPWetterZoom.isChanged() or LCD4linux.WetterType.isChanged() or LCD4linux.StandbyWetterType.isChanged() or LCD4linux.MPWetterType.isChanged() or LCD4linux.WetterColor.isChanged() or LCD4linux.StandbyWetterColor.isChanged() or LCD4linux.MPWetterColor.isChanged() or LCD4linux.WetterFont.isChanged() or LCD4linux.MPWetterFont.isChanged() or LCD4linux.StandbyWetterFont.isChanged() or LCD4linux.WetterShadow.isChanged() or LCD4linux.StandbyWetterShadow.isChanged() or LCD4linux.MPWetterShadow.isChanged(): - PICwetter[0] = False + PICwetter[0] = None if LCD4linux.Wetter2Zoom.isChanged() or LCD4linux.StandbyWetter2Zoom.isChanged() or LCD4linux.MPWetter2Zoom.isChanged() or LCD4linux.Wetter2Type.isChanged() or LCD4linux.StandbyWetter2Type.isChanged() or LCD4linux.MPWetter2Type.isChanged() or LCD4linux.Wetter2Color.isChanged() or LCD4linux.StandbyWetter2Color.isChanged() or LCD4linux.MPWetterColor.isChanged() or LCD4linux.Wetter2Font.isChanged() or LCD4linux.MPWetter2Font.isChanged() or LCD4linux.StandbyWetter2Font.isChanged() or LCD4linux.Wetter2Shadow.isChanged() or LCD4linux.StandbyWetter2Shadow.isChanged() or LCD4linux.MPWetter2Shadow.isChanged(): - PICwetter[1] = False + PICwetter[1] = None if self.SaveMeteo != LCD4linux.MeteoURL.value: self.SaveMeteo = LCD4linux.MeteoURL.value wwwMeteo = "" @@ -8097,6 +8095,7 @@ def LCDrestart(self): getSamsungDevice() TFTCheck(True) rmFile(CrashFile) + PICwetter = [None, None] rmFile("%stft.bmp" % TMPL) rmFiles(PIC + "*.*") if Briefkasten.qsize() <= 3: @@ -8213,7 +8212,6 @@ class UpdateStatus(Screen): def __init__(self, session): global ScreenActive Screen.__init__(self, session) - ScreenActive[0] = LCD4linux.ScreenActive.value self.NetatmoOK = NetatmoOK self.ServiceChangeRunning = False @@ -8360,10 +8358,7 @@ def __init__(self, session): self.NetworkConnectionAvailable = False try: if LCD4linux.NETworkCheckEnable.value == True: - if DPKG: - self.NetworkConnectionAvailable = iNetworkInfo.isConnected() - else: - iNetwork.checkNetworkState(self.checkNetworkCB) + iNetwork.checkNetworkState(self.checkNetworkCB) else: self.NetworkConnectionAvailable = None except Exception: @@ -8379,40 +8374,23 @@ def __init__(self, session): self.SonosTimer = eTimer() self.YMCastTimer = eTimer() self.BlueTimer = eTimer() - if DPKG: - self.StatusTimer_conn = self.StatusTimer.timeout.connect(self.updateStatus) - self.ServiceTimer_conn = self.ServiceTimer.timeout.connect(self.ServiceChange) - self.SamsungTimer_conn = self.SamsungTimer.timeout.connect(self.SamsungStart) - self.DpfTimer_conn = self.DpfTimer.timeout.connect(self.DpfStart) - self.QuickTimer_conn = self.QuickTimer.timeout.connect(self.QuickBildTimer) - self.CheckRefresh_conn = self.CheckRefresh.timeout.connect(self.CallCheckRefresh) - self.Later6Timer_conn = self.Later6Timer.timeout.connect(self.CallLater6) - self.SonosTimer_conn = self.SonosTimer.timeout.connect(self.getSonos) - self.YMCastTimer_conn = self.YMCastTimer.timeout.connect(self.getYMCast) - self.BlueTimer_conn = self.BlueTimer.timeout.connect(self.getBlue) - else: - self.StatusTimer.callback.append(self.updateStatus) - self.ServiceTimer.callback.append(self.ServiceChange) - self.SamsungTimer.callback.append(self.SamsungStart) - self.DpfTimer.callback.append(self.DpfStart) - self.QuickTimer.callback.append(self.QuickBildTimer) - self.CheckRefresh.callback.append(self.CallCheckRefresh) - self.Later6Timer.callback.append(self.CallLater6) - self.SonosTimer.callback.append(self.getSonos) - self.YMCastTimer.callback.append(self.getYMCast) - self.BlueTimer.callback.append(self.getBlue) + self.StatusTimer.callback.append(self.updateStatus) + self.ServiceTimer.callback.append(self.ServiceChange) + self.SamsungTimer.callback.append(self.SamsungStart) + self.DpfTimer.callback.append(self.DpfStart) + self.QuickTimer.callback.append(self.QuickBildTimer) + self.CheckRefresh.callback.append(self.CallCheckRefresh) + self.Later6Timer.callback.append(self.CallLater6) + self.SonosTimer.callback.append(self.getSonos) + self.YMCastTimer.callback.append(self.getYMCast) + self.BlueTimer.callback.append(self.getBlue) if GPjukeboxOK == True: CjukeboxEventNotifier.append(self.BPPlayerEvent) if BitrateRegistred == True: self.BitrateTimer = eTimer() - if DPKG: - self.BitrateTimer_conn = self.BitrateTimer.timeout.connect(self.runBitrateTimer) - else: - self.BitrateTimer.callback.append(self.runBitrateTimer) + self.BitrateTimer.callback.append(self.runBitrateTimer) self.BitrateTimer.startLongTimer(30) - - self.__event_tracker = ServiceEventTracker(screen = self, eventmap = - { + self.__event_tracker = ServiceEventTracker(screen=self, eventmap={ iPlayableService.evUpdatedInfo: self.restartTimer, iPlayableService.evUpdatedEventInfo: self.restartTimer, iPlayableService.evVideoSizeChanged: self.restartTimer @@ -8423,13 +8401,13 @@ def __init__(self, session): self.InstanceKeyPressed = eActionMap.getInstance().bindAction('', -0x7FFFFFFF, self.rcKeyPressed) self.recordtimer = session.nav.RecordTimer self.LastTimerlistUpdate = 0 - if str(LCD4linux.StandbyWetter.value) != "0" or str(LCD4linux.Wetter.value) != "0" or str(LCD4linux.MPWetter.value) != "0": + if (LCD4linux.StandbyWetter.value != "0" or LCD4linux.Wetter.value != "0" or LCD4linux.MPWetter.value != "0"): self.downloadWetter(LCD4linux.WetterCity.value, 0) - if str(LCD4linux.StandbyWetter2.value) != "0" or str(LCD4linux.Wetter2.value) != "0" or str(LCD4linux.MPWetter2.value) != "0": + if LCD4linux.StandbyWetter2.value != "0" or LCD4linux.Wetter2.value != "0" or LCD4linux.MPWetter2.value != "0": self.downloadWetter(LCD4linux.Wetter2City.value, 1) - if str(LCD4linux.StandbyMeteo.value) != "0" or str(LCD4linux.Meteo.value) != "0": + if LCD4linux.StandbyMeteo.value != "0" or LCD4linux.Meteo.value != "0": self.downloadMeteo() - if str(LCD4linux.ExternalIp.value) != "0" or str(LCD4linux.MPExternalIp.value) != "0" or str(LCD4linux.StandbyExternalIp.value) != "0": + if LCD4linux.ExternalIp.value != "0" or LCD4linux.MPExternalIp.value != "0" or LCD4linux.StandbyExternalIp.value != "0": self.ExternalIP = getExternalIP() self.timerlist = "" self.pluginlist = "" @@ -8482,10 +8460,7 @@ def onTunerCount(self): res_mgr = eDVBResourceManager.getInstance() if res_mgr: self.TunerCallBack = True - if DPKG: - self.frontendUseMaskChanged_conn = res_mgr.frontendUseMaskChanged.connect(self.tunerUseMaskChanged) - else: - res_mgr.frontendUseMaskChanged.get().append(self.tunerUseMaskChanged) + res_mgr.frontendUseMaskChanged.get().append(self.tunerUseMaskChanged) else: print("[ERROR]no res_mgr!!") @@ -8494,10 +8469,7 @@ def offTunerCount(self): res_mgr = eDVBResourceManager.getInstance() if res_mgr: self.TunerCallBack = False - if DPKG: - self.frontendUseMaskChanged_conn = None - else: - res_mgr.frontendUseMaskChanged.get().remove(self.tunerUseMaskChanged) + res_mgr.frontendUseMaskChanged.get().remove(self.tunerUseMaskChanged) else: print("[ERROR]no res_mgr!!") @@ -8986,10 +8958,10 @@ def updateStatus(self): self.SonosSoCo = None self.YMCastSoCo = None self.BlueSoCo = None - if str(LCD4linux.StandbyWetter.value) != "0" or str(LCD4linux.Wetter.value) != "0" or str(LCD4linux.MPWetter.value) != "0": + if LCD4linux.StandbyWetter.value != "0" or LCD4linux.Wetter.value != "0" or LCD4linux.MPWetter.value != "0": if strftime("%M") in ("35", "40", "55") or wwwWetter[0] == "": self.downloadWetter(LCD4linux.WetterCity.value, 0) - if str(LCD4linux.StandbyWetter2.value) != "0" or str(LCD4linux.Wetter2.value) != "0" or str(LCD4linux.MPWetter2.value) != "0": + if LCD4linux.StandbyWetter2.value != "0" or LCD4linux.Wetter2.value != "0" or LCD4linux.MPWetter2.value != "0": if strftime("%M") in ("35", "40", "55") or wwwWetter[1] == "": self.downloadWetter(LCD4linux.Wetter2City.value, 1) if strftime("%M") in LCD4linux.MailTime.value: @@ -9020,10 +8992,7 @@ def updateStatus(self): L4log("Error: Remove FritzCall", "%s" % FritzList) if self.NetworkConnectionAvailable is not None: L4log("check Network...") - if DPKG: - self.NetworkConnectionAvailable = iNetworkInfo.isConnected() - else: - iNetwork.checkNetworkState(self.checkNetworkCB) + iNetwork.checkNetworkState(self.checkNetworkCB) if str(LCD4linux.StandbyMeteo.value) != "0" or str(LCD4linux.Meteo.value) != "0": if divmod(int(strftime("%M")), 5)[1] == 0 or wwwMeteo.find("current_conditions") < 1: self.downloadMeteo() @@ -9386,16 +9355,10 @@ def runBitrateTimer(self): def stopBitrateData(self, TYP): L4logE("Bitrate Stop", TYP) if "V" in TYP and self.videoBitrate is not None: - if DPKG: - self.videoBitrate_conn = None - else: - self.videoBitrate.callback.remove(self.getVideoBitrateData) + self.videoBitrate.callback.remove(self.getVideoBitrateData) self.videoBitrate = None if "A" in TYP and self.audioBitrate is not None: - if DPKG: - self.audioBitrate_conn = None - else: - self.audioBitrate.callback.remove(self.getAudioBitrateData) + self.audioBitrate.callback.remove(self.getAudioBitrateData) self.audioBitrate = None def startBitrateData(self): @@ -9417,18 +9380,12 @@ def startBitrateData(self): apid = info.getInfo(iServiceInformation.sAudioPID) if vpid: self.videoBitrate = eBitrateCalculator(vpid, ref, 3000, 1024 * 1024) - if DPKG: - self.videoBitrate.callback = self.getVideoBitrateData - else: - self.videoBitrate.callback.append(self.getVideoBitrateData) + self.videoBitrate.callback.append(self.getVideoBitrateData) else: self.LvideoBitrate = "" if apid: self.audioBitrate = eBitrateCalculator(apid, ref, 3000, 64 * 1024) - if DPKG: - self.audioBitrate.callback = self.getVideoBitrateData - else: - self.audioBitrate.callback.append(self.getAudioBitrateData) + self.audioBitrate.callback.append(self.getAudioBitrateData) else: self.LaudioBitrate = "" else: @@ -9779,32 +9736,37 @@ def downloadWetter(self, ort, wetter): callInThread(getPage, self.feedurl, boundFunction(self.downloadOMcallback, wetter), self.downloadListError) elif LCD4linux.WetterApi.value == "OPENWEATHER": - apkey = "&appid=%s" % LCD4linux.WetterApiKeyOpenWeatherMap.value if len(LCD4linux.WetterApiKeyOpenWeatherMap.value) > 5 else "" - city = "id=%s" % quote(ort[3:]) if ort.startswith("wc:") else "q=%s" % quote(ort) - self.feedurl = "http://api.openweathermap.org/data/2.5/weather?%s&lang=%s&units=metric%s" % (city, la[:2], apkey) - L4logE("OWM-getcurrentweather%s: %s" % (wetter, self.feedurl)) - callInThread(getPage, self.feedurl, boundFunction(self.downloadOWMcallback, wetter), self.downloadListError) - self.feedurl = "https://api.openweathermap.org/data/2.5/onecall?&lon=%s&lat=%s&units=metric&exclude=hourly,minutely,current&lang=%s%s" % (self.Long[wetter], self.Lat[wetter], la[:2], apkey) - L4logE("OWM-getforecastweather%s: %s" % (wetter, self.feedurl)) - callInThread(getPage, self.feedurl, boundFunction(self.downloadOWMcallback, wetter), self.downloadListError) + if float(self.Long[wetter]) == 0 and float(self.Lat[wetter]) == 0: + self.feedurl = "https://geocoding-api.open-meteo.com/v1/search?language=%s&count=10&name=%s" % (la[:2], city) + L4logE("OWM-citysearch%s: %s" % (wetter, self.feedurl)) + callInThread(getPage, self.feedurl, boundFunction(self.getCityCoords, wetter), self.downloadListError) + else: + apkey = LCD4linux.WetterApiKeyOpenWeatherMap.value if len(LCD4linux.WetterApiKeyOpenWeatherMap.value) > 5 else "" + self.feedurl = "https://api.openweathermap.org/data/3.0/onecall?&lon=%s&lat=%s&units=metric&exclude=hourly,minutely,current&lang=%s&appid=%s" % (self.Long[wetter], self.Lat[wetter], la[:2], apkey) + L4logE("OWM-getOneCallWeather%s: %s" % (wetter, self.feedurl)) + callInThread(getPage, self.feedurl, boundFunction(self.downloadOWMcallback, wetter), self.downloadListError) elif LCD4linux.WetterApi.value == "WEATHERUNLOCKED": apkey = "?app_id=%s&app_key=%s" % (LCD4linux.WetterApiKeyWeatherUnlocked.value.split()[0], LCD4linux.WetterApiKeyWeatherUnlocked.value.split()[1]) if len(LCD4linux.WetterApiKeyWeatherUnlocked.value.split()) == 2 else "" lang = "&lang=%s" % ort.split(".")[0] if "." in ort else "" - self.feedurl = "http://api.weatherunlocked.com/api/current/%s%s%s" % (city, apkey, lang) + 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) + 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) - self.feedurl = "http://api.weatherunlocked.com/api/forecast/%s%s%s" % (city, apkey, lang) + if "." in city: # e.g. 'de.ZIPcode' + self.feedurl = "http://api.weatherunlocked.com/api/forecast/%s%s%s" % (city, apkey, lang) + 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) L4log("Wetter%s: downloadstart %s:%s %s %s" % (wetter, LCD4linux.WetterApi.value, ort, language.getLanguage(), la)) else: if self.NetworkConnectionAvailable is not None: L4log("Wetter%s: check Network..." % wetter) - if DPKG: - self.NetworkConnectionAvailable = iNetworkInfo.isConnected() - else: - iNetwork.checkNetworkState(self.checkNetworkCB) + iNetwork.checkNetworkState(self.checkNetworkCB) def downloadListError(self, error=""): L4log("Wetterdownload Error: %s" % error) @@ -9834,7 +9796,7 @@ def getCityCoords(self, ConfigWWW, jsonData): results = loads(jsonData).get("results", [None])[0] except Exception as err: self.WetterOK = False - L4log("Wetter%s-citysearch: invalid json data from MSN-server: %s" % (ConfigWWW, err)) + L4log("Wetter%s-citysearch: invalid json data from MSN-server: %s" % (ConfigWWW, str(err))) return if results: cityname = results["name"] if "name" in results else "" @@ -9849,7 +9811,7 @@ def getCityCoords(self, ConfigWWW, jsonData): def downloadMSNcallback(self, ConfigWWW, jsonData): iconmap = {"d000": "32", "d100": "34", "d200": "30", "d210": "12", "d211": "5", "d212": "14", "d220": "11", "d221": "42", - "d222": "16", "d240": "4", "d300": "28", "d310": "11", "d311": "5", "d312": "14", "d320": "39", "d321": "5", + "d222": "16", "d240": "4", "d300": "28", "d310": "11", "d311": "5", "d312": "14", "d320": "39", "d321": "5", "d322": "16", "d340": "4", "d400": "26", "d410": "9", "d411": "5", "d412": "14", "d420": "9", "d421": "5", "d422": "16", "d430": "12", "d431": "5", "d432": "15", "d440": "4", "d500": "28", "d600": "20", "d603": "10", "d605": "17", "d705": "17", "d900": "21", "d905": "17", "d907": "21", "n000": "31", "n100": "33", "n200": "29", @@ -9867,7 +9829,7 @@ def downloadMSNcallback(self, ConfigWWW, jsonData): try: r = loads(jsonData).get("responses", [None])[0] except Exception as err: - L4log("MSN-weather%s: json-download Error: %s" % (ConfigWWW, err)) + L4log("MSN-weather%s: json-download Error: %s" % (ConfigWWW, str(err))) return L4log("MSN-weather%s data ready" % ConfigWWW) L4logE("MSN-weather%s data: {placeholder for a large json-string}" % ConfigWWW) @@ -9889,7 +9851,7 @@ def downloadMSNcallback(self, ConfigWWW, jsonData): else: self.WDay[ConfigWWW]["Wind"] = "%.1f m/s %s" % (current.get("windSpd", 0) / 3.6, getDirection(current.get("windDir", "na"))) self.WDay[ConfigWWW]["Cond"] = current.get("pvdrCap", "") - self.WDay[ConfigWWW]["Icon"] = "%s.png" % iconmap.get(current.get("symbol", "")[:-1], "NA") # reduce MSN-code by 'windy'-flag + self.WDay[ConfigWWW]["Icon"] = "%s.png" % iconmap.get(current.get("symbol", "")[:4], "NA") # remove 'windy-flag' if present self.WDay[ConfigWWW]["Feel"] = "%.0f" % current.get("feels", 0) self.WDay[ConfigWWW]["Rain"] = "%.0f" % forecast[0].get("daily", {}).get("day", {}).get("precip", 0) self.WWeek[ConfigWWW] = [] @@ -9898,13 +9860,13 @@ def downloadMSNcallback(self, ConfigWWW, jsonData): Low = "%.0f" % forecast[idx].get("daily", {}).get("tempLo", 0) date = (currdate + timedelta(days=idx)).strftime("%Y-%m-%d") Day = datetime(int(date[:4]), int(date[5:7]), int(date[8:])).strftime("%a") - Icon = "%s.png" % iconmap.get(forecast[idx].get("daily", {}).get("symbol", "")[:-1], "NA") # reduce MSN-code by 'windy'-flag + Icon = "%s.png" % iconmap.get(forecast[idx].get("daily", {}).get("symbol", "")[:4], "NA") # remove 'windy-flag' if present Cond = forecast[idx].get("daily", {}).get("pvdrCap", "") Regen = "%.0f" % forecast[idx].get("daily", {}).get("day", {}).get("precip", 0) self.WWeek[ConfigWWW].append({"High": High, "Low": Low, "Day": Day, "Icon": Icon, "Cond": Cond, "Regen": Regen}) L4log("MSN-weather%s: completed!" % ConfigWWW) self.downloadSunrise() - PICwetter[ConfigWWW] = False + PICwetter[ConfigWWW] = None else: L4log("MSN-weather%s download Error: no data found." % ConfigWWW) @@ -9921,7 +9883,7 @@ def downloadOMcallback(self, ConfigWWW, jsonData): try: r = loads(jsonData) except Exception as err: - L4log("OM-weather%s: json-download Error: %s" % (ConfigWWW, err)) + L4log("OM-weather%s: json-download Error: %s" % (ConfigWWW, str(err))) return L4log("OM-weather%s data ready" % ConfigWWW) L4logE("OM-weather%s data: %s" % (ConfigWWW, r)) @@ -9961,7 +9923,7 @@ def downloadOMcallback(self, ConfigWWW, jsonData): self.WWeek[ConfigWWW].append({"High": High, "Low": Low, "Day": Day, "Icon": Icon, "Cond": Cond, "Regen": Regen}) L4log("OM-weather%s: completed!" % ConfigWWW) self.downloadSunrise() - PICwetter[ConfigWWW] = False + PICwetter[ConfigWWW] = None else: L4log("OM-weather%s download Error: no data found." % ConfigWWW) @@ -9981,7 +9943,7 @@ def downloadOWMcallback(self, ConfigWWW, jsonData): try: r = loads(jsonData) except Exception as err: - L4log("OWM-weather%s: json-download Error: %s" % (ConfigWWW, err)) + L4log("OWM-weather%s: json-download Error: %s" % (ConfigWWW, str(err))) return L4log("OMW-weather%s data ready" % ConfigWWW) L4logE("OMW-weather%s data: %s" % (ConfigWWW, r)) @@ -10003,7 +9965,7 @@ def downloadOWMcallback(self, ConfigWWW, jsonData): self.WDay[ConfigWWW]["Feel"] = "%.0f" % r.get("main", {}).get("feels_like", 0) self.WDay[ConfigWWW]["Rain"] = "%.0f" % (r.get("pop", 0) * 100) self.WDay[ConfigWWW]["Wtime"] = strftime("%H:%M"), localtime(r.get("dt", time())) - PICwetter[ConfigWWW] = False + PICwetter[ConfigWWW] = None elif r.get("daily", None) is not None: self.WetterOK = True L4log("OWM-weather%s: analysing forecasts..." % ConfigWWW) @@ -10017,7 +9979,7 @@ def downloadOWMcallback(self, ConfigWWW, jsonData): Cond = current.get("weather", [{}])[0].get("description", "") Regen = "%.0f" % (current.get("pop", 0) * 100) self.WWeek[ConfigWWW].append({"High": High, "Low": Low, "Day": Day, "Icon": Icon, "Cond": Cond, "Regen": Regen}) - PICwetter[ConfigWWW] = False + PICwetter[ConfigWWW] = None L4log("OWM-weather%s: completed!" % ConfigWWW) self.downloadSunrise() else: @@ -10061,7 +10023,7 @@ def downloadWUcallback(self, ConfigWWW, jsonData): rain = "%.0f" % r.get("prob_precip_pct", 0) self.WDay[ConfigWWW]["Rain"] = rain if rain.isdigit() else "0" # could be: "< 1" self.WDay[ConfigWWW]["Wtime"] = strftime("%H:%M", localtime()) - PICwetter[ConfigWWW] = False + PICwetter[ConfigWWW] = None elif r.get("Days", None) is not None: self.WetterOK = True L4log("WU-weather%s: analysing forecasts..." % ConfigWWW) @@ -10084,7 +10046,7 @@ def downloadWUcallback(self, ConfigWWW, jsonData): self.WWeek[ConfigWWW].append({"High": High, "Low": Low, "Day": Day, "Icon": Icon, "Cond": Cond, "Regen": Regen}) L4log("WU-weather%s: completed!" % ConfigWWW) self.downloadSunrise() - PICwetter[ConfigWWW] = False + PICwetter[ConfigWWW] = None else: wwwWetter[ConfigWWW] = "" L4log("WU-weather%s download Error: no data found" % ConfigWWW) @@ -10437,10 +10399,7 @@ def getSplit(ConfigSplit, ConfigAlign, MAX_W, w): def getFont(num): ff = [FONT, LCD4linux.Font1.value, LCD4linux.Font2.value, LCD4linux.Font3.value, LCD4linux.Font4.value, LCD4linux.Font5.value] - if ff[int(num)].endswith(".ttf") and isfile(ff[int(num)]): - return ff[int(num)] - else: - return FONT + return ff[int(num)] if ff[int(num)].endswith(".ttf") and isfile(ff[int(num)]) else FONT def getMem(): @@ -10871,16 +10830,17 @@ def getShowCover(BildFile): P2A = LCD4linux.PiconPathAlt.value PIC = [] PIC.append(join(P2, picon)) - name = normalize('NFKD', self.Lchannel_name) - name = sub(r'[^a-z0-9]', '', "%s.png" % str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if not PY3: name2 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("latin-1", "ignore") name4 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("utf-8", "ignore") name3 = "%s.png" % self.Lchannel_name2.replace('\xc2\x87', '').replace('\xc2\x86', '').decode("utf-8").encode("utf-8") + name = normalize('NFKD', unicode(str("" + self.Lchannel_name), 'utf-8', errors='ignore')).encode('ASCII', 'ignore') else: name2 = "%s.png" % self.Lchannel_name name4 = "%s.png" % self.Lchannel_name name3 = "%s.png" % self.Lchannel_name2.replace('\x87', '').replace('\x86', '') + name = normalize('NFKD', str("" + self.Lchannel_name)) + name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) PIC.append(join(P2, name3)) PIC.append(join(P2, name2)) PIC.append(join(P2, name)) @@ -10977,23 +10937,26 @@ def putWetter(workaround, draw, im): global OldFeel global OldHum global OldWind - MAX_W, MAX_H = (0, 0) + MAX_W, MAX_H = 0, 0 MAX_Wi, MAX_Hi = self.im[im].size if ConfigSplit == True: MAX_Wi = int(MAX_Wi / 2) Wim = 5 + int(ConfigWWW) - if PICwetter[ConfigWWW] is False or ConfigType != WetterTypeX[ConfigWWW] or ConfigZoom != WetterZoomX[ConfigWWW]: - PICwetter[ConfigWWW] = True + if PICwetter[ConfigWWW] is None or ConfigType != WetterType or ConfigZoom != WetterZoom: + PICwetter[ConfigWWW] = "wait" UseWetterPath = WetterPath if len(LCD4linux.WetterPath.value) > 2 and isfile(join(LCD4linux.WetterPath.value, "0.png")): UseWetterPath = LCD4linux.WetterPath.value - WetterTypeX[ConfigWWW] = ConfigType - WetterZoomX[ConfigWWW] = ConfigZoom + WetterType[ConfigWWW] = ConfigType + WetterZoom[ConfigWWW] = ConfigZoom POSX, POSY = 1, 0 Wmulti = ConfigZoom / 10.0 - if ConfigType[0] == "2": + largesize = ConfigType[0] != "3" + trendarrows = LCD4linux.WetterTrendArrows.value + MAX_Wr = 0 if trendarrows else int(12 * Wmulti) # reduce width of current weather frame when trendarrows are missing + if ConfigType.startswith("2"): MAX_H = int(175 * Wmulti) - elif ConfigType[0] == "4": + elif ConfigType.startswith("4"): MAX_H = int(25 * Wmulti) elif ConfigType == "5": MAX_H = int(54 * 6 * Wmulti) @@ -11003,27 +10966,34 @@ def putWetter(workaround, draw, im): MAX_H = int(80 * Wmulti) MAX_H += 2 if ConfigType == "1": - MAX_W = int(60 * 4 * Wmulti) + int(48 * 2 * Wmulti) + MAX_W = int(54 * 4 * Wmulti) + int(50 * 2 * Wmulti) - MAX_Wr + MAX_Wc = MAX_W elif ConfigType == "11": - MAX_W = int(60 * 5 * Wmulti) + int(48 * 2 * Wmulti) + MAX_W = int(54 * 5 * Wmulti) + int(50 * 2 * Wmulti) - MAX_Wr + MAX_Wc = MAX_W elif ConfigType == "12": - MAX_W = int(60 * 2 * Wmulti) + int(48 * 2 * Wmulti) - elif ConfigType == "22": - MAX_W = int(60 * 2 * Wmulti) + MAX_W = int(54 * 2 * Wmulti) + int(50 * 2 * Wmulti) - MAX_Wr + MAX_Wc = MAX_W elif ConfigType == "2": - MAX_W = int(60 * 4 * Wmulti) + MAX_W = int(55 * 4 * Wmulti) + MAX_Wc = int(50 * 2 * Wmulti) - MAX_Wr elif ConfigType == "21": - MAX_W = int(60 * 5 * Wmulti) + MAX_W = int(55 * 5 * Wmulti) + MAX_Wc = int(50 * 2 * Wmulti) - MAX_Wr + elif ConfigType == "22": + MAX_W = int(554 * 2 * Wmulti) + MAX_Wc = int(50 * 2 * Wmulti) - MAX_Wr elif ConfigType == "3": - MAX_W = int(60 * 2 * Wmulti) - elif ConfigType[0] == "4": - MAX_W = int(60 * Wmulti) - elif ConfigType[0] == "41": - MAX_W = int(60 * Wmulti) - elif ConfigType[0] == "5": - MAX_W = int(60 * 3 * Wmulti) + MAX_W = int(48 * 2 * Wmulti) - MAX_Wr + MAX_Wc = MAX_W + elif ConfigType.startswith("4"): + MAX_W = int(55 * Wmulti) + MAX_Wc = MAX_W + elif ConfigType.startswith("5"): + MAX_W = int(54 * 3 * Wmulti) + MAX_Wc = MAX_W POSX = int(54 * 2 * Wmulti) - POSY = 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": @@ -11041,12 +11011,12 @@ def putWetter(workaround, draw, im): Day = curr.get("Day", "") Icon = curr.get("Icon", "0") Cond = curr.get("Cond", "") - Regen = curr.get("Regen", "0") or "0" + Regen = curr.get("Regen", "0") if "." in Regen: Regen += "mm" if LCD4linux.WetterRain.value == "true2" else "" else: Regen += "%" if LCD4linux.WetterRain.value == "true2" else "" - if ConfigType[0] == "5": + if ConfigType.startswith("5"): font = ImageFont.truetype(ConfigFont, int(14 * Wmulti), encoding='unic') fontD = ImageFont.truetype(ConfigFont, int(14 * Wmulti), encoding='unic') else: @@ -11064,17 +11034,14 @@ def putWetter(workaround, draw, im): pil_image = pil_image.resize((int(int(LCD4linux.WetterIconZoom.value) * Wmulti), y)) else: pil_image = pil_image.resize((int(int(LCD4linux.WetterIconZoom.value) * Wmulti), y), Image.LANCZOS if PY3 else Image.ANTIALIAS) - if ConfigType[0] == "5": - PY = POSY - int(20 * Wmulti) - else: - PY = int(POSY + (int(40 * Wmulti) - y) / 2) + PY = POSY - int(20 * Wmulti) if ConfigType.startswith("5") else int(POSY + (int(40 * Wmulti) - y) / 2) PX = POSX + int((27 * Wmulti) - int(int(LCD4linux.WetterIconZoom.value) * Wmulti) / 2) self.im[Wim].paste(pil_image, (PX, PY + int(20 * Wmulti))) - if ConfigType[0] == "5": - Dayw, h = getFsize(Day, fontD) + if ConfigType.startswith("5"): if LCD4linux.WetterLine.value.startswith("true"): self.draw[Wim].line((10, POSY, MAX_W - 10, POSY), fill=ConfigColor) - PX = int(POSX - Dayw - (3 * Wmulti)) + w, h = getFsize(Day, fontD) + PX = int(POSX - w - (3 * Wmulti)) ShadowText(Wim, PX, POSY, Day, fontD, ConfigColor, ConfigShadow) w, h = getFsize("%s°" % High, font) PX = int(POSX - w - (3 * Wmulti)) @@ -11125,7 +11092,7 @@ def putWetter(workaround, draw, im): self.draw[Wim].line((POSX, 1, POSX, POSY + int(60 * Wmulti)), fill=ConfigColor) elif LCD4linux.WetterLine.value == "trueLong": self.draw[Wim].line((POSX, 1, POSX, POSY + int(80 * Wmulti)), fill=ConfigColor) - if ConfigType[0] == "5": + if ConfigType.startswith("5"): POSX = int(54 * 2 * Wmulti) POSY += int(54 * Wmulti) else: @@ -11136,7 +11103,7 @@ def putWetter(workaround, draw, im): elif LCD4linux.WetterLine.value == "trueLong": self.draw[Wim].line((POSX, 1, POSX, POSY + int(80 * Wmulti)), fill=ConfigColor) POSX += 1 - if ConfigType[0] == "2": + if ConfigType.startswith("2"): POSX = 1 POSY += int(80 * Wmulti) Hum = "?" @@ -11148,14 +11115,14 @@ def putWetter(workaround, draw, im): Wtime = "" if ConfigType == "3": POSY = int(-19 * Wmulti) - elif ConfigType[0] == "5": + elif ConfigType.startswith("5"): POSX, POSY = (int(54 * Wmulti), 1) if len(self.WDay[ConfigWWW]) != 0 and LCD4linux.WetterExtra.value == True: Locname = self.WDay[ConfigWWW].get("Locname", "") if len(self.WDay[ConfigWWW]) != 0: Temp_c = self.WDay[ConfigWWW].get("Temp_c", "0") cleanTemp_c = Temp_c - Hum = self.WDay[ConfigWWW].get("Hum", "0") + Hum = self.WDay[ConfigWWW].get("Hum", "0%") cleanHum = Hum.replace("%", "").strip() Feel = self.WDay[ConfigWWW].get("Feel", "0") cleanFeel = Feel @@ -11168,26 +11135,20 @@ def putWetter(workaround, draw, im): if Feel == "" or abs(int(round(float(Feel), 0) or "0") - int(round(float(Temp_c), 0) or "0")) < int(LCD4linux.WetterExtraFeel.value) or LCD4linux.WetterExtra.value == False: Feel = "" else: - Feelarrow = "" - if LCD4linux.WetterTrendArrows.value: - if OldFeel != -88: - Feelarrow = "▲" if OldFeel < float(Feel) else "▼" - else: - Feelarrow = "●" - OldFeel = float(cleanFeel) - Feel = "%s%s°" % (Feelarrow, Feel) - Temparrow = "" - if LCD4linux.WetterTrendArrows.value: - if OldTemp_c != -88: - Temparrow = "▲" if OldTemp_c < float(Temp_c) else "▼" - else: - Temparrow = "●" - OldTemp_c = float(cleanTemp_c) - Temp_c = "%s%s°" % (Temparrow, Temp_c) - if ConfigType[0] == "4": + if trendarrows: + Feelarrow = "●" if OldFeel == -88 else "▲" if OldFeel < float(Feel) else "▼" + OldFeel = float(cleanFeel) + Feel = "%s%s" % (Feelarrow, Feel) + Feel += "°" + if trendarrows: + Temparrow = "●" if OldTemp_c == -88 else "▲" if OldTemp_c < float(Temp_c) else "▼" + OldTemp_c = float(cleanTemp_c) + Temp_c = "%s%s" % (Temparrow, Temp_c) + Temp_c += "°" + if ConfigType.startswith("4"): if ConfigType == "4": Temp_c += "C" - TextSize = int((20 if LCD4linux.WetterTrendArrows.value else 25) * Wmulti) + TextSize = int(25 * Wmulti) font = ImageFont.truetype(ConfigFont, TextSize, encoding='unic') w, h = getFsize(Temp_c, font) while w > MAX_W: @@ -11200,89 +11161,91 @@ def putWetter(workaround, draw, im): if isfile(join(UseWetterPath, Icon)): pil_image = Image.open(join(UseWetterPath, Icon)).convert(imageMode) xx, yy = pil_image.size - if ConfigType[0] == "5": - y = int(float((int(LCD4linux.WetterIconZoom.value) + 30) * Wmulti) / xx * yy) + if ConfigType.startswith("5"): + y = int((int(LCD4linux.WetterIconZoom.value) + 5) * Wmulti / xx * yy) + x = int((int(LCD4linux.WetterIconZoom.value) + 5) * Wmulti) if str(LCD4linux.BilderQuality.value) == "0": - pil_image = pil_image.resize((int((int(LCD4linux.WetterIconZoom.value) + 30) * Wmulti), y)) + pil_image = pil_image.resize((x, y)) else: - pil_image = pil_image.resize((int((int(LCD4linux.WetterIconZoom.value) + 30) * Wmulti), y), Image.LANCZOS if PY3 else Image.ANTIALIAS) + pil_image = pil_image.resize((x, y), Image.LANCZOS if PY3 else Image.ANTIALIAS) xx, yy = pil_image.size - PY = 1 - int(20 * Wmulti) - POSX = MAX_W - xx + PY = 1 - int(10 * Wmulti) else: - y = int(float(int(LCD4linux.WetterIconZoom.value) * Wmulti) / xx * yy) + y = int((int(LCD4linux.WetterIconZoom.value) * Wmulti) / xx * yy) + x = int(int(LCD4linux.WetterIconZoom.value) * Wmulti) if str(LCD4linux.BilderQuality.value) == "0": - pil_image = pil_image.resize((int(int(LCD4linux.WetterIconZoom.value) * Wmulti) + 2, y)) + pil_image = pil_image.resize((x, y)) else: - pil_image = pil_image.resize((int(int(LCD4linux.WetterIconZoom.value) * Wmulti) + 2, y), Image.LANCZOS if PY3 else Image.ANTIALIAS) - PY = int(POSY + (int(40 * Wmulti) - y) / 2) - self.im[Wim].paste(pil_image, (POSX, PY + int(20 * Wmulti))) - POSXs, POSYs = (POSX, POSY + int(79 * Wmulti)) if ConfigType == "3" else (POSX, POSY) + pil_image = pil_image.resize((x, y), Image.LANCZOS if PY3 else Image.ANTIALIAS) + PY = int(POSY + (int(34 * Wmulti) - y) / 2) + self.im[Wim].paste(pil_image, (POSX, PY + int(20 * Wmulti))) + POSYs = POSY + {"2": 79, "1": 67}.get(LCD4linux.WetterWindLines.value, 56) * Wmulti if ConfigType.startswith("3") else POSY minus5 = -3 font = ImageFont.truetype(ConfigFont, int(((int(LCD4linux.WetterExtraZoom.value) - 100) / 20.0 + 8) * Wmulti), encoding='unic') - ShadowText(Wim, POSXs - minus5, POSYs, "%s %s" % (Locname, Wtime), font, LCD4linux.WetterExtraColorCity.value, ConfigShadow) - HumColor = LCD4linux.WetterRainColor.value if float(cleanHum) < int(LCD4linux.WetterRainColor2use.value) else LCD4linux.WetterRainColor2.value - Humarrow = "" - if LCD4linux.WetterTrendArrows.value: - if OldHum != -88: - Humarrow = "▲" if OldHum < float(cleanHum) else "▼" - else: - Humarrow = "●" - OldHum = float(cleanHum) - Hum = "%s%s" % (Humarrow, Hum) - Windarrow = "" - if LCD4linux.WetterTrendArrows.value: - if OldWind != -88: - Windarrow = "▲" if OldWind < float(cleanWind[0]) else "▼" - else: - Windarrow = "●" - OldWind = float(cleanWind[0]) - Wind = "%s%s" % (Windarrow, Wind) - if ConfigType[0] == "5": - font = ImageFont.truetype(ConfigFont, int(15 * Wmulti), encoding='unic') - w, h = getFsize(Cond, font) - PX = max(MAX_W - w - int(3 * Wmulti), 0) - ShadowText(Wim, PX, int(70 * Wmulti), Cond, font, ConfigColor, ConfigShadow) - w, h = getFsize(Wind, font) - ShadowText(Wim, MAX_W - w - int(3 * Wmulti), int(70 * Wmulti) + h, Wind, font, ConfigColor, ConfigShadow) - font = ImageFont.truetype(ConfigFont, int(35 * Wmulti), encoding='unic') - w, h = getFsize(Temp_c, font) + ShadowText(Wim, POSX - minus5, POSYs, "%s %s" % (Locname, Wtime), font, LCD4linux.WetterExtraColorCity.value, ConfigShadow) + if trendarrows: + Humarrow = "●" if OldHum == -88 else "▲" if OldHum < float(cleanHum) else "▼" + OldHum = float(cleanHum) + Hum = "%s%s" % (Humarrow, Hum) + if trendarrows: + Windarrow = "●" if OldWind == -88 else "▲" if OldWind < float(cleanWind[0]) else "▼" + OldWind = float(cleanWind[0]) + Wind = "%s%s" % (Windarrow, Wind) + + font = ImageFont.truetype(ConfigFont, int(13 * Wmulti), encoding='unic') + if LCD4linux.WetterWindLines.value == "2": + Wind = (Wind.split(" ", 2)) + for i in range(len(Wind), 3): + Wind.append("na") + ShadowText(Wim, POSX - minus5, POSY + int(56 * Wmulti), "%s %s" % (Wind[0], Wind[1]), font, ConfigColor, ConfigShadow) + ShadowText(Wim, POSX - minus5, POSY + int(67 * Wmulti), Wind[2], font, ConfigColor, ConfigShadow) + elif LCD4linux.WetterWindLines.value != "off": + ShadowText(Wim, POSX - minus5, POSY + int(56 * Wmulti), Wind, font, ConfigColor, ConfigShadow) + font = ImageFont.truetype(ConfigFont, int((24 if largesize else 20) * Wmulti), encoding='unic') + w, h = getFsize(Temp_c, font) + if not PY3: # for equal results, w needs an correction under Python 2 + w = int(w * (0.57 if trendarrows else 0.66)) + PX = MAX_Wc - int(w) + PY = POSY + int((8 if largesize else 16) * Wmulti) + ShadowText(Wim, PX, PY, Temp_c, font, LCD4linux.WetterHighColor.value, ConfigShadow) + + if LCD4linux.WetterRain.value != "false" and LCD4linux.WetterExtra.value: + if not ConfigType.startswith("4") and len(self.WWeek[ConfigWWW]) > 0: + Regen = self.WWeek[ConfigWWW][0].get("Regen", "0") + RColor = LCD4linux.WetterRainColor.value + if "." in Regen: + if float(Regen) * 10 >= int(LCD4linux.WetterRainColor2use.value): + RColor = LCD4linux.WetterRainColor2.value + Regen += "mm" if LCD4linux.WetterRain.value == "true2" else "" + else: + if int(Regen) >= int(LCD4linux.WetterRainColor2use.value): + RColor = LCD4linux.WetterRainColor2.value + Regen += "%" if LCD4linux.WetterRain.value == "true2" else "" + if float(Regen.replace("m", "").replace("%", "")) > 0: + font = ImageFont.truetype(ConfigFont, int(12 * Wmulti), encoding='unic') + PX = MAX_Wc - int(int(44 if trendarrows else 32) * Wmulti) - (0 if ConfigType.startswith("3") else int(8 * Wmulti)) + PY = POSY + int((34 if ConfigType.startswith("3") else 31) * Wmulti) + ShadowText(Wim, PX, PY, Regen, font, RColor, ConfigShadow) + + font = ImageFont.truetype(ConfigFont, int((15 if largesize else 12) * Wmulti), encoding='unic') + w, h = getFsize(Feel, font) if not PY3: # for equal results, w needs an correction under Python 2 - w = int(w * 0.65) - ShadowText(Wim, POSX - w - int(3 * Wmulti), POSY, Temp_c, font, LCD4linux.WetterHighColor.value, ConfigShadow) - w, h = getFsize(Temp_c[-1:], font) - font = ImageFont.truetype(ConfigFont, int((int(LCD4linux.WetterExtraZoom.value) / (8 if LCD4linux.WetterTrendArrows.value else 10) + 4) * Wmulti), encoding='unic') - wF, hF = getFsize(Feel, font) - ShadowText(Wim, POSX - w - int(3 * Wmulti), POSY + h - int(hF * 0.8), Feel, font, LCD4linux.WetterExtraColorFeel.value, ConfigShadow) - font = ImageFont.truetype(ConfigFont, int(15 * Wmulti), encoding='unic') - wH, hH = getFsize(Hum, font) - ShadowText(Wim, POSX - wH - int(3 * Wmulti), POSY + h + int(hF / 2), Hum, font, ConfigColor, ConfigShadow) - else: - font = ImageFont.truetype(ConfigFont, int(13 * Wmulti), encoding='unic') - if LCD4linux.WetterWindLines.value == "2": - Wind = (Wind.split(" ", 2)) - for i in range(len(Wind), 3): - Wind.append("na") - ShadowText(Wim, POSX - minus5, POSY + int(56 * Wmulti), "%s %s" % (Wind[0], Wind[1]), font, ConfigColor, ConfigShadow) - ShadowText(Wim, POSX - minus5, POSY + int(67 * Wmulti), Wind[2], font, ConfigColor, ConfigShadow) - elif LCD4linux.WetterWindLines.value != "off": - ShadowText(Wim, POSX - minus5, POSY + int(62 * Wmulti), Wind, font, ConfigColor, ConfigShadow) - font = ImageFont.truetype(ConfigFont, int((20 if LCD4linux.WetterTrendArrows.value else 25) * Wmulti), encoding='unic') - w, h = getFsize(Temp_c, font) - TempPosX = POSX + int(45 * Wmulti) - TempPosY = POSY + int((10 if LCD4linux.WetterWindLines.value == "2" and ConfigType[0] != "3" else 16) * Wmulti) - ShadowText(Wim, TempPosX, TempPosY, Temp_c, font, LCD4linux.WetterHighColor.value, ConfigShadow) - font = ImageFont.truetype(ConfigFont, int((14 if LCD4linux.WetterTrendArrows.value else 16) * Wmulti), encoding='unic') - wH, hH = getFsize(Hum, font) - HumPosY = POSY + int((12 if LCD4linux.WetterWindLines.value == "2" and ConfigType[0] != "3" else 20) * Wmulti) + h - ShadowText(Wim, TempPosX, HumPosY, Hum, font, HumColor, ConfigShadow) - if not PY3: # for equal results, wH needs an correction under Python 2 - wH = int(wH * 0.8) - font = ImageFont.truetype(ConfigFont, int(int(LCD4linux.WetterExtraZoom.value) / (16.0 if LCD4linux.WetterTrendArrows.value else 13.0) * Wmulti), encoding='unic') - ShadowText(Wim, TempPosX + int(wH * 0.8), HumPosY - int(hH * (0.57 if ConfigType[0] == "3" else 0.5)), Feel, font, LCD4linux.WetterExtraColorFeel.value, ConfigShadow) - PICwetter[ConfigWWW] = False + w = int(w * (0.58 if trendarrows else 0.67)) + PX = MAX_Wc - int(w) + PY = POSY + int((28 if largesize else 34) * Wmulti) + ShadowText(Wim, PX, PY, Feel, font, LCD4linux.WetterExtraColorFeel.value, ConfigShadow) + + font = ImageFont.truetype(ConfigFont, int((18 if largesize else 14) * Wmulti), encoding='unic') + w, h = getFsize(Hum, font) + if not PY3: # for equal results, w needs an correction under Python 2 + w = int(w * (0.72 if trendarrows else 0.98)) if largesize else int(w * (0.72 if trendarrows else 0.98)) + PX = MAX_Wc - int(w) + PY = POSY + int((40 if largesize else 44) * Wmulti) + ShadowText(Wim, PX, PY, Hum, font, LCD4linux.WetterHumColor.value, ConfigShadow) + + PICwetter[ConfigWWW] = 1 counter = 20 - while PICwetter[ConfigWWW] is True and counter > 0: + while PICwetter[ConfigWWW] == "wait" and counter > 0: L4logE("Weatherwait") sleep(0.03) counter -= 1 @@ -11424,25 +11387,17 @@ def putMoon(workaround, draw, im): INFOS = "" if ConfigInfo[2] == "1": MoonDist = MoonDistance() - MoonDistarrow = "" if ConfigTrends: - if OldMoonDist != -88: - MoonDistarrow = "▲" if OldMoonDist < MoonDist else "▼" - else: - MoonDistarrow = "●" - OldMoonDist = MoonDist - INFOS += "%s%s km" % (MoonDistarrow, round(MoonDist)) + MoonDistarrow = "●" if OldMoonDist == -88 else "▲" if OldMoonDist < MoonDist else "▼" + OldMoonDist = MoonDist + INFOS += "%s%s km" % (MoonDistarrow, round(MoonDist)) if ConfigInfo[1] == "1": illum = 100 - abs((cos(pi * POS) + 0j) ** 1.7 * 100) illum = abs(illum - 1) / .99 if illum - 1 > 0 else 0.0 - illumarrow = "" if ConfigTrends: - if Oldillum != -88: - illumarrow = "▲" if float(Oldillum) < illum else "▼" - else: - illumarrow = "●" - Oldillum = illum - INFOS += "- %s%s %%" % (illumarrow, round(illum, 1)) + illumarrow = "●" if Oldillum in [-88, 0] else "▲" if float(Oldillum) < illum else "▼" + Oldillum = illum + INFOS += "- %s%s %%" % (illumarrow, round(illum, 1)) if INFOS != "": w, h = getFsize(Code_utf8(INFOS), font) if w > ConfigSize: @@ -11582,7 +11537,7 @@ def putClock(workaround, draw, im): if ConfigSplit == True: MAX_W = int(MAX_W / 2) pp = ConfigPos - if ConfigType[0] == "4": + if ConfigType.startswith("4"): y = int(ConfigSize * 1.8) y271 = int(y / 2.71) if isfile(ClockBack) == True: @@ -11621,7 +11576,7 @@ def putClock(workaround, draw, im): ShadowText(draw, POSX + lx, ConfigPos + int((y / 1.14) - (h / 2)), now, font, ConfigColor, ConfigShadow) except Exception: pass - elif ConfigType[0] == "5": + elif ConfigType[0].startswith("5"): y = int(ConfigSize * 1.8) POSX = getSplit(ConfigSplit, ConfigAlign, MAX_W, y) pil_image = Clock + str(ConfigAnalog) + "/Clock.png" @@ -11695,7 +11650,7 @@ def putClock(workaround, draw, im): ShadowText(draw, x1, y1, now, font, ConfigColor, ConfigShadow) except Exception: pass - elif ConfigType[0] == "1": + elif ConfigType.startswith("1"): now = "" font = ImageFont.truetype(ConfigFont, ConfigSize, encoding='unic') ww, hS = getFsize(strftime("%H:%M"), font) @@ -11716,7 +11671,6 @@ def putClock(workaround, draw, im): elif tt == "3": font = ImageFont.truetype(ConfigFont, int(ConfigSize / 2.5), encoding='unic') now = Code_utf8(_(strftime("%A"))) - w, h = getFsize(now, font) lx = getSplit(ConfigSplit, ConfigAlign, MAX_W, w) if (ll + w / 2) < MAX_W and (ll - w / 2) > 0: @@ -12087,16 +12041,17 @@ def putPicon(workaround, draw, im): useCache = False PIC = [] PIC.append(join(P2, picon)) - name = normalize('NFKD', self.Lchannel_name if PY3 else self.Lchannel_name.decode('unicode-escape')) - name = sub(r'[^a-z0-9]', '', "%s.png" % str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) if not PY3: name2 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("latin-1", "ignore") - name4 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("latin-1", "ignore") + name4 = "%s.png" % self.Lchannel_name.decode("utf-8").encode("utf-8", "ignore") name3 = "%s.png" % self.Lchannel_name2.replace('\xc2\x87', '').replace('\xc2\x86', '').decode("utf-8").encode("utf-8") + name = normalize('NFKD', self.Lchannel_name.decode('unicode-escape')) else: name2 = "%s.png" % self.Lchannel_name name4 = "%s.png" % self.Lchannel_name name3 = "%s.png" % self.Lchannel_name2.replace('\x87', '').replace('\x86', '') + name = normalize('NFKD', self.Lchannel_name) + name = "%s.png" % sub(r'[^a-z0-9]', '', str(name).replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower()) name5 = getPiconName(self.LsreftoString) PIC.append(join(P2, name3)) PIC.append(join(P2, name2)) @@ -12314,11 +12269,11 @@ def putProgress(workaround, draw, im): elif ConfigType[0] in ["3", "5", "7"]: remaining = "%d%s" % (int(position[1] * 100 / length[1]), Prozent) w, h = getFsize(remaining, font) - if ConfigType[0] == "3": + if ConfigType.startswith("3"): ProgressBar -= (w + 10) Minus = 0 MinusProgress = 0 - elif ConfigType[0] == "7": + elif ConfigType.startswith("7"): Minus = -(ConfigSize - 2 + int((h - ConfigSize) / 2)) MinusProgress = (w + 10) else: @@ -12396,11 +12351,11 @@ def putProgress(workaround, draw, im): elif ConfigType[0] in ["3", "5", "7"]: remaining = "%d%s" % (int(event_run * 100 / duration), Prozent) w, h = getFsize(remaining, font) - if ConfigType[0] == "3": + if ConfigType.startswith("3"): ProgressBar -= (w + 10) Minus = 0 MinusProgress = 0 - elif ConfigType[0] == "7": + elif ConfigType.startswith("7"): Minus = -(ConfigSize - 2 + int((h - ConfigSize) / 2)) MinusProgress = (w + 10) else: @@ -12629,7 +12584,7 @@ def putSat(workaround, draw, im): font = ImageFont.truetype(ConfigFont, ConfigSize, encoding='unic') w, h = getFsize(Code_utf8(orbital), font) piconfile = join(LCD4linux.SatPath.value, "%s.png" % str(orbital).replace(".", "")) - if ConfigType[0] == "2" and isfile(piconfile): + if ConfigType.startswith("2") and isfile(piconfile): try: imW = Image.open(piconfile) xx, yy = imW.size @@ -12822,7 +12777,6 @@ def putTuner(workaround, draw, im): number = -1 if self.Ltuner_number is not None: number = self.Ltuner_number - i = "" Tcount = 0 font = ImageFont.truetype(ConfigFont, ConfigSize, encoding='unic') w, h = getFsize("A ", font) @@ -12851,10 +12805,7 @@ def putTuner(workaround, draw, im): for x in range(TunerCount): isON = True if TunerMask & count != 0: - if x == number: - c = LCD4linux.TunerColorActive.value - else: - c = LCD4linux.TunerColorOn.value + c = LCD4linux.TunerColorActive.value if x == number else LCD4linux.TunerColorOn.value else: c = LCD4linux.TunerColor.value isON = False @@ -12881,7 +12832,6 @@ def putInfo(workaround, draw, im): def NL(count): return "\n" if int(count) > 2 else "" - global CPUtotal global CPUidle MAX_W, MAX_H = self.im[im].size @@ -14056,7 +14006,7 @@ def putNetatmoIllu(workaround, draw, im): staerkeValOrg = staerkeVal2 staerke = staerkeVal2 dis_reason = Code_utf8(self.dis_reason[ConfigStation]) - if ConfigType[0] == "0": + if ConfigType.startswith("0"): if ConfigType[1:] == "9": S = 1.5 if ConfigSize <= 10 else 1.0 ZW = str(staerkeValOrg) # Value @@ -14073,7 +14023,7 @@ def putNetatmoIllu(workaround, draw, im): except Exception: pass self.draw[draw].rectangle((POSX, ConfigPos, POSX + ConfigLen, ConfigPos + ConfigSize), outline="yellow") - elif ConfigType[0] == "1": + elif ConfigType.startswith("1"): if isfile(join(LCD4data, "pointmask.png")): try: imM = Image.open(join(LCD4data, "pointmask.png")) @@ -14109,27 +14059,24 @@ def putCalendar(workaround, draw, im): if ConfigSplit == True: MAX_Wi = int(MAX_Wi / 2) if PICcal is not None and [ConfigType, ConfigTypeE, LCD4linux.CalDays.value] == CalType and ConfigZoom == CalZoom and [ConfigColor, ConfigBackColor, ConfigCaptionColor] == CalColor: - try: - x, y = self.im[4].size - POSX = getSplit(ConfigSplit, ConfigAlign, MAX_Wi, x) - if LCD4linux.CalTransparenz.value == "true": - self.im[im].paste(self.im[4], (POSX, ConfigPos), self.im[4]) - else: - self.im[im].paste(self.im[4], (POSX, ConfigPos)) - except Exception: - pass + x, y = self.im[4].size + POSX = getSplit(ConfigSplit, ConfigAlign, MAX_Wi, x) + if LCD4linux.CalTransparenz.value == "true": + self.im[im].paste(self.im[4], (POSX, ConfigPos), self.im[4]) + else: + self.im[im].paste(self.im[4], (POSX, ConfigPos)) else: POSX = 0 POSY = 0 ConfigSize = int(20 * ConfigZoom / 10) MAX_H = ConfigSize MAX_W = ConfigSize * 16 - if ConfigType[0] == "0": + if ConfigType.startswith("0"): MAX_H = ConfigSize * 9 - elif ConfigType[0] == "1": + elif ConfigType.startswith("1"): MAX_H = ConfigSize * 4 if ConfigTypeE[0] in ["C", "D"]: - if ConfigType[0] == "9": + if ConfigType.startswith("9"): MAX_W = ConfigSize * 25 MAX_H += ConfigSize * int(int(ConfigTypeE[1]) * 0.8) MAX_H += int(ConfigSize * 0.4) @@ -14167,7 +14114,7 @@ def putCalendar(workaround, draw, im): dd = 1 if day[0] == 0 else day[0] Week = date(datetime.now().year, datetime.now().month, dd).isocalendar()[1] PutWeek = False - if ConfigType[0] == "0" or (ConfigType[0] == "1" and ThisWeek == Week): + if ConfigType.startswith("0") or (ConfigType.startswith("1") and ThisWeek == Week): PutWeek = True Week = str(Week) w, h = getFsize(Week, font) @@ -14186,7 +14133,7 @@ def putCalendar(workaround, draw, im): if ConfigLayout in ["0", "2"]: if datetime.now().day == day[0]: self.draw[4].rectangle((PX1 - w1, POSY, PX1 + w1, POSY + h), fill=ConfigBackColor) - ShadowText(4, PX, POSY, Tag, font, ConfigColor if day[1] < 5 else LCD4linux.CalSaColor.value, ConfigShadow) + ShadowText(4, PX, POSY, Tag, font, ConfigColor if day[1] < 5 else LCD4linux.CalSaColor.value if day[1] == 5 else LCD4linux.CalSuColor.value, ConfigShadow) if ConfigLayout in ["0"] and ICS.get(ICStag, None) is not None: self.draw[4].rectangle((PX1 - w1, POSY, PX1 + w1, POSY + h), outline=CC[int(ICS[ICStag][0][2])]) if int(LCD4linux.CalLine.value) > 1: @@ -14199,7 +14146,7 @@ def putCalendar(workaround, draw, im): if int(LCD4linux.CalLine.value) > 1: self.draw[4].rectangle((PX1 - w1, POSY + h, PX1 + w1, POSY + h), outline=ConfigBackColor) else: - ShadowText(4, PX, POSY, Tag, font, ConfigColor if day[1] < 5 else LCD4linux.CalSaColor.value, ConfigShadow) + ShadowText(4, PX, POSY, Tag, font, ConfigColor if day[1] < 5 else LCD4linux.CalSaColor.value if day[1] == 5 else LCD4linux.CalSuColor.value, ConfigShadow) if ConfigLayout in ["1", "2"] and ICS.get(ICStag, None) is not None: self.draw[4].rectangle((PX1 - w1, POSY + h, PX1 + w1, POSY + h), outline=CC[int(ICS[ICStag][0][2])]) if int(LCD4linux.CalLine.value) > 1: @@ -14357,7 +14304,7 @@ def putRecording(workaround, draw, im): MAX_W, MAX_H = self.im[im].size POSX = None if self.LisRecording or ConfigMode == True: - if ConfigType[0] == "1": + if ConfigType.startswith("1"): self.draw[draw].ellipse((MAX_W - ConfigSize, -ConfigSize, MAX_W + ConfigSize, ConfigSize), fill="red") else: try: @@ -14376,7 +14323,7 @@ def putRecording(workaround, draw, im): except Exception: L4log("Error Recording Pic") if self.LisTimeshift and "t" in ConfigType: - if ConfigType[0] == "1": + if ConfigType.startswith("1"): for i in range(-1, 3): self.draw[draw].ellipse((MAX_W - ConfigSize - i, -ConfigSize - i, MAX_W + ConfigSize + i, ConfigSize + i), outline="yellow") else: @@ -14495,7 +14442,7 @@ def Lput4(LCD, SCR, FUNC, PARA): if not LCD4linux.Enable.value: return tt = time() -# L4logE("MP-Mode",isMediaPlayer) +# L4logE("MP-Mode", isMediaPlayer) L4log("creating LCD-Picture: %s" % ScreenActive) if isdir("%slcd4linux" % TMP) == False: try: @@ -14539,7 +14486,8 @@ def Lput4(LCD, SCR, FUNC, PARA): self.CoverName = ["-", "-"] elif sref.startswith(("4097:0", "5001:0", "5002:0", "5003:0")): if self.Lpath and self.Lpath.startswith("http") and self.Llength and self.Llength[0] == -1: - L4log("detected IPTV") + L4log("detected AudioMedia or IPTV") + isMediaPlayer = "mp3" else: L4log("detected VOD Media") isMediaPlayer = "mp3" @@ -15515,7 +15463,7 @@ def autostart(reason, **kwargs): def setup(menuid, **kwargs): - return [("LCD4Linux", main, "lcd4linux", None)] if menuid == "setup" else [] + return [("LCD4Linux", main, "lcd4linux", None)] if menuid == "setup" else [] def Plugins(**kwargs):