Skip to content

Commit 8cf68d6

Browse files
authored
Merge pull request #16 from Hains/python3
[LCD4linux] V5.0-r27 some improvements & bugfixes
2 parents a06bc41 + 3cf3fbf commit 8cf68d6

File tree

3 files changed

+55
-72
lines changed

3 files changed

+55
-72
lines changed

lcd4linux/src/WebConfigSite.py

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
44
from os import stat
55
from os.path import isfile, join, basename
66
from six import PY2, ensure_str, ensure_binary
7+
from time import time
8+
from twisted.web import resource, http
79
if PY2:
810
from HTMLParser import HTMLParser
911
_unescape = HTMLParser().unescape
1012
else:
1113
from html import unescape as _unescape
12-
from time import time
13-
from twisted.web import resource, http
14+
1415
from enigma import eTimer
15-
from Components.config import ConfigSelection
16+
from Components.config import ConfigSelection, ConfigYesNo, ConfigText, ConfigSlider, ConfigClock, ConfigPassword
1617
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_CONFIG
1718
from .module import L4Lelement
18-
from .plugin import *
19+
from .plugin import L4log, L4logE, getScreenActive, setConfigMode, setisMediaPlayer, setConfigStandby, getConfigStandby, getisMediaPlayer, getBilder
20+
from .plugin import L4LoadNewConfig, ConfTimeCheck, rmFile, rmFiles, setPopText, setScreenActive, getSaveEventListChanged, setSaveEventListChanged
21+
from .plugin import getMJPEGreader, xmlRead, xmlWrite, xmlClear, xmlDelete, xmlSkin, MJPEG_stop, MJPEG_start, setFONT, resetWetter, resetCal
22+
from .plugin import getWWW, getINFO, getTMPL, getConfigMode, PopText, Version, WWWpic, PICfritz, LCD4linux, LCD4config, CrashFile
1923
from . import _
2024

2125
from .configOptions import L1, L2, L3, L4
@@ -46,20 +50,12 @@ def _l(st):
4650

4751

4852
def AktiveMode(Test, R):
49-
Aktiv = ""
50-
Color = ""
51-
if Mode == Test:
52-
Aktiv = "checked"
53-
Color = "style=\"color: #FFCC00\""
53+
Aktiv, Color = ("checked", 'style=\"color: #FFCC00\"') if Mode == Test else ("", "")
5454
return Aktiv, Color, R
5555

5656

5757
def AktiveElement(Test):
58-
Aktiv = ""
59-
Color = ""
60-
if Element == Test:
61-
Aktiv = "checked"
62-
Color = "style=\"color: #FFCC00\""
58+
Aktiv, Color = ("checked", 'style=\"color: #FFCC00\"') if Element == Test else ("", "")
6359
return Aktiv, Color
6460

6561

@@ -101,12 +97,7 @@ def render_POST(self, request):
10197
return self.action(request)
10298

10399
def action(self, req):
104-
global Mode
105-
global ModeOld
106-
global Element
107-
global ElementList
108-
global ExeMode
109-
global StatusMode
100+
global Mode, ModeOld, Element, ElementList, ExeMode, StatusMode
110101
IP = ensure_str(req.getClientIP())
111102
IP = IP.split(":")[-1]
112103
L4logE("IP1:", IP)
@@ -190,18 +181,16 @@ def action(self, req):
190181
req.setHeader('Content-Disposition', 'attachment;filename=lcd4config')
191182
req.setHeader('Content-Length', str(stat(lcd4config).st_size))
192183
req.setHeader('charset', 'UTF-8')
193-
f = open(lcd4config, "r")
194-
html = f.read()
195-
f.close()
184+
with open(lcd4config, "r") as f:
185+
html = f.read()
196186
return ensure_binary(html)
197187
if req.args.get(b"upload.y", None) is not None:
198188
L4log("WebIF: upload Config")
199189
lcd4config = "/tmp/test"
200190
data = req.args[b"uploadName"][0]
201191
if len(data) > 0 and data.startswith(b"config."):
202-
f = open(lcd4config, "wb")
203-
f.write(data)
204-
f.close()
192+
with open(lcd4config, "wb") as f:
193+
f.write(data)
205194
if isfile(lcd4config):
206195
L4LoadNewConfig(lcd4config)
207196
else:
@@ -221,9 +210,8 @@ def action(self, req):
221210
req.setHeader('Content-Disposition', 'attachment;filename=l4log.txt')
222211
req.setHeader('Content-Length', str(stat(lcd4config).st_size))
223212
req.setHeader('charset', 'UTF-8')
224-
f = open(lcd4config, "r")
225-
html = f.read()
226-
f.close()
213+
with open(lcd4config, "r") as f:
214+
html = f.read()
227215
return ensure_binary(html)
228216
if command is None:
229217
L4logE("no command")
@@ -373,9 +361,8 @@ def action(self, req):
373361
#ConfigClock
374362
if isinstance(ConfObj, ConfigClock):
375363
t = val.split(":")
376-
if len(t) == 2:
377-
if t[0].isdigit() and t[1].isdigit():
378-
ConfObj.value = [int(t[0]), int(t[1])]
364+
if len(t) == 2 and t[0].isdigit() and t[1].isdigit():
365+
ConfObj.value = [int(t[0]), int(t[1])]
379366
if ConfObj.isChanged():
380367
ConfObj.save()
381368
L4log("Changed", a)
@@ -459,7 +446,6 @@ def action(self, req):
459446
html += "vertical-align: middle; font-size:8px; }\n"
460447
html += "</style>\n"
461448
if L4LElement.getRefresh() == True:
462-
glob
463449
GI = getINFO().split()
464450
GR = min(int(float(GI[6])) + 1, 6) if len(GI) > 6 else 6
465451
html += "<meta http-equiv=\"refresh\" content=\"%d\">\n" % GR
@@ -551,7 +537,7 @@ def action(self, req):
551537
Conf = LL[2].strip()
552538
if Mode == "1":
553539
Conf = Conf[:13]
554-
if ((LL[1][:1] != "-" and Mode != "1") or (Mode == "1" and Conf not in ElementList)) and LL[3] != 0:
540+
if ((not LL[1].startswith("-") and Mode != "1") or (Mode == "1" and Conf not in ElementList)) and LL[3] != 0:
555541
if Element == "" or ModeOld != Mode:
556542
Element = "other"
557543
ModeOld = Mode
@@ -604,14 +590,13 @@ def action(self, req):
604590
b = Conf.replace(".MP", ".Standby")
605591
if (" " + b) in list(zip(*L4))[2]:
606592
isSb = True
607-
elif Mode in "4":
608-
if ".Standby" in Conf:
609-
b = Conf.replace(".Standby", ".")
610-
if (" " + b) in list(zip(*L2))[2]:
611-
isOn = True
612-
b = Conf.replace(".Standby", ".MP")
613-
if (" " + b) in list(zip(*L3))[2]:
614-
isMP = True
593+
elif Mode in "4" and ".Standby" in Conf:
594+
b = Conf.replace(".Standby", ".")
595+
if (" " + b) in list(zip(*L2))[2]:
596+
isOn = True
597+
b = Conf.replace(".Standby", ".MP")
598+
if (" " + b) in list(zip(*L3))[2]:
599+
isMP = True
615600
if AktCode == 0:
616601
AktCode = LL[3]
617602
Curr = ConfObj.value

lcd4linux/src/WebSite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from os.path import isfile, getmtime
44
from six import ensure_str, ensure_binary
55
from twisted.web import resource
6-
from .plugin import *
6+
from .plugin import getConfigMode, getTMPL, LCD4linux
77

88

99
class LCD4linuxweb(resource.Resource):

lcd4linux/src/plugin.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,7 @@
172172
if find_library("usb-0.1") is not None or find_library("usb-1.0") is not None:
173173
print("[LCD4linux] libusb found :-)", getEnigmaVersionString())
174174
USBok = True
175-
elif ARCH in ("aarch64"):
176-
get_backend(find_library=lambda x: "/lib64/libusb-1.0.so.0")
177-
print("[LCD4linux] libusb found :-)", getEnigmaVersionString())
178-
USBok = True
179-
Version = "V5.0-r25"
175+
Version = "V5.0-r27"
180176
L4LElist = L4Lelement()
181177
L4LdoThread = True
182178
LCD4enigma2config = resolveFilename(SCOPE_CONFIG) # /etc/enigma2/
@@ -233,8 +229,8 @@
233229
OSDdontshow = ["LCD4linux Settings", "Virtual Zap", "InfoBar", "Infobar", "SecondInfoBar", "FanControl2", "Mute", "LCD Text", "UnhandledKey", "QuickZap", "Volume", "PVRState"]
234230
OSDdontskin = ["LCDdisplayFile", "VirtualZap", "InfoBar", "Infobar", "InfoBarSummary", "PictureInPicture", "SimpleSummary", "ScreenSummary", "TimeshiftState", "InfoScreen", "Standby", "EMCMediaCenter", "InfoBarMoviePlayerSummary", "PVRState", "ResolutionLabel", "WidgetBackground", "camodogFSScreen2", "camodogFSmini"]
235231
wwwWetter = ["", ""]
236-
WetterType = ["", ""]
237-
WetterZoom = [0, 0]
232+
WetterType = ""
233+
WetterZoom = 0
238234
OldTemp_c = -88
239235
OldFeel = -88
240236
OldHum = -88
@@ -1745,7 +1741,7 @@
17451741
LCD4linux.MPCover = ConfigSelection(choices=ScreenSelect, default="0")
17461742
LCD4linux.MPCoverLCD = ConfigSelection(choices=LCDSelect, default="1")
17471743
LCD4linux.MPCoverPath1 = ConfigText(default="/tmp", fixed_size=False, visible_width=50)
1748-
LCD4linux.MPCoverPath2 = ConfigText(default="/tmp", fixed_size=False, visible_width=50)
1744+
LCD4linux.MPCoverPath2 = ConfigText(default="/media/hdd/movie/", fixed_size=False, visible_width=50)
17491745
LCD4linux.MPCoverFile = ConfigText(default="/tmp/lcd4linux.jpg", fixed_size=False, visible_width=50)
17501746
LCD4linux.MPCoverFile2 = ConfigText(default="/tmp/lcd4linux.jpg", fixed_size=False, visible_width=50)
17511747
LCD4linux.MPCoverSize = ConfigSlider(default=240, increment=10, limits=(10, 1024))
@@ -9821,17 +9817,17 @@ def downloadWetter(self, ort, wetter):
98219817
lang = "&lang=%s" % ort.split(".")[0] if "." in ort else ""
98229818
city = LCD4linux.WetterCity.value if wetter == 0 else LCD4linux.Wetter2City.value
98239819
if "." in city: # e.g. 'de.ZIPccode'
9824-
self.feedurl = "http://api.weatherunlocked.com/api/current/%s%s%s" % (city, apkey, lang)
9820+
feedurl = "http://api.weatherunlocked.com/api/current/%s" % city
98259821
else:
9826-
self.feedurl = "http://api.weatherunlocked.com/api/current/%s,%s%s%s" % (self.Long[wetter], self.Lat[wetter], apkey, lang)
9827-
L4logE("WU-getcurrentweather%s: %s" % (wetter, self.feedurl))
9828-
callInThread(getPage, self.feedurl, boundFunction(self.downloadWUcallback, wetter), self.downloadListError)
9829-
if "." in city: # e.g. 'de.ZIPcode'
9830-
self.feedurl = "http://api.weatherunlocked.com/api/forecast/%s%s%s" % (city, apkey, lang)
9822+
feedurl = "http://api.weatherunlocked.com/api/current/%s,%s" % (self.Long[wetter], self.Lat[wetter])
9823+
L4logE("WU-getcurrentweather%s: %s" % (wetter, feedurl))
9824+
callInThread(boundFunction(getPage, feedurl, params=params), boundFunction(self.downloadWUcallback, wetter), self.downloadListError)
9825+
if "." in ort: # e.g. 'de.ZIPcode'
9826+
feedurl = "http://api.weatherunlocked.com/api/forecast/%s" % city
98319827
else:
9832-
self.feedurl = "http://api.weatherunlocked.com/api/forecast/%s,%s%s%s" % (self.Long[wetter], self.Lat[wetter], apkey, lang)
9833-
L4logE("WU-getforecastweather%s: %s" % (wetter, self.feedurl))
9834-
callInThread(getPage, self.feedurl, boundFunction(self.downloadWUcallback, wetter), self.downloadListError)
9828+
feedurl = "http://api.weatherunlocked.com/api/forecast/%s,%s" % (self.Long[wetter], self.Lat[wetter])
9829+
L4logE("WU-getforecastweather%s: %s" % (wetter, feedurl))
9830+
callInThread(boundFunction(getPage, feedurl, params=params), boundFunction(self.downloadWUcallback, wetter), self.downloadListError)
98359831
L4log("Wetter%s: downloadstart %s:%s %s %s" % (wetter, LCD4linux.WetterApi.value, ort, language.getLanguage(), la))
98369832
else:
98379833
if self.NetworkConnectionAvailable is not None:
@@ -10596,8 +10592,7 @@ def MoonPosition(now=None):
1059610592

1059710593

1059810594
def MoonPhase(pos):
10599-
index = (pos * float(8)) + float("0.5")
10600-
index = floor(index)
10595+
index = int(floor(pos * 8 + 0.5))
1060110596
return {
1060210597
0: _("New Moon"),
1060310598
1: _("First Quarter"),
@@ -11015,8 +11010,8 @@ def putWetter(workaround, draw, im):
1101511010
UseWetterPath = WetterPath
1101611011
if len(LCD4linux.WetterPath.value) > 2 and isfile(join(LCD4linux.WetterPath.value, "0.png")):
1101711012
UseWetterPath = LCD4linux.WetterPath.value
11018-
WetterType[ConfigWWW] = ConfigType
11019-
WetterZoom[ConfigWWW] = ConfigZoom
11013+
WetterType = ConfigType
11014+
WetterZoom = ConfigZoom
1102011015
POSX, POSY = 1, 0
1102111016
Wmulti = ConfigZoom / 10.0
1102211017
largesize = not ConfigType.startswith("3")
@@ -11049,7 +11044,7 @@ def putWetter(workaround, draw, im):
1104911044
MAX_W = int(55 * 5 * Wmulti)
1105011045
MAX_Wc = int(50 * 2 * Wmulti) - MAX_Wr
1105111046
elif ConfigType == "22":
11052-
MAX_W = int(554 * 2 * Wmulti)
11047+
MAX_W = int(55 * 2 * Wmulti)
1105311048
MAX_Wc = int(50 * 2 * Wmulti) - MAX_Wr
1105411049
elif ConfigType == "3":
1105511050
MAX_W = int(48 * 2 * Wmulti) - MAX_Wr
@@ -11062,16 +11057,19 @@ def putWetter(workaround, draw, im):
1106211057
MAX_Wc = MAX_W
1106311058
POSX = int(54 * 2 * Wmulti)
1106411059
POSY = int(40 * 2 * Wmulti)
11065-
imageMode = "RGBA" if LCD4linux.WetterTransparenz.value == "true" else "RGB"
11066-
self.im[Wim] = Image.new(imageMode, (MAX_W, MAX_H), (0, 0, 0, 0))
11067-
if LCD4linux.WetterTransparenz.value == "crop":
11068-
POSXs = getSplit(ConfigSplit, ConfigAlign, MAX_Wi, MAX_W)
11069-
image_Back = self.im[im].crop((POSXs, ConfigPos, POSXs + MAX_W, ConfigPos + MAX_H))
11070-
self.im[Wim].paste(image_Back, (0, 0))
11060+
if LCD4linux.WetterTransparenz.value == "true":
11061+
self.im[Wim] = Image.new('RGBA', (MAX_W, MAX_H), (0, 0, 0, 0))
11062+
else:
11063+
self.im[Wim] = Image.new('RGB', (MAX_W, MAX_H), (0, 0, 0, 0))
11064+
if LCD4linux.WetterTransparenz.value == "crop":
11065+
POSXs = getSplit(ConfigSplit, ConfigAlign, MAX_Wi, MAX_W)
11066+
image_Back = self.im[im].crop((POSXs, ConfigPos, POSXs + MAX_W, ConfigPos + MAX_H))
11067+
self.im[Wim].paste(image_Back, (0, 0))
1107111068
self.draw[Wim] = ImageDraw.Draw(self.im[Wim])
1107211069
if ConfigType != "3" and not ConfigType.startswith("4"):
1107311070
i = 0
1107411071
for curr in self.WWeek[ConfigWWW]:
11072+
L4logE(str(curr))
1107511073
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"]):
1107611074
i += 1
1107711075
High = curr.get("High", "0")
@@ -11233,7 +11231,7 @@ def putWetter(workaround, draw, im):
1123311231
else:
1123411232
xx = yy = 20
1123511233
if isfile(join(UseWetterPath, Icon)):
11236-
pil_image = Image.open(join(UseWetterPath, Icon)).convert(imageMode)
11234+
pil_image = Image.open(join(UseWetterPath, Icon)).convert("RGBA" if LCD4linux.WetterTransparenz.value == "true" else "RGB")
1123711235
xx, yy = pil_image.size
1123811236
if ConfigType.startswith("5"):
1123911237
y = int((int(LCD4linux.WetterIconZoom.value) + 5) * Wmulti / xx * yy)

0 commit comments

Comments
 (0)