diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2009-02-11 12:52:48 +0100 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2009-02-11 12:52:48 +0100 |
| commit | bbfcb7ea1f040d030277e2b6f2efa9ea0967bf2b (patch) | |
| tree | c5945c791698c14723e989449e6b4bfcc275c05d /lib/python/Components | |
| parent | 4f7990ff2a55874b9eb65e3c9cd47dacb9f76deb (diff) | |
| parent | 5e6f814d005a01caa437a532e61f4b338617ff67 (diff) | |
| download | enigma2-bbfcb7ea1f040d030277e2b6f2efa9ea0967bf2b.tar.gz enigma2-bbfcb7ea1f040d030277e2b6f2efa9ea0967bf2b.zip | |
Merge branch 'master' of /home/tmbinc/enigma2-git into tmbinc/FixTimingBugs
Conflicts:
lib/dvb/decoder.cpp
Diffstat (limited to 'lib/python/Components')
30 files changed, 1411 insertions, 442 deletions
diff --git a/lib/python/Components/AVSwitch.py b/lib/python/Components/AVSwitch.py index 8f99b98e..3188469a 100644 --- a/lib/python/Components/AVSwitch.py +++ b/lib/python/Components/AVSwitch.py @@ -1,33 +1,43 @@ from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, ConfigEnableDisable, ConfigSubsection, ConfigBoolean -from enigma import eAVSwitch +from enigma import eAVSwitch, getDesktop from SystemInfo import SystemInfo class AVSwitch: - INPUT = { "ENCODER": (0, 4), "SCART": (1, 3), "AUX": (2, 4) } - def setInput(self, input): - eAVSwitch.getInstance().setInput(self.INPUT[input][0]) - if self.INPUT[input][1] == 4: - aspect = self.getAspectRatioSetting() - self.setAspectWSS(aspect) - self.setAspectSlowBlank(aspect) - else: - eAVSwitch.getInstance().setSlowblank(self.INPUT[input][1]) - # FIXME why do we have to reset the colorformat? bug in avs-driver? - map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3} - eAVSwitch.getInstance().setColorFormat(map[config.av.colorformat.value]) + INPUT = { "ENCODER": 0, "SCART": 1, "AUX": 2 } + eAVSwitch.getInstance().setInput(INPUT[input]) def setColorFormat(self, value): eAVSwitch.getInstance().setColorFormat(value) def setAspectRatio(self, value): eAVSwitch.getInstance().setAspectRatio(value) - self.setAspectWSS(value) - self.setAspectSlowBlank(value) def setSystem(self, value): eAVSwitch.getInstance().setVideomode(value) + def getOutputAspect(self): + valstr = config.av.aspectratio.value + if valstr in ("4_3_letterbox", "4_3_panscan"): # 4:3 + return (4,3) + elif valstr == "16_9": # auto ... 4:3 or 16:9 + try: + aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read() + if aspect_str == "1": # 4:3 + return (4,3) + except IOError: + pass + elif valstr in ("16_9_always", "16_9_letterbox"): # 16:9 + pass + elif valstr in ("16_10_letterbox", "16_10_panscan"): # 16:10 + return (16,10) + return (16,9) + + def getFramebufferScale(self): + aspect = self.getOutputAspect() + fb_size = getDesktop(0).size() + return (aspect[0] * fb_size.height(), aspect[1] * fb_size.width()) + def getAspectRatioSetting(self): valstr = config.av.aspectratio.value if valstr == "4_3_letterbox": @@ -47,35 +57,12 @@ class AVSwitch: return val def setAspectWSS(self, aspect=None): - if aspect is None: - aspect = self.getAspectRatioSetting() - if aspect == 0 or aspect == 1: # letterbox or panscan - if not config.av.wss.value: - value = 0 # wss off - else: - value = 3 # 4:3_full_format - elif aspect == 2: # 16:9 - if not config.av.wss.value: - value = 2 # auto(4:3_off) - else: - value = 1 # auto - elif aspect == 3 or aspect == 6: # always 16:9 - value = 4 # 16:9_full_format - elif aspect == 4 or aspect == 5: # 16:10 - value = 10 # 14:9_full_format + if not config.av.wss.value: + value = 2 # auto(4:3_off) + else: + value = 1 # auto eAVSwitch.getInstance().setWSS(value) - def setAspectSlowBlank(self, aspect=None): - if aspect is None: - aspect = self.getAspectRatioSetting() - if aspect == 0 or aspect == 1: # letterbox or panscan - value = 2 # 12 V - elif aspect == 2: # 16:9 - value = 4 # auto - elif aspect == 3 or aspect == 4 or aspect == 5 or aspect == 6: # always 16:9 - value = 1 # 6V - eAVSwitch.getInstance().setSlowblank(value) - def InitAVSwitch(): config.av = ConfigSubsection() config.av.yuvenabled = ConfigBoolean(default=False) diff --git a/lib/python/Components/Console.py b/lib/python/Components/Console.py index c5fa5f98..f1f3fd95 100644 --- a/lib/python/Components/Console.py +++ b/lib/python/Components/Console.py @@ -8,7 +8,7 @@ class Console(object): self.callbacks = {} self.extra_args = {} - def ePopen(self, cmd, callback, extra_args=[]): + def ePopen(self, cmd, callback=None, extra_args=[]): name = cmd i = 0 while self.appContainers.has_key(name): @@ -21,7 +21,9 @@ class Console(object): self.appContainers[name] = eConsoleAppContainer() self.appContainers[name].dataAvail.append(boundFunction(self.dataAvailCB,name)) self.appContainers[name].appClosed.append(boundFunction(self.finishedCB,name)) - retval = self.appContainers[name].execute(cmd) + if isinstance(cmd, str): # until .execute supports a better api + cmd = [cmd] + retval = self.appContainers[name].execute(*cmd) if retval: self.finishedCB(name, retval) @@ -50,5 +52,6 @@ class Console(object): extra_args = self.extra_args[name] del self.appContainers[name] del self.extra_args[name] - self.callbacks[name](data,retval,extra_args) + if self.callbacks[name]: + self.callbacks[name](data,retval,extra_args) del self.callbacks[name] diff --git a/lib/python/Components/Converter/EventTime.py b/lib/python/Components/Converter/EventTime.py index 966f2ca8..41f1ebf3 100644 --- a/lib/python/Components/Converter/EventTime.py +++ b/lib/python/Components/Converter/EventTime.py @@ -1,7 +1,7 @@ from Converter import Converter from Poll import Poll from time import time -from Components.Element import cached +from Components.Element import cached, ElementError class EventTime(Poll, Converter, object): STARTTIME = 0 @@ -28,7 +28,7 @@ class EventTime(Poll, Converter, object): self.poll_interval = 30*1000 self.poll_enabled = True else: - raise str("'%s' is not <StartTime|EndTime|Remaining|Duration|Progress> for EventTime converter" % type) + raise ElementError("'%s' is not <StartTime|EndTime|Remaining|Duration|Progress> for EventTime converter" % type) @cached def getTime(self): diff --git a/lib/python/Components/Converter/MovieInfo.py b/lib/python/Components/Converter/MovieInfo.py index 068d24d3..be28dcce 100644 --- a/lib/python/Components/Converter/MovieInfo.py +++ b/lib/python/Components/Converter/MovieInfo.py @@ -1,5 +1,5 @@ from Components.Converter.Converter import Converter -from Components.Element import cached +from Components.Element import cached, ElementError from enigma import iServiceInformation from ServiceReference import ServiceReference @@ -16,7 +16,7 @@ class MovieInfo(Converter, object): elif type == "RecordServiceName": self.type = self.MOVIE_REC_SERVICE_NAME else: - raise str("'%s' is not <ShortDescription|MetaDescription|RecordServiceName> for MovieInfo converter" % type) + raise ElementError("'%s' is not <ShortDescription|MetaDescription|RecordServiceName> for MovieInfo converter" % type) Converter.__init__(self, type) @cached diff --git a/lib/python/Components/Converter/RemainingToText.py b/lib/python/Components/Converter/RemainingToText.py index adefe9cf..4249e30a 100644 --- a/lib/python/Components/Converter/RemainingToText.py +++ b/lib/python/Components/Converter/RemainingToText.py @@ -2,19 +2,43 @@ from Components.Converter.Converter import Converter from Components.Element import cached class RemainingToText(Converter, object): + DEFAULT = 0 + WITH_SECONDS = 1 + NO_SECONDS = 2 + def __init__(self, type): Converter.__init__(self, type) + if type == "WithSeconds": + self.type = self.WITH_SECONDS + elif type == "NoSeconds": + self.type = self.NO_SECONDS + else: + self.type = self.DEFAULT @cached def getText(self): - r = self.source.time - if r is None: + time = self.source.time + if time is None: return "" (duration, remaining) = self.source.time - if remaining is not None: - return "+%d min" % (remaining / 60) + + if self.type == self.WITH_SECONDS: + if remaining is not None: + return "%d:%02d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60), remaining % 60) + else: + return "%02d:%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60), duration % 60) + elif self.type == self.NO_SECONDS: + if remaining is not None: + return "+%d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60)) + else: + return "%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60)) + elif self.type == self.DEFAULT: + if remaining is not None: + return "+%d min" % (remaining / 60) + else: + return "%d min" % (duration / 60) else: - return "%d min" % (duration / 60) + return "???" text = property(getText) diff --git a/lib/python/Components/Converter/ServicePosition.py b/lib/python/Components/Converter/ServicePosition.py index b488258b..2bcc5492 100644 --- a/lib/python/Components/Converter/ServicePosition.py +++ b/lib/python/Components/Converter/ServicePosition.py @@ -1,7 +1,7 @@ from Converter import Converter from Poll import Poll from enigma import iPlayableService -from Components.Element import cached +from Components.Element import cached, ElementError class ServicePosition(Converter, Poll, object): TYPE_LENGTH = 0 @@ -19,6 +19,7 @@ class ServicePosition(Converter, Poll, object): self.negate = 'Negate' in args self.detailed = 'Detailed' in args self.showHours = 'ShowHours' in args + self.showNoSeconds = 'ShowNoSeconds' in args if self.detailed: self.poll_interval = 100 @@ -34,7 +35,7 @@ class ServicePosition(Converter, Poll, object): elif type == "Gauge": self.type = self.TYPE_GAUGE else: - raise "type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours}" + raise ElementError("type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|NoSeconds}") self.poll_enabled = self.type != self.TYPE_LENGTH @@ -94,9 +95,15 @@ class ServicePosition(Converter, Poll, object): if not self.detailed: if self.showHours: - return sign + "%d:%02d:%02d" % (l/3600, l%3600/60, l%60) + if self.showNoSeconds: + return sign + "%d:%02d" % (l/3600, l%3600/60) + else: + return sign + "%d:%02d:%02d" % (l/3600, l%3600/60, l%60) else: - return sign + "%d:%02d" % (l/60, l%60) + if self.showNoSeconds: + return sign + "%d" % (l/60) + else: + return sign + "%d:%02d" % (l/60, l%60) else: if self.showHours: return sign + "%d:%02d:%02d:%03d" % ((l/3600/90000), (l/90000)%3600/60, (l/90000)%60, (l%90000)/90) diff --git a/lib/python/Components/Converter/ServiceTime.py b/lib/python/Components/Converter/ServiceTime.py index 16bcae3a..89965067 100644 --- a/lib/python/Components/Converter/ServiceTime.py +++ b/lib/python/Components/Converter/ServiceTime.py @@ -1,5 +1,5 @@ from Converter import Converter -from Components.Element import cached +from Components.Element import cached, ElementError from enigma import iServiceInformation class ServiceTime(Converter, object): @@ -16,7 +16,7 @@ class ServiceTime(Converter, object): elif type == "Duration": self.type = self.DURATION else: - raise str("'%s' is not <StartTime|EndTime|Duration> for eEventTime converter" % type) + raise ElementError("'%s' is not <StartTime|EndTime|Duration> for eEventTime converter" % type) @cached def getTime(self): diff --git a/lib/python/Components/Converter/TemplatedMultiContent.py b/lib/python/Components/Converter/TemplatedMultiContent.py index a1b601d6..5f1d4f24 100644 --- a/lib/python/Components/Converter/TemplatedMultiContent.py +++ b/lib/python/Components/Converter/TemplatedMultiContent.py @@ -5,22 +5,27 @@ class TemplatedMultiContent(StringList): def __init__(self, args): StringList.__init__(self, args) from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_HALIGN_RIGHT, RT_VALIGN_TOP, RT_VALIGN_CENTER, RT_VALIGN_BOTTOM - from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmap, MultiContentEntryPixmapAlphaTest + from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmap, MultiContentEntryPixmapAlphaTest, MultiContentTemplateColor l = locals() del l["self"] # cleanup locals a bit del l["args"] self.template = eval(args, {}, l) + self.active_style = None assert "fonts" in self.template assert "itemHeight" in self.template - assert "template" in self.template + assert "template" in self.template or "templates" in self.template + assert "template" in self.template or "default" in self.template["templates"] # we need to have a default template + + if not "template" in self.template: # default template can be ["template"] or ["templates"]["default"] + self.template["template"] = self.template["templates"]["default"] def changed(self, what): if not self.content: from enigma import eListboxPythonMultiContent self.content = eListboxPythonMultiContent() self.content.setItemHeight(self.template["itemHeight"]) - self.content.setTemplate(self.template["template"]) + self.setTemplate() # also setup fonts (also given by source) index = 0 @@ -28,7 +33,28 @@ class TemplatedMultiContent(StringList): self.content.setFont(index, f) index += 1 + # if only template changed, don't reload list + if what[0] == self.CHANGED_SPECIFIC and what[1] == "style": + self.setTemplate() + return + if self.source: self.content.setList(self.source.list) + self.setTemplate() self.downstream_elements.changed(what) + + def setTemplate(self): + if self.source: + style = self.source.style + if style == self.active_style: + return # style did not change + + # if skin defined "templates", that means that it defines multiple styles in a dict. template should still be a default + templates = self.template.get("templates") + template = self.template.get("template") + + if templates and style: # if we have a custom style defined in the source, and different templates in the skin, look it up + template = templates.get(self.source.style, template) # default to default template + + self.content.setTemplate(template) diff --git a/lib/python/Components/Element.py b/lib/python/Components/Element.py index 2af57793..f4a8f127 100644 --- a/lib/python/Components/Element.py +++ b/lib/python/Components/Element.py @@ -16,6 +16,13 @@ def cached(f): return cache[name][1] return wrapper +class ElementError(Exception): + def __init__(self, message): + self.message = message + + def __str__(self): + return self.message + class Element(object): CHANGED_DEFAULT = 0 # initial "pull" state CHANGED_ALL = 1 # really everything changed diff --git a/lib/python/Components/EpgList.py b/lib/python/Components/EpgList.py index dbcd572b..8a7c8d45 100644 --- a/lib/python/Components/EpgList.py +++ b/lib/python/Components/EpgList.py @@ -52,6 +52,10 @@ class EPGList(HTMLComponent, GUIComponent): self.l.setBuildFunc(self.buildSimilarEntry) self.epgcache = eEPGCache.getInstance() self.clock_pixmap = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/icons/epgclock.png')) + self.clock_add_pixmap = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/icons/epgclock_add.png')) + self.clock_pre_pixmap = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/icons/epgclock_pre.png')) + self.clock_post_pixmap = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/icons/epgclock_post.png')) + self.clock_prepost_pixmap = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/icons/epgclock_prepost.png')) def getEventFromId(self, service, eventid): event = None @@ -60,7 +64,7 @@ class EPGList(HTMLComponent, GUIComponent): return event def getCurrentChangeCount(self): - if self.type == EPG_TYPE_MULTI: + if self.type == EPG_TYPE_MULTI and self.l.getCurrentSelection() is not None: return self.l.getCurrentSelection()[0] return 0 @@ -92,11 +96,12 @@ class EPGList(HTMLComponent, GUIComponent): def selectionChanged(self): for x in self.onSelChanged: if x is not None: - try: - x() - except: # FIXME!!! - print "FIXME in EPGList.selectionChanged" - pass + x() +# try: +# x() +# except: # FIXME!!! +# print "FIXME in EPGList.selectionChanged" +# pass GUI_WIDGET = eListbox @@ -135,8 +140,32 @@ class EPGList(HTMLComponent, GUIComponent): self.datetime_rect = Rect(width/20*2, 0, width/20*5-15, height) self.service_rect = Rect(width/20*7, 0, width/20*13, height) + def getClockPixmap(self, refstr, beginTime, duration, eventId): + pre_clock = 1 + post_clock = 2 + clock_type = 0 + endTime = beginTime + duration + for x in self.timer.timer_list: + if x.service_ref.ref.toString() == refstr: + if x.eit == eventId: + return self.clock_pixmap + beg = x.begin + end = x.end + if beginTime > beg and beginTime < end and endTime > end: + clock_type |= pre_clock + elif beginTime < beg and endTime > beg and endTime < end: + clock_type |= post_clock + if clock_type == 0: + return self.clock_add_pixmap + elif clock_type == pre_clock: + return self.clock_pre_pixmap + elif clock_type == post_clock: + return self.clock_post_pixmap + else: + return self.clock_prepost_pixmap + def buildSingleEntry(self, service, eventId, beginTime, duration, EventName): - rec=beginTime and (self.timer.isInTimer(eventId, beginTime, duration, service) > ((duration/10)*8)) + rec=beginTime and (self.timer.isInTimer(eventId, beginTime, duration, service)) r1=self.weekday_rect r2=self.datetime_rect r3=self.descr_rect @@ -145,14 +174,15 @@ class EPGList(HTMLComponent, GUIComponent): res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_RIGHT, self.days[t[6]])) res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r1.height(), 0, RT_HALIGN_RIGHT, "%02d.%02d, %02d:%02d"%(t[2],t[1],t[3],t[4]))) if rec: - res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, self.clock_pixmap)) + clock_pic = self.getClockPixmap(service, beginTime, duration, eventId) + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, clock_pic)) res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left() + 25, r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName)) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName)) return res def buildSimilarEntry(self, service, eventId, beginTime, service_name, duration): - rec=beginTime and (self.timer.isInTimer(eventId, beginTime, duration, service) > ((duration/10)*8)) + rec=beginTime and (self.timer.isInTimer(eventId, beginTime, duration, service)) r1=self.weekday_rect r2=self.datetime_rect r3=self.service_rect @@ -161,22 +191,24 @@ class EPGList(HTMLComponent, GUIComponent): res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_RIGHT, self.days[t[6]])) res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r1.height(), 0, RT_HALIGN_RIGHT, "%02d.%02d, %02d:%02d"%(t[2],t[1],t[3],t[4]))) if rec: - res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, self.clock_pixmap)) + clock_pic = self.getClockPixmap(service, beginTime, duration, eventId) + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, clock_pic)) res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left() + 25, r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, service_name)) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, service_name)) return res def buildMultiEntry(self, changecount, service, eventId, begTime, duration, EventName, nowTime, service_name): - rec=begTime and (self.timer.isInTimer(eventId, begTime, duration, service) > ((duration/10)*8)) + rec=begTime and (self.timer.isInTimer(eventId, begTime, duration, service)) r1=self.service_rect r2=self.progress_rect r3=self.descr_rect r4=self.start_end_rect res = [ None ] # no private data needed if rec: + clock_pic = self.getClockPixmap(service, begTime, duration, eventId) res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width()-21, r1.height(), 0, RT_HALIGN_LEFT, service_name)) - res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r1.left()+r1.width()-16, r1.top(), 21, 21, self.clock_pixmap)) + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r1.left()+r1.width()-16, r1.top(), 21, 21, clock_pic)) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_LEFT, service_name)) if begTime is not None: @@ -252,6 +284,12 @@ class EPGList(HTMLComponent, GUIComponent): x = self.l.getCurrentSelection() return x and x[1] + def moveToService(self,serviceref): + for x in range(len(self.list)): + if self.list[x][1] == serviceref.toString(): + self.instance.moveSelectionTo(x) + break + def moveToEventId(self, eventId): index = 0 for x in self.list: diff --git a/lib/python/Components/FileList.py b/lib/python/Components/FileList.py index e028ec3a..84abf328 100644 --- a/lib/python/Components/FileList.py +++ b/lib/python/Components/FileList.py @@ -10,6 +10,7 @@ from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, \ from Tools.LoadPixmap import LoadPixmap EXTENSIONS = { + "m4a": "music", "mp2": "music", "mp3": "music", "wav": "music", @@ -21,6 +22,7 @@ EXTENSIONS = { "bmp": "picture", "ts": "movie", "avi": "movie", + "divx": "movie", "mpg": "movie", "mpeg": "movie", "mkv": "movie", @@ -117,8 +119,6 @@ class FileList(MenuList): def changeDir(self, directory, select = None): self.list = [] - if directory and not os_path.isdir(directory): - directory = None # if we are just entering from the list of mount points: if self.current_directory is None: if directory and self.showMountpoints: @@ -136,6 +136,9 @@ class FileList(MenuList): self.list.append(FileEntryComponent(name = p.description, absolute = path, isDir = True)) files = [ ] directories = [ ] + elif directory is None: + files = [ ] + directories = [ ] elif self.useServiceRef: root = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + directory) if self.additional_extensions: diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index f7c3a7cb..6c6c3c6c 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -2,6 +2,8 @@ from os import system, listdir, statvfs, popen, makedirs, readlink, stat, major, from Tools.Directories import SCOPE_HDD, resolveFilename from Tools.CList import CList from SystemInfo import SystemInfo +import string, time +from Components.Console import Console def tryOpen(filename): try: @@ -17,22 +19,33 @@ class Harddisk: tmp = procfile.readline().split(':') s_major = int(tmp[0]) s_minor = int(tmp[1]) + self.max_idle_time = 0 + self.idle_running = False + self.timer = None for disc in listdir("/dev/discs"): path = readlink('/dev/discs/'+disc) - devidex = '/dev'+path[2:]+'/' - disc = devidex+'disc' + devidex = '/dev/discs/'+disc+'/' + devidex2 = '/dev'+path[2:]+'/' + disc = devidex2+'disc' ret = stat(disc).st_rdev if s_major == major(ret) and s_minor == minor(ret): self.devidex = devidex - print "new Harddisk", device, self.devidex + self.devidex2 = devidex2 + print "new Harddisk", device, '->', self.devidex, '->', self.devidex2 + self.startIdle() break def __lt__(self, ob): return self.device < ob.device + def stop(self): + if self.timer: + self.timer.stop() + self.timer.callback.remove(self.runIdle) + def bus(self): - ide_cf = self.device.find("hd") == 0 and self.devidex.find("host0") == -1 # 7025 specific - internal = self.device.find("hd") == 0 and self.devidex + ide_cf = self.device.find("hd") == 0 and self.devidex2.find("host0") == -1 # 7025 specific + internal = self.device.find("hd") == 0 if ide_cf: ret = "External (CF)" elif internal: @@ -90,7 +103,7 @@ class Harddisk: line = procfile.readline() if line == "": break - if line.startswith(self.devidex): + if line.startswith(self.devidex) or line.startswith(self.devidex2): parts = line.strip().split(" ") try: stat = statvfs(parts[1]) @@ -123,7 +136,7 @@ class Harddisk: cmd = "/bin/umount" for line in procfile: - if line.startswith(self.devidex): + if line.startswith(self.devidex) or line.startswith(self.devidex2): parts = line.split() cmd = ' '.join([cmd, parts[1]]) @@ -210,12 +223,77 @@ class Harddisk: def getDeviceName(self): return self.getDeviceDir() + "disc" + # the HDD idle poll daemon. + # as some harddrives have a buggy standby timer, we are doing this by hand here. + # first, we disable the hardware timer. then, we check every now and then if + # any access has been made to the disc. If there has been no access over a specifed time, + # we set the hdd into standby. + def readStats(self): + l = open("/sys/block/%s/stat" % self.device).read() + nr_read = int(l[:8].strip()) + nr_write = int(l[4*9:4*9+8].strip()) + return nr_read, nr_write + + def startIdle(self): + self.last_access = time.time() + self.last_stat = 0 + self.is_sleeping = False + from enigma import eTimer + + # disable HDD standby timer + Console().ePopen(("hdparm", "hdparm", "-S0", (self.devidex + "disc"))) + self.timer = eTimer() + self.timer.callback.append(self.runIdle) + self.idle_running = True + self.setIdleTime(self.max_idle_time) # kick the idle polling loop + + def runIdle(self): + if not self.max_idle_time: + return + t = time.time() + + idle_time = t - self.last_access + + stats = self.readStats() + print "nr_read", stats[0], "nr_write", stats[1] + l = sum(stats) + print "sum", l, "prev_sum", self.last_stat + + if l != self.last_stat: # access + print "hdd was accessed since previous check!" + self.last_stat = l + self.last_access = t + idle_time = 0 + self.is_sleeping = False + else: + print "hdd IDLE!" + + print "[IDLE]", idle_time, self.max_idle_time, self.is_sleeping + if idle_time >= self.max_idle_time and not self.is_sleeping: + self.setSleep() + self.is_sleeping = True + + def setSleep(self): + Console().ePopen(("hdparm", "hdparm", "-y", (self.devidex + "disc"))) + + def setIdleTime(self, idle): + self.max_idle_time = idle + if self.idle_running: + if not idle: + self.timer.stop() + else: + self.timer.start(idle * 100, False) # poll 10 times per period. + + def isSleeping(self): + return self.is_sleeping + class Partition: - def __init__(self, mountpoint, description = "", force_mounted = False): + def __init__(self, mountpoint, device = None, description = "", force_mounted = False): self.mountpoint = mountpoint self.description = description self.force_mounted = force_mounted self.is_hotplug = force_mounted # so far; this might change. + self.device = device def stat(self): return statvfs(self.mountpoint) @@ -245,6 +323,15 @@ class Partition: return True return False +DEVICEDB = \ + { + # dm8000: + "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.1/1-1.1:1.0": "Front USB Slot", + "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.2/1-1.2:1.0": "Back, upper USB Slot", + "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0": "Back, lower USB Slot", + "/devices/platform/brcm-ehci-1.1/usb2/2-1/2-1:1.0/host1/target1:0:0/1:0:0:0": "DVD Drive", + } + class HarddiskManager: def __init__(self): self.hdd = [ ] @@ -305,37 +392,62 @@ class HarddiskManager: self.cd = blockdev except IOError: error = True - return error, blacklisted, removable, is_cdrom, partitions + # check for medium + medium_found = True + try: + open("/dev/" + blockdev).close() + except IOError, err: + if err.errno == 159: # no medium present + medium_found = False + + return error, blacklisted, removable, is_cdrom, partitions, medium_found def enumerateBlockDevices(self): print "enumerating block devices..." for blockdev in listdir("/sys/block"): - error, blacklisted, removable, is_cdrom, partitions = self.getBlockDevInfo(blockdev) + error, blacklisted, removable, is_cdrom, partitions, medium_found = self.getBlockDevInfo(blockdev) print "found block device '%s':" % blockdev, if error: print "error querying properties" elif blacklisted: print "blacklisted" + elif not medium_found: + print "no medium" else: print "ok, removable=%s, cdrom=%s, partitions=%s, device=%s" % (removable, is_cdrom, partitions, blockdev) - self.addHotplugPartition(blockdev, blockdev) + + self.addHotplugPartition(blockdev) for part in partitions: - self.addHotplugPartition(part, part) + self.addHotplugPartition(part) def getAutofsMountpoint(self, device): return "/autofs/%s/" % (device) - def addHotplugPartition(self, device, description): - p = Partition(mountpoint = self.getAutofsMountpoint(device), description = description, force_mounted = True) + def addHotplugPartition(self, device, physdev = None): + if not physdev: + dev, part = self.splitDeviceName(device) + try: + physdev = readlink("/sys/block/" + dev + "/device")[5:] + except OSError: + physdev = dev + print "couldn't determine blockdev physdev for device", device + + # device is the device name, without /dev + # physdev is the physical device path, which we (might) use to determine the userfriendly name + description = self.getUserfriendlyDeviceName(device, physdev) + + p = Partition(mountpoint = self.getAutofsMountpoint(device), description = description, force_mounted = True, device = device) self.partitions.append(p) self.on_partition_list_change("add", p) + + # see if this is a harddrive l = len(device) - if l and device[l-1] not in ('0','1','2','3','4','5','6','7','8','9'): - error, blacklisted, removable, is_cdrom, partitions = self.getBlockDevInfo(device) - if not blacklisted and not removable and not is_cdrom: + if l and device[l-1] not in string.digits: + error, blacklisted, removable, is_cdrom, partitions, medium_found = self.getBlockDevInfo(device) + if not blacklisted and not removable and not is_cdrom and medium_found: self.hdd.append(Harddisk(device)) self.hdd.sort() - SystemInfo["Harddisc"] = len(self.hdd) > 0 + SystemInfo["Harddisk"] = len(self.hdd) > 0 def removeHotplugPartition(self, device): mountpoint = self.getAutofsMountpoint(device) @@ -344,13 +456,14 @@ class HarddiskManager: self.partitions.remove(x) self.on_partition_list_change("remove", x) l = len(device) - if l and device[l-1] not in ('0','1','2','3','4','5','6','7','8','9'): + if l and device[l-1] not in string.digits: idx = 0 for hdd in self.hdd: if hdd.device == device: + self.hdd[x].stop() del self.hdd[idx] break - SystemInfo["Harddisc"] = len(self.hdd) > 0 + SystemInfo["Harddisk"] = len(self.hdd) > 0 def HDDCount(self): return len(self.hdd) @@ -369,6 +482,41 @@ class HarddiskManager: return self.cd def getMountedPartitions(self, onlyhotplug = False): - return [x for x in self.partitions if (x.is_hotplug or not onlyhotplug) and x.mounted()] + parts = [x for x in self.partitions if (x.is_hotplug or not onlyhotplug) and x.mounted()] + devs = set([x.device for x in parts]) + for devname in devs.copy(): + if not devname: + continue + dev, part = self.splitDeviceName(devname) + if part and dev in devs: # if this is a partition and we still have the wholedisk, remove wholedisk + devs.remove(dev) + + # return all devices which are not removed due to being a wholedisk when a partition exists + return [x for x in parts if not x.device or x.device in devs] + + def splitDeviceName(self, devname): + # this works for: sdaX, hdaX, sr0 (which is in fact dev="sr0", part=""). It doesn't work for other names like mtdblock3, but they are blacklisted anyway. + dev = devname[:3] + part = devname[3:] + for p in part: + if p not in string.digits: + return devname, 0 + return dev, part and int(part) or 0 + + def getUserfriendlyDeviceName(self, dev, phys): + dev, part = self.splitDeviceName(dev) + description = "External Storage %s" % dev + try: + description = open("/sys" + phys + "/model").read().strip() + except IOError, s: + print "couldn't read model: ", s + for physdevprefix, pdescription in DEVICEDB.items(): + if phys.startswith(physdevprefix): + description = pdescription + + # not wholedisk and not partition 1 + if part and part != 1: + description += " (Partition %d)" % part + return description harddiskmanager = HarddiskManager() diff --git a/lib/python/Components/Language.py b/lib/python/Components/Language.py index 6d1e31f3..395f6829 100644 --- a/lib/python/Components/Language.py +++ b/lib/python/Components/Language.py @@ -36,6 +36,7 @@ class Language: self.addLanguage(_("Swedish"), "sv", "SE") self.addLanguage(_("Turkish"), "tr", "TR") self.addLanguage(_("Ukrainian"), "uk", "UA") + self.addLanguage(_("Frisian"), "fy", "x-FY") # there is no separate country for frisian self.callbacks = [] diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index fda58bf3..67cec18d 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -18,4 +18,4 @@ install_PYTHON = \ MultiContent.py MediaPlayer.py TunerInfo.py VideoWindow.py ChoiceList.py \ Element.py Playlist.py ParentalControl.py ParentalControlList.py \ Ipkg.py SelectionList.py Scanner.py SystemInfo.py DreamInfoHandler.py \ - Task.py language_cache.py Console.py + Task.py language_cache.py Console.py ResourceManager.py TuneTest.py diff --git a/lib/python/Components/MovieList.py b/lib/python/Components/MovieList.py index 8568f3d6..5c98e4be 100644 --- a/lib/python/Components/MovieList.py +++ b/lib/python/Components/MovieList.py @@ -93,10 +93,7 @@ class MovieList(GUIComponent): if len > 0: len = "%d:%02d" % (len / 60, len % 60) else: - if config.usage.load_length_of_movies_in_moviellist.value: - len = "?:??" - else: - len = "X:XX" + len = "" res = [ None ] diff --git a/lib/python/Components/MultiContent.py b/lib/python/Components/MultiContent.py index 71096df8..ff0219ff 100644 --- a/lib/python/Components/MultiContent.py +++ b/lib/python/Components/MultiContent.py @@ -1,5 +1,7 @@ from enigma import eListboxPythonMultiContent, RT_HALIGN_LEFT, RT_VALIGN_TOP +def MultiContentTemplateColor(n): return 0xff000000 | n + def MultiContentEntryText(pos = (0, 0), size = (0, 0), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_TOP, text = "", color = None, color_sel = None, backcolor = None, backcolor_sel = None, border_width = None, border_color = None): return (eListboxPythonMultiContent.TYPE_TEXT, pos[0], pos[1], size[0], size[1], font, flags, text, color, color_sel, backcolor, backcolor_sel, border_width, border_color) diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index f4e91083..4be10d53 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -14,8 +14,6 @@ from enigma import eDVBSatelliteEquipmentControl as secClass, \ from time import localtime, mktime from datetime import datetime -from sets import Set - def getConfigSatlist(orbpos, satlist): default_orbpos = None for x in satlist: @@ -39,7 +37,7 @@ class SecConfigure: sec.addSatellite(orbpos) self.configuredSatellites.add(orbpos) - def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST, useInputPower=True, inputPowerDelta=50, fastDiSEqC = False, setVoltageTone = True): + def addLNBSimple(self, sec, slotid, diseqcmode, toneburstmode = diseqcParam.NO, diseqcpos = diseqcParam.SENDNO, orbpos = 0, longitude = 0, latitude = 0, loDirection = 0, laDirection = 0, turningSpeed = rotorParam.FAST, useInputPower=True, inputPowerDelta=50, fastDiSEqC = False, setVoltageTone = True, diseqc13V = False): if orbpos is None or orbpos == 3601: return #simple defaults @@ -51,6 +49,8 @@ class SecConfigure: elif self.linked.has_key(slotid): for slot in self.linked[slotid]: tunermask |= (1 << slot) + sec.setLNBSatCR(-1) + sec.setLNBNum(1) sec.setLNBLOFL(9750000) sec.setLNBLOFH(10600000) sec.setLNBThreshold(11700000) @@ -70,7 +70,10 @@ class SecConfigure: if 0 <= diseqcmode < 3: self.addSatellite(sec, orbpos) if setVoltageTone: - sec.setVoltageMode(switchParam.HV) + if diseqc13V: + sec.setVoltageMode(switchParam.HV_13) + else: + sec.setVoltageMode(switchParam.HV) sec.setToneMode(switchParam.HILO) else: sec.setVoltageMode(switchParam._14V) @@ -90,7 +93,10 @@ class SecConfigure: for x in self.NimManager.satList: print "Add sat " + str(x[0]) self.addSatellite(sec, int(x[0])) - sec.setVoltageMode(switchParam.HV) + if diseqc13V: + sec.setVoltageMode(switchParam.HV_13) + else: + sec.setVoltageMode(switchParam.HV) sec.setToneMode(switchParam.HILO) sec.setRotorPosNum(0) # USALS @@ -115,7 +121,7 @@ class SecConfigure: def update(self): sec = secClass.getInstance() - self.configuredSatellites = Set() + self.configuredSatellites = set() sec.clear() ## this do unlinking NIMs too !! print "sec config cleared" @@ -172,24 +178,24 @@ class SecConfigure: print "diseqcmode: ", nim.diseqcMode.value if nim.diseqcMode.value == "single": #single if nim.simpleSingleSendDiSEqC.value: - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, diseqc13V = nim.diseqc13V.value) else: - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.NONE, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value) elif nim.diseqcMode.value == "toneburst_a_b": #Toneburst A/B - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO) - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.A, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.B, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.SENDNO, diseqc13V = nim.diseqc13V.value) elif nim.diseqcMode.value == "diseqc_a_b": #DiSEqC A/B fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone) - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value) elif nim.diseqcMode.value == "diseqc_a_b_c_d": #DiSEqC A/B/C/D fastDiSEqC = nim.simpleDiSEqCOnlyOnSatChange.value setVoltageTone = nim.simpleDiSEqCSetVoltageTone.value - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone) - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone) - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone) - self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcA.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcB.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.AB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcC.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BA, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value) + self.addLNBSimple(sec, slotid = x, orbpos = nim.diseqcD.orbital_position, toneburstmode = diseqcParam.NO, diseqcmode = diseqcParam.V1_0, diseqcpos = diseqcParam.BB, fastDiSEqC = fastDiSEqC, setVoltageTone = setVoltageTone, diseqc13V = nim.diseqc13V.value) elif nim.diseqcMode.value == "positioner": #Positioner if nim.latitudeOrientation.value == "north": laValue = rotorParam.NORTH @@ -219,7 +225,8 @@ class SecConfigure: laDirection = laValue, turningSpeed = turning_speed, useInputPower = useInputPower, - inputPowerDelta = inputPowerDelta) + inputPowerDelta = inputPowerDelta, + diseqc13V = nim.diseqc13V.value) elif nim.configMode.value == "advanced": #advanced config self.updateAdvanced(sec, x) print "sec config completed" @@ -248,6 +255,9 @@ class SecConfigure: currLnb = config.Nims[slotid].advanced.lnb[x] sec.addLNB() + if x < 33: + sec.setLNBNum(x) + tunermask = 1 << slotid if self.equal.has_key(slotid): for slot in self.equal[slotid]: @@ -256,10 +266,32 @@ class SecConfigure: for slot in self.linked[slotid]: tunermask |= (1 << slot) + if currLnb.lof.value != "unicable": + sec.setLNBSatCR(-1) + if currLnb.lof.value == "universal_lnb": sec.setLNBLOFL(9750000) sec.setLNBLOFH(10600000) sec.setLNBThreshold(11700000) + elif currLnb.lof.value == "unicable": + sec.setLNBLOFL(9750000) + sec.setLNBLOFH(10600000) + sec.setLNBThreshold(11700000) + if currLnb.unicable.value == "unicable_user": + sec.setLNBSatCR(currLnb.satcruser.index) + sec.setLNBSatCRvco(currLnb.satcrvcouser[currLnb.satcruser.index].value*1000) + elif currLnb.unicable.value == "unicable_matrix": + manufacturer_name = currLnb.unicableMatrixManufacturer.value + manufacturer = currLnb.unicableMatrix[manufacturer_name] + product_name = manufacturer.product.value + sec.setLNBSatCR(manufacturer.scr[product_name].index) + sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000) + elif currLnb.unicable.value == "unicable_lnb": + manufacturer_name = currLnb.unicableMatrixManufacturer.value + manufacturer = currLnb.unicableMatrix[manufacturer_name] + product_name = manufacturer.product.value + sec.setLNBSatCR(manufacturer.scr[product_name].index) + sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000) elif currLnb.lof.value == "c_band": sec.setLNBLOFL(5150000) sec.setLNBLOFH(5150000) @@ -374,6 +406,8 @@ class SecConfigure: sec.setLNBSlotMask(tunermask) + sec.setLNBPrio(int(currLnb.prio.value)) + # finally add the orbital positions for y in lnbSat[x]: self.addSatellite(sec, y) @@ -383,7 +417,10 @@ class SecConfigure: satpos = y currSat = config.Nims[slotid].advanced.sat[satpos] if currSat.voltage.value == "polarization": - sec.setVoltageMode(switchParam.HV) + if config.Nims[slotid].diseqc13V.value: + sec.setVoltageMode(switchParam.HV_13) + else: + sec.setVoltageMode(switchParam.HV) elif currSat.voltage.value == "13V": sec.setVoltageMode(switchParam._14V) elif currSat.voltage.value == "18V": @@ -403,7 +440,7 @@ class SecConfigure: def __init__(self, nimmgr): self.NimManager = nimmgr - self.configuredSatellites = Set() + self.configuredSatellites = set() self.update() class NIM(object): @@ -880,61 +917,197 @@ def InitNimManager(nimmgr): for x in range(len(nimmgr.nim_slots)): config.Nims.append(ConfigSubsection()) + lnb_choices = { + "universal_lnb": _("Universal LNB"), + "unicable": _("Unicable"), + "c_band": _("C-Band"), + "user_defined": _("User defined")} + lnb_choices_default = "universal_lnb" + + unicablelnbproducts = { + "Humax": {"150 SCR":["1210","1420","1680","2040"]}, + "Inverto": {"IDLP-40UNIQD+S":["1680","1420","2040","1210"]}, + "Kathrein": {"UAS481":["1400","1516","1632","1748"]}, + "Kreiling": {"KR1440":["1680","1420","2040","1210"]}, + "Radix": {"Unicable LNB":["1680","1420","2040","1210"]}, + "Wisi": {"OC 05":["1210","1420","1680","2040"]}} + UnicableLnbManufacturers = unicablelnbproducts.keys() + UnicableLnbManufacturers.sort() + + unicablematrixproducts = { + "Ankaro": { + "UCS 51440":["1400","1632","1284","1516"], + "UCS 51820":["1400","1632","1284","1516","1864","2096","1748","1980"], + "UCS 51840":["1400","1632","1284","1516","1864","2096","1748","1980"], + "UCS 52240":["1400","1632"], + "UCS 52420":["1400","1632","1284","1516"], + "UCS 52440":["1400","1632","1284","1516"], + "UCS 91440":["1400","1632","1284","1516"], + "UCS 91820":["1400","1632","1284","1516","1864","2096","1748","1980"], + "UCS 91840":["1400","1632","1284","1516","1864","2096","1748","1980"], + "UCS 92240":["1400","1632"], + "UCS 92420":["1400","1632","1284","1516"], + "UCS 92440":["1400","1632","1284","1516"]}, + "DCT Delta": { + "SUM518":["1284","1400","1516","1632","1748","1864","1980","2096"], + "SUM918":["1284","1400","1516","1632","1748","1864","1980","2096"], + "SUM928":["1284","1400","1516","1632","1748","1864","1980","2096"]}, + "Inverto": { + "IDLP-UST11O-CUO1O-8PP":["1076","1178","1280","1382","1484","1586","1688","1790"]}, + "Kathrein": { + "EXR501":["1400","1516","1632","1748"], + "EXR551":["1400","1516","1632","1748"], + "EXR552":["1400","1516"]}, + "ROTEK": { + "EKL2/1":["1400","1516"], + "EKL2/1E":["0","0","1632","1748"]}, + "Smart": { + "DPA 51":["1284","1400","1516","1632","1748","1864","1980","2096"]}, + "Technisat": { + "TechniRouter 5/1x8 G":["1284","1400","1516","1632","1748","1864","1980","2096"], + "TechniRouter 5/1x8 K":["1284","1400","1516","1632","1748","1864","1980","2096"], + "TechniRouter 5/2x4 G":["1284","1400","1516","1632"], + "TechniRouter 5/2x4 K":["1284","1400","1516","1632"]}, + "Telstar": { + "SCR 5/1x8 G":["1284","1400","1516","1632","1748","1864","1980","2096"], + "SCR 5/1x8 K":["1284","1400","1516","1632","1748","1864","1980","2096"], + "SCR 5/2x4 G":["1284","1400","1516","1632"], + "SCR 5/2x4 K":["1284","1400","1516","1632"]}} + UnicableMatrixManufacturers = unicablematrixproducts.keys() + UnicableMatrixManufacturers.sort() + + unicable_choices = { + "unicable_lnb": _("Unicable LNB"), + "unicable_matrix": _("Unicable Martix"), + "unicable_user": "Unicable "+_("User defined")} + unicable_choices_default = "unicable_lnb" + + unicableLnb = ConfigSubDict() + for y in unicablelnbproducts: + products = unicablelnbproducts[y].keys() + products.sort() + unicableLnb[y] = ConfigSubsection() + unicableLnb[y].product = ConfigSelection(choices = products, default = products[0]) + unicableLnb[y].scr = ConfigSubDict() + unicableLnb[y].vco = ConfigSubDict() + for z in products: + scrlist = [] + vcolist = unicablelnbproducts[y][z] + unicableLnb[y].vco[z] = ConfigSubList() + for cnt in range(1,1+len(vcolist)): + scrlist.append(("%d" %cnt,"SCR %d" %cnt)) + vcofreq = int(vcolist[cnt-1]) + unicableLnb[y].vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) + unicableLnb[y].scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) + + unicableMatrix = ConfigSubDict() + + for y in unicablematrixproducts: + products = unicablematrixproducts[y].keys() + products.sort() + unicableMatrix[y] = ConfigSubsection() + unicableMatrix[y].product = ConfigSelection(choices = products, default = products[0]) + unicableMatrix[y].scr = ConfigSubDict() + unicableMatrix[y].vco = ConfigSubDict() + for z in products: + scrlist = [] + vcolist = unicablematrixproducts[y][z] + unicableMatrix[y].vco[z] = ConfigSubList() + for cnt in range(1,1+len(vcolist)): + vcofreq = int(vcolist[cnt-1]) + if vcofreq == 0: + scrlist.append(("%d" %cnt,"SCR %d " %cnt +_("not used"))) + else: + scrlist.append(("%d" %cnt,"SCR %d" %cnt)) + unicableMatrix[y].vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) + unicableMatrix[y].scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) + + advanced_lnb_satcruser_choices = [ ("1", "SatCR 1"), ("2", "SatCR 2"), ("3", "SatCR 3"), ("4", "SatCR 4"), + ("5", "SatCR 5"), ("6", "SatCR 6"), ("7", "SatCR 7"), ("8", "SatCR 8")] + + satcrvcouser = ConfigSubList() + satcrvcouser.append(ConfigInteger(default=1284, limits = (0, 9999))) + satcrvcouser.append(ConfigInteger(default=1400, limits = (0, 9999))) + satcrvcouser.append(ConfigInteger(default=1516, limits = (0, 9999))) + satcrvcouser.append(ConfigInteger(default=1632, limits = (0, 9999))) + satcrvcouser.append(ConfigInteger(default=1748, limits = (0, 9999))) + satcrvcouser.append(ConfigInteger(default=1864, limits = (0, 9999))) + satcrvcouser.append(ConfigInteger(default=1980, limits = (0, 9999))) + satcrvcouser.append(ConfigInteger(default=2096, limits = (0, 9999))) + + prio_list = [ ("-1", _("Auto")) ] + prio_list += [(str(prio), str(prio)) for prio in range(65)+range(14000,14065)+range(19000,19065)] + + advanced_lnb_csw_choices = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))] + advanced_lnb_csw_choices += [(str(0xF0|y), "Input " + str(y+1)) for y in range(0, 16)] + + advanced_lnb_ucsw_choices = [("0", _("None"))] + [(str(y), "Input " + str(y)) for y in range(1, 17)] + + diseqc_mode_choices = [ + ("single", _("Single")), ("toneburst_a_b", _("Toneburst A/B")), + ("diseqc_a_b", _("DiSEqC A/B")), ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")), + ("positioner", _("Positioner"))] + + positioner_mode_choices = [("usals", _("USALS")), ("manual", _("manual"))] + + diseqc_satlist_choices = [(3601, _('nothing connected'), 1)] + nimmgr.satList + + longitude_orientation_choices = [("east", _("East")), ("west", _("West"))] + latitude_orientation_choices = [("north", _("North")), ("south", _("South"))] + turning_speed_choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))] + + advanced_satlist_choices = nimmgr.satList + [ + (3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1), + (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)] + advanced_lnb_choices = [("0", "not available")] + [(str(y), "LNB " + str(y)) for y in range(1, 33)] + advanced_voltage_choices = [("polarization", _("Polarization")), ("13V", _("13 V")), ("18V", _("18 V"))] + advanced_tonemode_choices = [("band", _("Band")), ("on", _("On")), ("off", _("Off"))] + advanced_lnb_toneburst_choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))] + advanced_lnb_allsat_diseqcmode_choices = [("1_2", _("1.2"))] + advanced_lnb_diseqcmode_choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))] + advanced_lnb_commandOrder1_0_choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")] + advanced_lnb_commandOrder_choices = [ + ("ct", "committed, toneburst"), ("tc", "toneburst, committed"), + ("cut", "committed, uncommitted, toneburst"), ("tcu", "toneburst, committed, uncommitted"), + ("uct", "uncommitted, committed, toneburst"), ("tuc", "toneburst, uncommitted, commmitted")] + advanced_lnb_diseqc_repeat_choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))] + advanced_lnb_fast_turning_btime = mktime(datetime(1970, 1, 1, 7, 0).timetuple()); + advanced_lnb_fast_turning_etime = mktime(datetime(1970, 1, 1, 19, 0).timetuple()); for slot in nimmgr.nim_slots: x = slot.slot nim = config.Nims[x] if slot.isCompatible("DVB-S"): - choices = { "nothing": _("nothing connected"), - "simple": _("simple"), - "advanced": _("advanced")} + config_mode_choices = [ ("nothing", _("nothing connected")), + ("simple", _("simple")), ("advanced", _("advanced"))] if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0: - choices["equal"] = _("equal to") - choices["satposdepends"] = _("second cable of motorized LNB") + config_mode_choices.append(("equal", _("equal to"))) + config_mode_choices.append(("satposdepends", _("second cable of motorized LNB"))) if len(nimmgr.canConnectTo(x)) > 0: - choices["loopthrough"] = _("loopthrough to") - nim.configMode = ConfigSelection(choices = choices, default = "nothing") - -# for y in nimmgr.nim_slots: -# if y.slot == 0: -# if not y.isCompatible("DVB-S"): -# # reset to simple -# nim.configMode.value = "simple" -# nim.configMode.save() - - nim.diseqcMode = ConfigSelection( - choices = [ - ("single", _("Single")), - ("toneburst_a_b", _("Toneburst A/B")), - ("diseqc_a_b", _("DiSEqC A/B")), - ("diseqc_a_b_c_d", _("DiSEqC A/B/C/D")), - ("positioner", _("Positioner"))], - default = "diseqc_a_b") - - choices = [] - for id in nimmgr.getNimListOfType("DVB-S"): - if id != x: - choices.append((str(id), nimmgr.getNimDescription(id))) - nim.connectedTo = ConfigSelection(choices = choices) - nim.simpleSingleSendDiSEqC = ConfigYesNo(default=False) - nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(default=True) - nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(default=False) - nim.diseqcA = getConfigSatlist(192, [(3601, _('nothing connected'), 1)] + nimmgr.satList) - nim.diseqcB = getConfigSatlist(130, [(3601, _('nothing connected'), 1)] + nimmgr.satList) - nim.diseqcC = ConfigSatlist(list = [(3601, _('nothing connected'), 1)] + nimmgr.satList) - nim.diseqcD = ConfigSatlist(list = [(3601, _('nothing connected'), 1)] + nimmgr.satList) - nim.positionerMode = ConfigSelection( - choices = [ - ("usals", _("USALS")), - ("manual", _("manual"))], - default = "usals") + config_mode_choices.append(("loopthrough", _("loopthrough to"))) + nim.configMode = ConfigSelection(config_mode_choices, "nothing") + + nim.diseqc13V = ConfigYesNo(False) + + nim.diseqcMode = ConfigSelection(diseqc_mode_choices, "diseqc_a_b") + + nim.connectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x]) + + nim.simpleSingleSendDiSEqC = ConfigYesNo(False) + nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(True) + nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(False) + nim.diseqcA = getConfigSatlist(192, diseqc_satlist_choices) + nim.diseqcB = getConfigSatlist(130, diseqc_satlist_choices) + nim.diseqcC = ConfigSatlist(list = diseqc_satlist_choices) + nim.diseqcD = ConfigSatlist(list = diseqc_satlist_choices) + nim.positionerMode = ConfigSelection(positioner_mode_choices, "usals") nim.longitude = ConfigFloat(default=[5,100], limits=[(0,359),(0,999)]) - nim.longitudeOrientation = ConfigSelection(choices={"east": _("East"), "west": _("West")}, default = "east") + nim.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east") nim.latitude = ConfigFloat(default=[50,767], limits=[(0,359),(0,999)]) - nim.latitudeOrientation = ConfigSelection(choices={"north": _("North"), "south": _("South")}, default="north") - nim.powerMeasurement = ConfigYesNo(default=True) + nim.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north") + nim.powerMeasurement = ConfigYesNo(True) nim.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100)) - nim.turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch")) ], default = "fast") + nim.turningSpeed = ConfigSelection(turning_speed_choices, "fast") btime = datetime(1970, 1, 1, 7, 0); nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900) etime = datetime(1970, 1, 1, 19, 0); @@ -942,78 +1115,72 @@ def InitNimManager(nimmgr): # advanced config: nim.advanced = ConfigSubsection() - tmp = [(3601, _('All Satellites')+' 1', 1), (3602, _('All Satellites')+' 2', 1), (3603, _('All Satellites')+' 3', 1), (3604, _('All Satellites')+' 4', 1)] - nim.advanced.sats = getConfigSatlist(192,nimmgr.satList+tmp) + nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices) nim.advanced.sat = ConfigSubDict() - lnbs = [("0", "not available")] - for y in range(1, 33): - lnbs.append((str(y), "LNB " + str(y))) for x in nimmgr.satList: nim.advanced.sat[x[0]] = ConfigSubsection() - nim.advanced.sat[x[0]].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization") - nim.advanced.sat[x[0]].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band") - nim.advanced.sat[x[0]].usals = ConfigYesNo(default=True) + nim.advanced.sat[x[0]].voltage = ConfigSelection(advanced_voltage_choices, "polarization") + nim.advanced.sat[x[0]].tonemode = ConfigSelection(advanced_tonemode_choices, "band") + nim.advanced.sat[x[0]].usals = ConfigYesNo(True) nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255)) - nim.advanced.sat[x[0]].lnb = ConfigSelection(choices = lnbs) + nim.advanced.sat[x[0]].lnb = ConfigSelection(advanced_lnb_choices, "0") for x in range(3601, 3605): nim.advanced.sat[x] = ConfigSubsection() - nim.advanced.sat[x].voltage = ConfigSelection(choices={"polarization": _("Polarization"), "13V": _("13 V"), "18V": _("18 V")}, default = "polarization") - nim.advanced.sat[x].tonemode = ConfigSelection(choices={"band": _("Band"), "on": _("On"), "off": _("Off")}, default = "band") + nim.advanced.sat[x].voltage = ConfigSelection(advanced_voltage_choices, "polarization") + nim.advanced.sat[x].tonemode = ConfigSelection(advanced_tonemode_choices, "band") nim.advanced.sat[x].usals = ConfigYesNo(default=True) nim.advanced.sat[x].rotorposition = ConfigInteger(default=1, limits=(1, 255)) lnbnum = 33+x-3601 - nim.advanced.sat[x].lnb = ConfigSelection(choices = [("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], default="0") - - csw = [("none", _("None")), ("AA", _("AA")), ("AB", _("AB")), ("BA", _("BA")), ("BB", _("BB"))] - for y in range(0, 16): - csw.append((str(0xF0|y), "Input " + str(y+1))) - - ucsw = [("0", _("None"))] - for y in range(1, 17): - ucsw.append((str(y), "Input " + str(y))) + nim.advanced.sat[x].lnb = ConfigSelection([("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], "0") nim.advanced.lnb = ConfigSubList() nim.advanced.lnb.append(ConfigNothing()) + for x in range(1, 37): nim.advanced.lnb.append(ConfigSubsection()) - nim.advanced.lnb[x].lof = ConfigSelection(choices={"universal_lnb": _("Universal LNB"), "c_band": _("C-Band"), "user_defined": _("User defined")}, default="universal_lnb") + nim.advanced.lnb[x].lof = ConfigSelection(lnb_choices, lnb_choices_default) + nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999)) nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999)) nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999)) + + nim.advanced.lnb[x].unicable = ConfigSelection(unicable_choices, unicable_choices_default) + + nim.advanced.lnb[x].unicableLnb = unicableLnb # is this okay? all lnb use the same ConfigSubDict ? ! ? + nim.advanced.lnb[x].unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0]) + + nim.advanced.lnb[x].unicableMatrix = unicableMatrix # is this okay? all lnb use the same ConfigSubDict ? ! ? + nim.advanced.lnb[x].unicableMatrixManufacturer = ConfigSelection(UnicableMatrixManufacturers, UnicableMatrixManufacturers[0]) + + nim.advanced.lnb[x].satcruser = ConfigSelection(advanced_lnb_satcruser_choices, "1") + nim.advanced.lnb[x].satcrvcouser = satcrvcouser # is this okay? all lnb use the same ConfigSubDict ? ! ? + # nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V") - nim.advanced.lnb[x].increased_voltage = ConfigYesNo(default=False) - nim.advanced.lnb[x].toneburst = ConfigSelection(choices = [("none", _("None")), ("A", _("A")), ("B", _("B"))], default = "none") + nim.advanced.lnb[x].increased_voltage = ConfigYesNo(False) + nim.advanced.lnb[x].toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none") if x > 32: - nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("1_2", _("1.2"))], default = "1_2") + nim.advanced.lnb[x].diseqcMode = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2") else: - nim.advanced.lnb[x].diseqcMode = ConfigSelection(choices = [("none", _("None")), ("1_0", _("1.0")), ("1_1", _("1.1")), ("1_2", _("1.2"))], default = "none") - nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(choices = csw) - nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(default=False) - nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(default=False) - nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(choices = [("ct", "committed, toneburst"), ("tc", "toneburst, committed")], default = "ct") - nim.advanced.lnb[x].commandOrder = ConfigSelection(choices = [ - ("ct", "committed, toneburst"), - ("tc", "toneburst, committed"), - ("cut", "committed, uncommitted, toneburst"), - ("tcu", "toneburst, committed, uncommitted"), - ("uct", "uncommitted, committed, toneburst"), - ("tuc", "toneburst, uncommitted, commmitted")], - default="ct") - nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(choices = ucsw) - nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))], default = "none") + nim.advanced.lnb[x].diseqcMode = ConfigSelection(advanced_lnb_diseqcmode_choices, "none") + nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(advanced_lnb_csw_choices) + nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(False) + nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(False) + nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(advanced_lnb_commandOrder1_0_choices, "ct") + nim.advanced.lnb[x].commandOrder = ConfigSelection(advanced_lnb_commandOrder_choices, "ct") + nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(advanced_lnb_ucsw_choices) + nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(advanced_lnb_diseqc_repeat_choices, "none") nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)]) - nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(choices = [("east", _("East")), ("west", _("West"))], default = "east") + nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east") nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)]) - nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(choices = [("north", _("North")), ("south", _("South"))], default = "north") + nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north") nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True) nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100)) - nim.advanced.lnb[x].turningSpeed = ConfigSelection(choices = [("fast", _("Fast")), ("slow", _("Slow")), ("fast epoch", _("Fast epoch"))], default = "fast") - btime = datetime(1970, 1, 1, 7, 0); - nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 600) - etime = datetime(1970, 1, 1, 19, 0); - nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 600) + nim.advanced.lnb[x].turningSpeed = ConfigSelection(turning_speed_choices, "fast") + nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=advanced_lnb_fast_turning_btime, formatstring = _("%H:%M"), increment = 600) + nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=advanced_lnb_fast_turning_etime, formatstring = _("%H:%M"), increment = 600) + nim.advanced.lnb[x].prio = ConfigSelection(prio_list, "-1") elif slot.isCompatible("DVB-C"): nim.configMode = ConfigSelection( choices = { diff --git a/lib/python/Components/Renderer/Canvas.py b/lib/python/Components/Renderer/Canvas.py index bd7ffb5e..acf0dbf7 100644 --- a/lib/python/Components/Renderer/Canvas.py +++ b/lib/python/Components/Renderer/Canvas.py @@ -35,7 +35,7 @@ class Canvas(Renderer): self.instance.writeText(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]), gRGB(l[6]), l[7], l[8], l[9]) else: print "drawlist entry:", l - raise "invalid drawlist entry" + raise RuntimeError("invalid drawlist entry") def changed(self, what): self.pull_updates() diff --git a/lib/python/Components/ResourceManager.py b/lib/python/Components/ResourceManager.py new file mode 100644 index 00000000..fb6be4a8 --- /dev/null +++ b/lib/python/Components/ResourceManager.py @@ -0,0 +1,23 @@ +class ResourceManager: + def __init__(self): + self.resourceList = {} + + def addResource(self, name, resource): + print "adding Resource", name + self.resourceList[name] = resource + print "resources:", self.resourceList + + + def getResource(self, name): + if not self.hasResource(name): + return None + return self.resourceList[name] + + def hasResource(self, name): + return self.resourceList.has_key(name) + + def removeResource(self, name): + if self.hasResource(name): + del self.resourceList[name] + +resourcemanager = ResourceManager()
\ No newline at end of file diff --git a/lib/python/Components/Scanner.py b/lib/python/Components/Scanner.py index 766d1966..86a5431d 100644 --- a/lib/python/Components/Scanner.py +++ b/lib/python/Components/Scanner.py @@ -135,7 +135,7 @@ def scanDevice(mountpoint): from Components.Harddisk import harddiskmanager blockdev = mountpoint.rstrip("/").rsplit('/',1)[-1] - error, blacklisted, removable, is_cdrom, partitions = harddiskmanager.getBlockDevInfo(blockdev) + error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.getBlockDevInfo(blockdev) # now scan the paths for p in paths_to_scan: diff --git a/lib/python/Components/ServiceScan.py b/lib/python/Components/ServiceScan.py index 5a7b3dea..78cd758e 100644 --- a/lib/python/Components/ServiceScan.py +++ b/lib/python/Components/ServiceScan.py @@ -36,54 +36,58 @@ class ServiceScan: tp_text = "" if transponder: tp_type = transponder.getSystem() - if not tp_type[0]: - tp_type = tp_type[1] - if tp_type == iDVBFrontend.feSatellite: - network = _("Satellite") - tp = transponder.getDVBS() - if not tp[0]: - tp = tp[1] - orb_pos = tp.orbital_position - try: - sat_name = str(nimmgr.getSatDescription(orb_pos)) - except KeyError: - sat_name = "" - if orb_pos > 1800: # west - orb_pos = 3600 - orb_pos - h = _("W") - else: - h = _("E") - if sat_name.find("%d.%d" % (orb_pos/10, orb_pos%10)) != -1: - network = sat_name - else: - network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h) - tp_text = ("%s %s %d%c / %d / %s") %( { 0 : "DVB-S", 1 : "DVB-S2" }[tp.system], - { 0 : "Auto", 1 : "QPSK", 2 : "M8PSK", 3 : "QAM16" }[tp.modulation], - tp.frequency/1000, - { 0 : 'H', 1 : 'V', 2 : 'L', 3 : 'R' }[tp.polarisation], - tp.symbol_rate/1000, - { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", - 5 : "7/8", 6 : "8/9", 7 : "3/5", 8 : "4/5", 9 : "9/10", - 15 : "NONE" }[tp.fec] ) - elif tp_type == iDVBFrontend.feCable: - network = _("Cable") - tp = transponder.getDVBC() - if not tp[0]: - tp = tp[1] - tp_text = ("DVB-C %s %d / %d / %s") %( { 0 : "AUTO", 1 : "QAM16", 2 : "QAM32", 3 : "QAM64", 4 : "QAM128", 5 : "QAM256" }[tp.modulation], - tp.frequency, - tp.symbol_rate/1000, - { 0 : "AUTO", 1 : "1/2", 2 : "2/3", 3 : "3/4", 4 : "5/6", 5 : "7/8", 6 : "8/9", 15 : "NONE" }[tp.fec_inner] ) - elif tp_type == iDVBFrontend.feTerrestrial: - network = _("Terrestrial") - tp = transponder.getDVBT() - if not tp[0]: - tp = tp[1] - tp_text = ("DVB-T %s %d %s") %( { 0 : "QPSK", 1 : "QAM16", 2 : "QAM64", 3 : "AUTO"}[tp.modulation], - tp.frequency, - { 0 : "Bw 8MHz", 1 : "Bw 7MHz", 2 : "Bw 6MHz", 3 : "Bw Auto" }[tp.bandwidth]) + if tp_type == iDVBFrontend.feSatellite: + network = _("Satellite") + tp = transponder.getDVBS() + orb_pos = tp.orbital_position + try: + sat_name = str(nimmgr.getSatDescription(orb_pos)) + except KeyError: + sat_name = "" + if orb_pos > 1800: # west + orb_pos = 3600 - orb_pos + h = _("W") else: - print "unknown transponder type in scanStatusChanged" + h = _("E") + if sat_name.find("%d.%d" % (orb_pos/10, orb_pos%10)) != -1: + network = sat_name + else: + network = ("%s %d.%d %s") % (sat_name, orb_pos / 10, orb_pos % 10, h) + tp_text = ("%s %s %d%c / %d / %s") %( { tp.System_DVB_S : "DVB-S", + tp.System_DVB_S2 : "DVB-S2" }.get(tp.system, tp.System_DVB_S), + { tp.Modulation_Auto : "Auto", tp.Modulation_QPSK : "QPSK", + tp.Modulation_8PSK : "8PSK", tp.Modulation_QAM16 : "QAM16" }.get(tp.modulation, tp.Modulation_QPSK), + tp.frequency/1000, + { tp.Polarisation_Horizontal : 'H', tp.Polarisation_Vertical : 'V', tp.Polarisation_CircularLeft : 'L', + tp.Polarisation_CircularRight : 'R' }.get(tp.polarisation, tp.Polarisation_Horizontal), + tp.symbol_rate/1000, + { tp.FEC_Auto : "AUTO", tp.FEC_1_2 : "1/2", tp.FEC_2_3 : "2/3", + tp.FEC_3_4 : "3/4", tp.FEC_5_6 : "5/6", tp.FEC_7_8 : "7/8", + tp.FEC_8_9 : "8/9", tp.FEC_3_5 : "3/5", tp.FEC_4_5 : "4/5", + tp.FEC_9_10 : "9/10", tp.FEC_None : "NONE" }.get(tp.fec, tp.FEC_Auto)) + elif tp_type == iDVBFrontend.feCable: + network = _("Cable") + tp = transponder.getDVBC() + tp_text = ("DVB-C %s %d / %d / %s") %( { tp.Modulation_Auto : "AUTO", + tp.Modulation_QAM16 : "QAM16", tp.Modulation_QAM32 : "QAM32", + tp.Modulation_QAM64 : "QAM64", tp.Modulation_QAM128 : "QAM128", + tp.Modulation_QAM256 : "QAM256" }.get(tp.modulation, tp.Modulation_Auto), + tp.frequency, + tp.symbol_rate/1000, + { tp.FEC_Auto : "AUTO", tp.FEC_1_2 : "1/2", tp.FEC_2_3 : "2/3", + tp.FEC_3_4 : "3/4", tp.FEC_5_6 : "5/6", tp.FEC_7_8 : "7/8", + tp.FEC_8_9 : "8/9", tp.FEC_None : "NONE" }.get(tp.fec_inner, tp.FEC_Auto)) + elif tp_type == iDVBFrontend.feTerrestrial: + network = _("Terrestrial") + tp = transponder.getDVBT() + tp_text = ("DVB-T %s %d %s") %( { tp.Modulation_QPSK : "QPSK", + tp.Modulation_QAM16 : "QAM16", tp.Modulation_QAM64 : "QAM64", + tp.Modulation_Auto : "AUTO" }.get(tp.modulation, tp.Modulation_Auto), + tp.frequency, + { tp.Bandwidth_8MHz : "Bw 8MHz", tp.Bandwidth_7MHz : "Bw 7MHz", tp.Bandwidth_6MHz : "Bw 6MHz", + tp.Bandwidth_Auto : "Bw Auto" }.get(tp.bandwidth, tp.Bandwidth_Auto)) + else: + print "unknown transponder type in scanStatusChanged" self.network.setText(network) self.transponder.setText(tp_text) diff --git a/lib/python/Components/Sources/List.py b/lib/python/Components/Sources/List.py index ef9c1c89..23b53957 100644 --- a/lib/python/Components/Sources/List.py +++ b/lib/python/Components/Sources/List.py @@ -17,6 +17,7 @@ to generate HTML.""" self.fonts = fonts self.disable_callbacks = False self.enableWrapAround = enableWrapAround + self.__style = "default" # style might be an optional string which can be used to define different visualisations in the skin def setList(self, list): self.__list = list @@ -27,7 +28,11 @@ to generate HTML.""" def entry_changed(self, index): if not self.disable_callbacks: self.downstream_elements.entry_changed(self, index) - + + def modifyEntry(self, index, data): + self.__list[index] = data + self.entry_changed(index) + def count(self): return len(self.__list) @@ -76,17 +81,21 @@ to generate HTML.""" self.index -= 1 self.setIndex(self.index) + @cached + def getStyle(self): + return self.__style + + def setStyle(self, style): + self.__style = style + self.changed((self.CHANGED_SPECIFIC, "style")) + + style = property(getStyle, setStyle) + def updateList(self, list): """Changes the list without changing the selection or emitting changed Events""" assert len(list) == len(self.__list) - print "get old index" old_index = self.index - print "disable callback" self.disable_callbacks = True - print "set list" self.list = list - print "set index" self.index = old_index - print "reenable callbacks" self.disable_callbacks = False - print "done" diff --git a/lib/python/Components/Sources/Progress.py b/lib/python/Components/Sources/Progress.py index b96065b3..d57a6179 100644 --- a/lib/python/Components/Sources/Progress.py +++ b/lib/python/Components/Sources/Progress.py @@ -12,5 +12,12 @@ class Progress(Source): def setValue(self, value): self.__value = value self.changed((self.CHANGED_ALL,)) + + def setRange(self, range = 100): + self.range = range + self.changed((self.CHANGED_ALL,)) + + def getRange(self): + return self.range value = property(getValue, setValue) diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index 9a768425..df94f8a6 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -127,9 +127,11 @@ class Task(object): self.cmd = None self.cwd = "/tmp" self.args = [ ] + self.cmdline = None self.task_progress_changed = None self.output_line = "" job.addTask(self) + self.container = None def setCommandline(self, cmd, args): self.cmd = cmd @@ -141,6 +143,9 @@ class Task(object): self.global_preconditions.append(ToolExistsPrecondition()) self.postconditions.append(ReturncodePostcondition()) + def setCmdline(self, cmdline): + self.cmdline = cmdline + def checkPreconditions(self, immediate = False): not_met = [ ] if immediate: @@ -166,13 +171,15 @@ class Task(object): self.container.stdoutAvail.append(self.processStdout) self.container.stderrAvail.append(self.processStderr) - assert self.cmd is not None - assert len(self.args) >= 1 - if self.cwd is not None: self.container.setCWD(self.cwd) - print "execute:", self.container.execute(self.cmd, *self.args), self.cmd, self.args + if not self.cmd and self.cmdline: + print "execute:", self.container.execute(self.cmdline), self.cmdline + else: + assert self.cmd is not None + assert len(self.args) >= 1 + print "execute:", self.container.execute(self.cmd, *self.args), ' '.join(self.args) if self.initial_input: self.writeInput(self.initial_input) @@ -205,7 +212,8 @@ class Task(object): self.finish() def abort(self): - self.container.kill() + if self.container: + self.container.kill() self.finish(aborted = True) def finish(self, aborted = False): diff --git a/lib/python/Components/TimerSanityCheck.py b/lib/python/Components/TimerSanityCheck.py index 031c9cae..99b2fba5 100644 --- a/lib/python/Components/TimerSanityCheck.py +++ b/lib/python/Components/TimerSanityCheck.py @@ -173,8 +173,7 @@ class TimerSanityCheck: def getServiceType(ref): # helper function to get a service type of a service reference serviceInfo = serviceHandler.info(ref) serviceInfo = serviceInfo and serviceInfo.getInfoObject(ref, iServiceInformation.sTransponderData) - if serviceInfo: - return { "Satellite" : "DVB-S", "Cable" : "DVB-C", "Terrestrial" : "DVB-T"}[serviceInfo["type"]] + return serviceInfo and serviceInfo["tuner_type"] or "" ref = timer.service_ref.ref if ref.flags & eServiceReference.isGroup: # service group ? @@ -200,7 +199,7 @@ class TimerSanityCheck: if timer == fakeRec[0] and fakeRec[1]: NavigationInstance.instance.stopRecordService(fakeRec[1]) fakeRecList.remove(fakeRec) - del fakeRec + fakeRec = None for entry in overlaplist: if entry[1] == timer: overlaplist.remove(entry) diff --git a/lib/python/Components/TuneTest.py b/lib/python/Components/TuneTest.py new file mode 100644 index 00000000..de7b0098 --- /dev/null +++ b/lib/python/Components/TuneTest.py @@ -0,0 +1,235 @@ +from enigma import eDVBFrontendParametersSatellite, eDVBFrontendParameters, eDVBResourceManager, eTimer + +class Tuner: + def __init__(self, frontend): + self.frontend = frontend + + # transponder = (frequency, symbolrate, polarisation, fec, inversion, orbpos, system, modulation) + # 0 1 2 3 4 5 6 7 + def tune(self, transponder): + if self.frontend: + print "tuning to transponder with data", transponder + parm = eDVBFrontendParametersSatellite() + parm.frequency = transponder[0] * 1000 + parm.symbol_rate = transponder[1] * 1000 + parm.polarisation = transponder[2] + parm.fec = transponder[3] + parm.inversion = transponder[4] + parm.orbital_position = transponder[5] + parm.system = transponder[6] + parm.modulation = transponder[7] + parm.rolloff = transponder[8] + parm.pilot = transponder[9] + feparm = eDVBFrontendParameters() + feparm.setDVBS(parm) + self.lastparm = feparm + self.frontend.tune(feparm) + + def retune(self): + if self.frontend: + self.frontend.tune(self.lastparm) + + def getTransponderData(self): + ret = { } + if self.frontend: + self.frontend.getTransponderData(ret, True) + return ret + +# tunes a list of transponders and checks, if they lock and optionally checks the onid/tsid combination +# 1) add transponders with addTransponder() +# 2) call run(<checkPIDs = True>) +# 3) finishedChecking() is called, when the run is finished +class TuneTest: + def __init__(self, feid, stopOnSuccess = -1, stopOnError = -1): + self.stopOnSuccess = stopOnSuccess + self.stopOnError = stopOnError + self.feid = feid + self.transponderlist = [] + self.currTuned = None + print "TuneTest for feid %d" % self.feid + if not self.openFrontend(): + self.oldref = self.session.nav.getCurrentlyPlayingServiceReference() + self.session.nav.stopService() # try to disable foreground service + if not self.openFrontend(): + if self.session.pipshown: # try to disable pip + self.session.pipshown = False + del self.session.pip + if not self.openFrontend(): + self.frontend = None # in normal case this should not happen + self.tuner = Tuner(self.frontend) + self.timer = eTimer() + self.timer.callback.append(self.updateStatus) + + def gotTsidOnid(self, tsid, onid): + print "******** got tsid, onid:", tsid, onid + if tsid is not None and onid is not None: + self.pidStatus = self.INTERNAL_PID_STATUS_SUCCESSFUL + self.tsid = tsid + self.onid = onid + else: + self.pidStatus = self.INTERNAL_PID_STATUS_FAILED + self.tsid = -1 + self.onid = -1 + self.timer.start(100, True) + + def updateStatus(self): + dict = {} + self.frontend.getFrontendStatus(dict) + stop = False + + print "status:", dict + if dict["tuner_state"] == "TUNING": + print "TUNING" + self.timer.start(100, True) + self.progressCallback((self.getProgressLength(), self.tuningtransponder, self.STATUS_TUNING, self.currTuned)) + elif self.checkPIDs and self.pidStatus == self.INTERNAL_PID_STATUS_NOOP: + print "2nd choice" + if dict["tuner_state"] == "LOCKED": + print "acquiring TSID/ONID" + self.raw_channel.requestTsidOnid(self.gotTsidOnid) + self.pidStatus = self.INTERNAL_PID_STATUS_WAITING + else: + self.pidStatus = self.INTERNAL_PID_STATUS_FAILED + elif self.checkPIDs and self.pidStatus == self.INTERNAL_PID_STATUS_WAITING: + print "waiting for pids" + else: + if dict["tuner_state"] == "LOSTLOCK" or dict["tuner_state"] == "FAILED": + self.tuningtransponder = self.nextTransponder() + self.failedTune.append([self.currTuned, self.oldTuned, "tune_failed"]) + if self.stopOnError != -1 and self.stopOnError <= len(self.failedTune): + stop = True + elif dict["tuner_state"] == "LOCKED": + pidsFailed = False + if self.checkPIDs: + if self.currTuned is not None: + if self.tsid != self.currTuned[8] or self.onid != self.currTuned[9]: + self.failedTune.append([self.currTuned, self.oldTuned, "pids_failed", {"real": (self.tsid, self.onid), "expected": (self.currTuned[8], self.currTuned[9])}]) + pidsFailed = True + else: + self.successfullyTune.append([self.currTuned, self.oldTuned]) + if self.stopOnSuccess != -1 and self.stopOnSuccess <= len(self.successfullyTune): + stop = True + elif not self.checkPIDs or (self.checkPids and not pidsFailed): + self.successfullyTune.append([self.currTuned, self.oldTuned]) + if self.stopOnSuccess != -1 and self.stopOnSuccess <= len(self.successfullyTune): + stop = True + self.tuningtransponder = self.nextTransponder() + else: + print "************* tuner_state:", dict["tuner_state"] + + self.progressCallback((self.getProgressLength(), self.tuningtransponder, self.STATUS_NOOP, self.currTuned)) + + if not stop: + self.tune() + if self.tuningtransponder < len(self.transponderlist) and not stop: + if self.pidStatus != self.INTERNAL_PID_STATUS_WAITING: + self.timer.start(100, True) + print "restart timer" + else: + print "not restarting timers (waiting for pids)" + else: + self.progressCallback((self.getProgressLength(), len(self.transponderlist), self.STATUS_DONE, self.currTuned)) + print "finishedChecking" + self.finishedChecking() + + def firstTransponder(self): + print "firstTransponder:" + index = 0 + if self.checkPIDs: + print "checkPIDs-loop" + # check for tsid != -1 and onid != -1 + print "index:", index + print "len(self.transponderlist):", len(self.transponderlist) + while (index < len(self.transponderlist) and (self.transponderlist[index][8] == -1 or self.transponderlist[index][9] == -1)): + index += 1 + print "FirstTransponder final index:", index + return index + + def nextTransponder(self): + print "getting next transponder", self.tuningtransponder + index = self.tuningtransponder + 1 + if self.checkPIDs: + print "checkPIDs-loop" + # check for tsid != -1 and onid != -1 + print "index:", index + print "len(self.transponderlist):", len(self.transponderlist) + while (index < len(self.transponderlist) and (self.transponderlist[index][8] == -1 or self.transponderlist[index][9] == -1)): + index += 1 + + print "next transponder index:", index + return index + + def finishedChecking(self): + print "finished testing" + print "successfull:", self.successfullyTune + print "failed:", self.failedTune + + def openFrontend(self): + res_mgr = eDVBResourceManager.getInstance() + if res_mgr: + self.raw_channel = res_mgr.allocateRawChannel(self.feid) + if self.raw_channel: + self.frontend = self.raw_channel.getFrontend() + if self.frontend: + return True + else: + print "getFrontend failed" + else: + print "getRawChannel failed" + else: + print "getResourceManager instance failed" + return False + + def tune(self): + print "tuning to", self.tuningtransponder + if self.tuningtransponder < len(self.transponderlist): + self.pidStatus = self.INTERNAL_PID_STATUS_NOOP + self.oldTuned = self.currTuned + self.currTuned = self.transponderlist[self.tuningtransponder] + self.tuner.tune(self.transponderlist[self.tuningtransponder]) + + INTERNAL_PID_STATUS_NOOP = 0 + INTERNAL_PID_STATUS_WAITING = 1 + INTERNAL_PID_STATUS_SUCCESSFUL = 2 + INTERNAL_PID_STATUS_FAILED = 3 + + def run(self, checkPIDs = False): + self.checkPIDs = checkPIDs + self.pidStatus = self.INTERNAL_PID_STATUS_NOOP + self.failedTune = [] + self.successfullyTune = [] + self.tuningtransponder = self.firstTransponder() + self.tune() + self.progressCallback((self.getProgressLength(), self.tuningtransponder, self.STATUS_START, self.currTuned)) + self.timer.start(100, True) + + # transponder = (frequency, symbolrate, polarisation, fec, inversion, orbpos, <system>, <modulation>, <tsid>, <onid>) + # 0 1 2 3 4 5 6 7 8 9 + def addTransponder(self, transponder): + self.transponderlist.append(transponder) + + def clearTransponder(self): + self.transponderlist = [] + + def getProgressLength(self): + count = 0 + if self.stopOnError == -1: + count = len(self.transponderlist) + else: + if count < self.stopOnError: + count = self.stopOnError + if self.stopOnSuccess == -1: + count = len(self.transponderlist) + else: + if count < self.stopOnSuccess: + count = self.stopOnSuccess + return count + + STATUS_START = 0 + STATUS_TUNING = 1 + STATUS_DONE = 2 + STATUS_NOOP = 3 + # can be overwritten + # progress = (range, value, status, transponder) + def progressCallback(self, progress): + pass
\ No newline at end of file diff --git a/lib/python/Components/TunerInfo.py b/lib/python/Components/TunerInfo.py index d8b4d064..39f54c0b 100644 --- a/lib/python/Components/TunerInfo.py +++ b/lib/python/Components/TunerInfo.py @@ -10,13 +10,14 @@ class TunerInfo(GUIComponent): BER = 2 LOCK = 3 SNR_PERCENTAGE = 0 - AGC_PERCENTAGE = 1 - BER_VALUE = 2 - SNR_BAR = 3 - AGC_BAR = 4 - BER_BAR = 5 - LOCK_STATE = 6 - SYNC_STATE = 7 + SNR_DB = 1 + AGC_PERCENTAGE = 2 + BER_VALUE = 3 + SNR_BAR = 4 + AGC_BAR = 5 + BER_BAR = 6 + LOCK_STATE = 7 + SYNC_STATE = 8 def __init__(self, type, servicefkt = None, frontendfkt = None, statusDict = None): GUIComponent.__init__(self) @@ -47,7 +48,9 @@ class TunerInfo(GUIComponent): return val*100/65535 def update(self): - if self.type == self.SNR_PERCENTAGE or self.type == self.SNR_BAR: + if self.type == self.SNR_DB: + value = self.getValue(self.SNR_DB) + elif self.type == self.SNR_PERCENTAGE or self.type == self.SNR_BAR: value = self.getValue(self.SNR) * 100 / 65536 elif self.type == self.AGC_PERCENTAGE or self.type == self.AGC_BAR: value = self.getValue(self.AGC) * 100 / 65536 @@ -55,8 +58,13 @@ class TunerInfo(GUIComponent): value = self.getValue(self.BER) elif self.type == self.LOCK_STATE: value = self.getValue(self.LOCK) - - if self.type == self.SNR_PERCENTAGE or self.type == self.AGC_PERCENTAGE: + + if self.type == self.SNR_DB: + if value != 0x12345678: + self.setText("%3.02f dB" % (value / 100.0)) + else: + self.setText("") + elif self.type == self.SNR_PERCENTAGE or self.type == self.AGC_PERCENTAGE: self.setText("%d%%" % (value)) elif self.type == self.BER_VALUE: self.setText("%d" % (value)) @@ -72,7 +80,9 @@ class TunerInfo(GUIComponent): def getValue(self, what): if self.statusDict: - if what == self.SNR: + if what == self.SNR_DB: + return self.statusDict.get("tuner_signal_quality_db", 0x12345678) + elif what == self.SNR: return self.statusDict.get("tuner_signal_quality", 0) elif what == self.AGC: return self.statusDict.get("tuner_signal_power", 0) @@ -85,7 +95,9 @@ class TunerInfo(GUIComponent): if service is not None: feinfo = service.frontendInfo() if feinfo is not None: - if what == self.SNR: + if what == self.SNR_DB: + return feinfo.getFrontendInfo(iFrontendInformation.signalQualitydB) + elif what == self.SNR: return feinfo.getFrontendInfo(iFrontendInformation.signalQuality) elif what == self.AGC: return feinfo.getFrontendInfo(iFrontendInformation.signalPower) @@ -96,7 +108,9 @@ class TunerInfo(GUIComponent): elif self.frontendfkt: frontend = self.frontendfkt() if frontend: - if what == self.SNR: + if what == self.SNR_DB: + return frontend.readFrontendData(iFrontendInformation.signalQualitydB) + elif what == self.SNR: return frontend.readFrontendData(iFrontendInformation.signalQuality) elif what == self.AGC: return frontend.readFrontendData(iFrontendInformation.signalPower) diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index 6ed87840..21e057f2 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -17,12 +17,12 @@ def InitUsageConfig(): config.usage.show_infobar_on_zap = ConfigYesNo(default = True) config.usage.show_infobar_on_skip = ConfigYesNo(default = True) config.usage.show_infobar_on_event_change = ConfigYesNo(default = True) - config.usage.hdd_standby = ConfigSelection(default = "120", choices = [ - ("0", _("no standby")), ("2", "10 " + _("seconds")), ("6", "30 " + _("seconds")), - ("12", "1 " + _("minute")), ("24", "2 " + _("minutes")), - ("60", "5 " + _("minutes")), ("120", "10 " + _("minutes")), ("240", "20 " + _("minutes")), - ("241", "30 " + _("minutes")), ("242", "1 " + _("hour")), ("244", "2 " + _("hours")), - ("248", "4 " + _("hours")) ]) + config.usage.hdd_standby = ConfigSelection(default = "600", choices = [ + ("0", _("no standby")), ("10", "10 " + _("seconds")), ("30", "30 " + _("seconds")), + ("60", "1 " + _("minute")), ("120", "2 " + _("minutes")), + ("300", "5 " + _("minutes")), ("600", "10 " + _("minutes")), ("1200", "20 " + _("minutes")), + ("1800", "30 " + _("minutes")), ("3600", "1 " + _("hour")), ("7200", "2 " + _("hours")), + ("14400", "4 " + _("hours")) ]) config.usage.output_12V = ConfigSelection(default = "do not change", choices = [ ("do not change", _("do not change")), ("off", _("off")), ("on", _("on")) ]) @@ -66,7 +66,7 @@ def InitUsageConfig(): def setHDDStandby(configElement): for hdd in harddiskmanager.HDDList(): - os.system("hdparm -S%s %s" % (configElement.value, hdd[1].getDeviceName())) + hdd[1].setIdleTime(int(configElement.value)) config.usage.hdd_standby.addNotifier(setHDDStandby) def set12VOutput(configElement): @@ -89,8 +89,8 @@ def InitUsageConfig(): config.seek.speeds_backward = ConfigSet(default=[8, 16, 32, 64, 128], choices=[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128]) config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25]) - config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2"]) - config.seek.enter_backward = ConfigSelection(default = "2", choices = ["2"]) + config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) + config.seek.enter_backward = ConfigSelection(default = "1", choices = ["1", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) config.seek.stepwise_minspeed = ConfigSelection(default = "16", choices = ["Never", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) config.seek.stepwise_repeat = ConfigSelection(default = "3", choices = ["2", "3", "4", "5", "6"]) @@ -104,14 +104,14 @@ def InitUsageConfig(): configElement.value = [2] updateChoices(config.seek.enter_forward, configElement.value) - config.seek.speeds_forward.addNotifier(updateEnterForward) + config.seek.speeds_forward.addNotifier(updateEnterForward, immediate_feedback = False) def updateEnterBackward(configElement): if not configElement.value: configElement.value = [2] updateChoices(config.seek.enter_backward, configElement.value) - config.seek.speeds_backward.addNotifier(updateEnterBackward) + config.seek.speeds_backward.addNotifier(updateEnterBackward, immediate_feedback = False) def updateChoices(sel, choices): if choices: diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 4d57bbb9..eaf07180 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -1,10 +1,10 @@ -import time from enigma import getPrevAsciiCode from Tools.NumericalTextInput import NumericalTextInput from Tools.Directories import resolveFilename, SCOPE_CONFIG from Components.Harddisk import harddiskmanager -import copy -import os +from copy import copy as copy_copy +from os import path as os_path +from time import localtime, strftime # ConfigElement, the base class of all ConfigElements. @@ -28,11 +28,12 @@ import os # class ConfigElement(object): def __init__(self): - object.__init__(self) self.saved_value = None + self.last_value = None self.save_disabled = False self.notifiers = [] + self.notifiers_final = [] self.enabled = True self.callNotifiersOnSaveAndCancel = False @@ -85,10 +86,16 @@ class ConfigElement(object): for x in self.notifiers: x(self) - def addNotifier(self, notifier, initial_call = True): + def changedFinal(self): + for x in self.notifiers_final: + x(self) + + def addNotifier(self, notifier, initial_call = True, immediate_feedback = True): assert callable(notifier), "notifiers must be callable" - self.notifiers.append(notifier) - + if immediate_feedback: + self.notifiers.append(notifier) + else: + self.notifiers_final.append(notifier) # CHECKME: # do we want to call the notifier # - at all when adding it? (yes, though optional) @@ -110,7 +117,9 @@ class ConfigElement(object): pass def onDeselect(self, session): - pass + if not self.last_value == self.value: + self.changedFinal() + self.last_value = self.value KEY_LEFT = 0 KEY_RIGHT = 1 @@ -130,6 +139,107 @@ def getKeyNumber(key): assert key in KEY_NUMBERS return key - KEY_0 +class choicesList(object): # XXX: we might want a better name for this + LIST_TYPE_LIST = 1 + LIST_TYPE_DICT = 2 + + def __init__(self, choices, type = None): + object.__init__(self) + self.choices = choices + if type is None: + if isinstance(choices, list): + self.type = choicesList.LIST_TYPE_LIST + elif isinstance(choices, dict): + self.type = choicesList.LIST_TYPE_DICT + else: + assert False, "choices must be dict or list!" + else: + self.type = type + + def __list__(self): + if self.type == choicesList.LIST_TYPE_LIST: + ret = [isinstance(x, tuple) and x[0] or x for x in self.choices] + else: + ret = self.choices.keys() + return ret or [""] + + def __iter__(self): + if self.type == choicesList.LIST_TYPE_LIST: + ret = [isinstance(x, tuple) and x[0] or x for x in self.choices] + else: + ret = self.choices + return iter(ret or [""]) + + def __len__(self): + return len(self.choices) or 1 + + def __getitem__(self, index): + if self.type == choicesList.LIST_TYPE_LIST: + ret = self.choices[index] + if isinstance(ret, tuple): + ret = ret[0] + return ret + return self.choices.keys()[index] + + def index(self, value): + return self.__list__().index(value) + + def __setitem__(self, index, value): + if self.type == choicesList.LIST_TYPE_LIST: + orig = self.choices[index] + if isinstance(orig, tuple): + self.choices[index] = (value, orig[1]) + else: + self.choices[index] = value + else: + key = self.choices.keys()[index] + orig = self.choices[key] + del self.choices[key] + self.choices[value] = orig + + def default(self): + if self.type is choicesList.LIST_TYPE_LIST: + default = self.choices[0] + if isinstance(default, tuple): + default = default[0] + else: + default = self.choices.keys()[0] + return default + +class descriptionList(choicesList): # XXX: we might want a better name for this + def __list__(self): + if self.type == choicesList.LIST_TYPE_LIST: + ret = [isinstance(x, tuple) and x[1] or x for x in self.choices] + else: + ret = self.choices.values() + return ret or [""] + + def __iter__(self): + return iter(self.__list__()) + + def __getitem__(self, index): + if self.type == choicesList.LIST_TYPE_LIST: + for x in self.choices: + if isinstance(x, tuple): + if x[0] == index: + return str(x[1]) + elif x == index: + return str(x) + return str(index) # Fallback! + else: + return str(self.choices.get(index, "")) + + def __setitem__(self, index, value): + if self.type == choicesList.LIST_TYPE_LIST: + i = self.index(index) + orig = self.choices[i] + if isinstance(orig, tuple): + self.choices[i] = (orig[0], value) + else: + self.choices[i] = value + else: + self.choices[index] = value + # # ConfigSelection is a "one of.."-type. # it has the "choices", usually a list, which contains @@ -141,43 +251,21 @@ def getKeyNumber(key): class ConfigSelection(ConfigElement): def __init__(self, choices, default = None): ConfigElement.__init__(self) - self._value = None - self.setChoices(choices, default) + self.choices = choicesList(choices) + + if default is None: + default = self.choices.default() + + self.default = self._value = self.last_value = default + self.changed() def setChoices(self, choices, default = None): - self.choices = [] - self.description = {} - - if isinstance(choices, list): - for x in choices: - if isinstance(x, tuple): - self.choices.append(x[0]) - self.description[x[0]] = x[1] - else: - self.choices.append(x) - self.description[x] = x - elif isinstance(choices, dict): - for (key, val) in choices.items(): - self.choices.append(key) - self.description[key] = val - else: - assert False, "ConfigSelection choices must be dict or list!" - - #assert len(self.choices), "you can't have an empty configselection" - if len(self.choices) == 0: - self.choices = [""] - self.description[""] = "" + self.choices = choicesList(choices) if default is None: - default = self.choices[0] - - assert default in self.choices, "default must be in choice list, but " + repr(default) + " is not!" - for x in self.choices: - assert isinstance(x, str), "ConfigSelection choices must be strings" - - self.default = default + default = self.choices.default() - if self.value == None or not self.value in self.choices: + if self.value not in self.choices: self.value = default def setValue(self, value): @@ -185,7 +273,6 @@ class ConfigSelection(ConfigElement): self._value = value else: self._value = self.default - self.changed() def tostring(self, val): @@ -196,7 +283,6 @@ class ConfigSelection(ConfigElement): def setCurrentText(self, text): i = self.choices.index(self.value) - del self.description[self.choices[i]] self.choices[i] = text self.description[text] = text self._value = text @@ -220,7 +306,7 @@ class ConfigSelection(ConfigElement): self.value = self.choices[0] elif key == KEY_END: self.value = self.choices[nchoices - 1] - + def selectNext(self): nchoices = len(self.choices) i = self.choices.index(self.value) @@ -242,27 +328,32 @@ class ConfigSelection(ConfigElement): def getHTML(self, id): res = "" for v in self.choices: + descr = self.description[v] if self.value == v: checked = 'checked="checked" ' else: checked = '' - res += '<input type="radio" name="' + id + '" ' + checked + 'value="' + v + '">' + self.description[v] + "</input></br>\n" + res += '<input type="radio" name="' + id + '" ' + checked + 'value="' + v + '">' + descr + "</input></br>\n" return res; def unsafeAssign(self, value): # setValue does check if value is in choices. This is safe enough. self.value = value + description = property(lambda self: descriptionList(self.choices.choices, self.choices.type)) + # a binary decision. # # several customized versions exist for different # descriptions. # +boolean_descriptions = {False: "false", True: "true"} class ConfigBoolean(ConfigElement): - def __init__(self, default = False, descriptions = {False: "false", True: "true"}): + def __init__(self, default = False, descriptions = boolean_descriptions): ConfigElement.__init__(self) self.descriptions = descriptions - self.value = self.default = default + self.value = self.last_value = self.default = default + def handleKey(self, key): if key in [KEY_LEFT, KEY_RIGHT]: self.value = not self.value @@ -309,24 +400,32 @@ class ConfigBoolean(ConfigElement): else: self.value = False + def onDeselect(self, session): + if not self.last_value == self.value: + self.changedFinal() + self.last_value = self.value + +yes_no_descriptions = {False: _("no"), True: _("yes")} class ConfigYesNo(ConfigBoolean): def __init__(self, default = False): - ConfigBoolean.__init__(self, default = default, descriptions = {False: _("no"), True: _("yes")}) + ConfigBoolean.__init__(self, default = default, descriptions = yes_no_descriptions) +on_off_descriptions = {False: _("off"), True: _("on")} class ConfigOnOff(ConfigBoolean): def __init__(self, default = False): - ConfigBoolean.__init__(self, default = default, descriptions = {False: _("off"), True: _("on")}) + ConfigBoolean.__init__(self, default = default, descriptions = on_off_descriptions) +enable_disable_descriptions = {False: _("disable"), True: _("enable")} class ConfigEnableDisable(ConfigBoolean): def __init__(self, default = False): - ConfigBoolean.__init__(self, default = default, descriptions = {False: _("disable"), True: _("enable")}) + ConfigBoolean.__init__(self, default = default, descriptions = enable_disable_descriptions) class ConfigDateTime(ConfigElement): def __init__(self, default, formatstring, increment = 86400): ConfigElement.__init__(self) self.increment = increment self.formatstring = formatstring - self.value = self.default = int(default) + self.value = self.last_value = self.default = int(default) def handleKey(self, key): if key == KEY_LEFT: @@ -337,10 +436,10 @@ class ConfigDateTime(ConfigElement): self.value = self.default def getText(self): - return time.strftime(self.formatstring, time.localtime(self.value)) + return strftime(self.formatstring, localtime(self.value)) def getMulti(self, selected): - return ("text", time.strftime(self.formatstring, time.localtime(self.value))) + return ("text", strftime(self.formatstring, localtime(self.value))) def fromstring(self, val): return int(val) @@ -352,7 +451,7 @@ class ConfigDateTime(ConfigElement): # several helper exist to ease this up a bit. # class ConfigSequence(ConfigElement): - def __init__(self, seperator, limits, censor_char = "", default = None): + def __init__(self, seperator, limits, default, censor_char = ""): ConfigElement.__init__(self) assert isinstance(limits, list) and len(limits[0]) == 2, "limits must be [(min, max),...]-tuple-list" assert censor_char == "" or len(censor_char) == 1, "censor char must be a single char (or \"\")" @@ -364,11 +463,10 @@ class ConfigSequence(ConfigElement): self.seperator = seperator self.limits = limits self.censor_char = censor_char - - self.default = default - self.value = copy.copy(default) - - self.endNotifier = [] + + self.last_value = self.default = default + self.value = copy_copy(default) + self.endNotifier = None def validate(self): max_pos = 0 @@ -385,8 +483,9 @@ class ConfigSequence(ConfigElement): num += 1 if self.marked_pos >= max_pos: - for x in self.endNotifier: - x(self) + if endNotifier: + for x in self.endNotifier: + x(self) self.marked_pos = max_pos - 1 if self.marked_pos < 0: @@ -395,13 +494,15 @@ class ConfigSequence(ConfigElement): def validatePos(self): if self.marked_pos < 0: self.marked_pos = 0 - + total_len = sum([len(str(x[1])) for x in self.limits]) if self.marked_pos >= total_len: self.marked_pos = total_len - 1 - + def addEndNotifier(self, notifier): + if endNotifier is None: + endNotifier = [] self.endNotifier.append(notifier) def handleKey(self, key): @@ -412,7 +513,7 @@ class ConfigSequence(ConfigElement): if key == KEY_RIGHT: self.marked_pos += 1 self.validatePos() - + if key == KEY_HOME: self.marked_pos = 0 self.validatePos() @@ -425,7 +526,7 @@ class ConfigSequence(ConfigElement): num += 1 self.marked_pos = max_pos - 1 self.validatePos() - + if key in KEY_NUMBERS or key == KEY_ASCII: if key == KEY_ASCII: code = getPrevAsciiCode() @@ -434,11 +535,11 @@ class ConfigSequence(ConfigElement): number = code - 48 else: number = getKeyNumber(key) - + block_len = [] for x in self.limits: block_len.append(len(str(x[1]))) - + total_len = sum(block_len) pos = 0 @@ -457,17 +558,17 @@ class ConfigSequence(ConfigElement): # position in the block posinblock = self.marked_pos - block_len_total[blocknumber] - + oldvalue = self._value[blocknumber] olddec = oldvalue % 10 ** (number_len - posinblock) - (oldvalue % 10 ** (number_len - posinblock - 1)) newvalue = oldvalue - olddec + (10 ** (number_len - posinblock - 1) * number) - + self._value[blocknumber] = newvalue self.marked_pos += 1 - + self.validate() self.changed() - + def genText(self): value = "" mPos = self.marked_pos @@ -477,18 +578,17 @@ class ConfigSequence(ConfigElement): value += self.seperator if mPos >= len(value) - 1: mPos += 1 - if self.censor_char == "": value += ("%0" + str(len(str(self.limits[num][1]))) + "d") % i else: value += (self.censor_char * len(str(self.limits[num][1]))) num += 1 return (value, mPos) - + def getText(self): (value, mPos) = self.genText() return value - + def getMulti(self, selected): (value, mPos) = self.genText() # only mark cursor when we are selected @@ -500,16 +600,22 @@ class ConfigSequence(ConfigElement): def tostring(self, val): return self.seperator.join([self.saveSingle(x) for x in val]) - + def saveSingle(self, v): return str(v) def fromstring(self, value): return [int(x) for x in value.split(self.seperator)] + def onDeselect(self, session): + if self.last_value != self._value: + self.changedFinal() + self.last_value = copy_copy(self._value) + +ip_limits = [(0,255),(0,255),(0,255),(0,255)] class ConfigIP(ConfigSequence): def __init__(self, default, auto_jump = False): - ConfigSequence.__init__(self, seperator = ".", limits = [(0,255),(0,255),(0,255),(0,255)], default = default) + ConfigSequence.__init__(self, seperator = ".", limits = ip_limits, default = default) self.block_len = [] for x in self.limits: self.block_len.append(len(str(x[1]))) @@ -590,22 +696,54 @@ class ConfigIP(ConfigSequence): # we definitely don't want leading zeros return '.'.join(["%d" % d for d in self.value]) +mac_limits = [(1,255),(1,255),(1,255),(1,255),(1,255),(1,255)] class ConfigMAC(ConfigSequence): def __init__(self, default): - ConfigSequence.__init__(self, seperator = ":", limits = [(1,255),(1,255),(1,255),(1,255),(1,255),(1,255)], default = default) + ConfigSequence.__init__(self, seperator = ":", limits = mac_limits, default = default) class ConfigPosition(ConfigSequence): def __init__(self, default, args): ConfigSequence.__init__(self, seperator = ",", limits = [(0,args[0]),(0,args[1]),(0,args[2]),(0,args[3])], default = default) +clock_limits = [(0,23),(0,59)] class ConfigClock(ConfigSequence): def __init__(self, default): - import time - t = time.localtime(default) - ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = [t.tm_hour, t.tm_min]) + t = localtime(default) + ConfigSequence.__init__(self, seperator = ":", limits = clock_limits, default = [t.tm_hour, t.tm_min]) + + def increment(self): + # Check if Minutes maxed out + if self._value[1] == 59: + # Increment Hour, reset Minutes + if self._value[0] < 23: + self._value[0] += 1 + else: + self._value[0] = 0 + self._value[1] = 0 + else: + # Increment Minutes + self._value[1] += 1 + # Trigger change + self.changed() + + def decrement(self): + # Check if Minutes is minimum + if self._value[1] == 0: + # Decrement Hour, set Minutes to 59 + if self._value[0] > 0: + self._value[0] -= 1 + else: + self._value[0] = 23 + self._value[1] = 59 + else: + # Decrement Minutes + self._value[1] -= 1 + # Trigger change + self.changed() +integer_limits = (0, 9999999999) class ConfigInteger(ConfigSequence): - def __init__(self, default, limits = (0, 9999999999)): + def __init__(self, default, limits = integer_limits): ConfigSequence.__init__(self, seperator = ":", limits = [limits], default = default) # you need to override this to do input validation @@ -615,7 +753,7 @@ class ConfigInteger(ConfigSequence): def getValue(self): return self._value[0] - + value = property(getValue, setValue) def fromstring(self, value): @@ -657,7 +795,7 @@ class ConfigText(ConfigElement, NumericalTextInput): self.offset = 0 self.overwrite = fixed_size self.help_window = None - self.value = self.default = default + self.value = self.last_value = self.default = default def validateMarker(self): if self.fixed_size: @@ -823,6 +961,9 @@ class ConfigText(ConfigElement, NumericalTextInput): if self.help_window: session.deleteDialog(self.help_window) self.help_window = None + if not self.last_value == self.value: + self.changedFinal() + self.last_value = self.value def getHTML(self, id): return '<input type="text" name="' + id + '" value="' + self.value + '" /><br>\n' @@ -897,12 +1038,40 @@ class ConfigNumber(ConfigText): def onDeselect(self, session): self.marked_pos = 0 self.offset = 0 + if not self.last_value == self.value: + self.changedFinal() + self.last_value = self.value + +class ConfigSearchText(ConfigText): + def __init__(self, default = "", fixed_size = False, visible_width = False): + ConfigText.__init__(self, default = default, fixed_size = fixed_size, visible_width = visible_width) + NumericalTextInput.__init__(self, nextFunc = self.nextFunc, handleTimeout = False, search = True) + +class ConfigDirectory(ConfigText): + def __init__(self, default="", visible_width=60): + ConfigText.__init__(self, default, fixed_size = True, visible_width = visible_width) + def handleKey(self, key): + pass + def getValue(self): + if self.text == "": + return None + else: + return ConfigText.getValue(self) + def setValue(self, val): + if val == None: + val = "" + ConfigText.setValue(self, val) + def getMulti(self, selected): + if self.text == "": + return ("mtext"[1-selected:], _("List of Storage Devices"), range(0)) + else: + return ConfigText.getMulti(self, selected) # a slider. class ConfigSlider(ConfigElement): def __init__(self, default = 0, increment = 1, limits = (0, 100)): ConfigElement.__init__(self) - self.value = self.default = default + self.value = self.last_value = self.default = default self.min = limits[0] self.max = limits[1] self.increment = increment @@ -954,28 +1123,17 @@ class ConfigSatlist(ConfigSelection): class ConfigSet(ConfigElement): def __init__(self, choices, default = []): ConfigElement.__init__(self) - self.choices = [] - self.description = {} if isinstance(choices, list): choices.sort() - for x in choices: - if isinstance(x, tuple): - self.choices.append(x[0]) - self.description[x[0]] = str(x[1]) - else: - self.choices.append(x) - self.description[x] = str(x) + self.choices = choicesList(choices, choicesList.LIST_TYPE_LIST) else: assert False, "ConfigSet choices must be a list!" - if len(self.choices) == 0: - self.choices = [""] - self.description[""] = "" if default is None: default = [] self.pos = -1 default.sort() - self.default = default - self.value = default+[] + self.last_value = self.default = default + self.value = default[:] def toggleChoice(self, choice): if choice in self.value: @@ -983,6 +1141,7 @@ class ConfigSet(ConfigElement): else: self.value.append(choice) self.value.sort() + self.changed() def handleKey(self, key): if key in KEY_NUMBERS + [KEY_DELETE, KEY_BACKSPACE]: @@ -1012,7 +1171,7 @@ class ConfigSet(ConfigElement): if not selected or self.pos == -1: return ("text", self.genString(self.value)) else: - tmp = self.value+[] + tmp = self.value[:] ch = self.choices[self.pos] mem = ch in self.value if not mem: @@ -1029,7 +1188,9 @@ class ConfigSet(ConfigElement): def onDeselect(self, session): self.pos = -1 - self.changed() + if not self.last_value == self.value: + self.changedFinal() + self.last_value = self.value[:] def tostring(self, value): return str(value) @@ -1037,6 +1198,8 @@ class ConfigSet(ConfigElement): def fromstring(self, val): return eval(val) + description = property(lambda self: descriptionList(self.choices.choices, choicesList.LIST_TYPE_LIST)) + class ConfigLocations(ConfigElement): def __init__(self, default = [], visible_width = False): ConfigElement.__init__(self) @@ -1046,6 +1209,7 @@ class ConfigLocations(ConfigElement): self.locations = [] self.mountpoints = [] harddiskmanager.on_partition_list_change.append(self.mountpointsChanged) + self.value = default+[] def setValue(self, value): loc = [x[0] for x in self.locations if x[3]] @@ -1078,7 +1242,7 @@ class ConfigLocations(ConfigElement): self.locations = [[x, None, False, False] for x in tmp] self.refreshMountpoints() for x in self.locations: - if os.path.exists(x[0]): + if os_path.exists(x[0]): x[1] = self.getMountpoint(x[0]) x[2] = True @@ -1107,7 +1271,7 @@ class ConfigLocations(ConfigElement): for x in self.locations: if x[1] == mp: x[2] = True - elif x[1] == None and os.path.exists(x[0]): + elif x[1] == None and os_path.exists(x[0]): x[1] = self.getMountpoint(x[0]) x[2] = True @@ -1133,7 +1297,7 @@ class ConfigLocations(ConfigElement): self.addedMount(x) def getMountpoint(self, file): - file = os.path.realpath(file)+"/" + file = os_path.realpath(file)+"/" for m in self.mountpoints: if file.startswith(m): return m @@ -1230,7 +1394,7 @@ class ConfigSubList(list, object): x.load() def getSavedValue(self): - res = {} + res = { } for i in range(len(self)): sv = self[i].saved_value if sv is not None: @@ -1253,10 +1417,7 @@ class ConfigSubList(list, object): item.load() def dict(self): - res = dict() - for index in range(len(self)): - res[str(index)] = self[index] - return res + return dict([(str(index), value) for index, value in self.enumerate()]) # same as ConfigSubList, just as a dictionary. # care must be taken that the 'key' has a proper @@ -1322,11 +1483,12 @@ class ConfigSubsection(object): def __setattr__(self, name, value): if name == "saved_value": return self.setSavedValue(value) - assert isinstance(value, ConfigSubsection) or isinstance(value, ConfigElement) or isinstance(value, ConfigSubList) or isinstance(value, ConfigSubDict), "ConfigSubsections can only store ConfigSubsections, ConfigSubLists, ConfigSubDicts or ConfigElements" + assert isinstance(value, (ConfigSubsection, ConfigElement, ConfigSubList, ConfigSubDict)), "ConfigSubsections can only store ConfigSubsections, ConfigSubLists, ConfigSubDicts or ConfigElements" self.content.items[name] = value - if name in self.content.stored_values: - #print "ok, now we have a new item,", name, "and have the following value for it:", self.content.stored_values[name] - value.saved_value = self.content.stored_values[name] + x = self.content.stored_values.get(name, None) + if x is not None: + #print "ok, now we have a new item,", name, "and have the following value for it:", x + value.saved_value = x value.load() def __getattr__(self, name): @@ -1344,12 +1506,11 @@ class ConfigSubsection(object): def setSavedValue(self, values): values = dict(values) - self.content.stored_values = values - for (key, val) in self.content.items.items(): - if key in values: - val.saved_value = values[key] + value = values.get(key, None) + if value is not None: + val.saved_value = value saved_value = property(getSavedValue, setSavedValue) @@ -1377,19 +1538,18 @@ class Config(ConfigSubsection): def pickle_this(self, prefix, topickle, result): for (key, val) in topickle.items(): - name = prefix + "." + key - + name = ''.join((prefix, '.', key)) if isinstance(val, dict): self.pickle_this(name, val, result) elif isinstance(val, tuple): - result.append(name + "=" + val[0]) # + " ; " + val[1]) + result += [name, '=', val[0], '\n'] else: - result.append(name + "=" + val) + result += [name, '=', val, '\n'] def pickle(self): - result = [ ] + result = [] self.pickle_this("config", self.saved_value, result) - return '\n'.join(result) + "\n" + return ''.join(result) def unpickle(self, lines): tree = { } diff --git a/lib/python/Components/language_cache.py b/lib/python/Components/language_cache.py index 046f281d..a9c02bc0 100644 --- a/lib/python/Components/language_cache.py +++ b/lib/python/Components/language_cache.py @@ -4,6 +4,7 @@ LANG_TEXT = { "fr_FR": "French", "fi_FI": "Finnish", "pt_PT": "Portuguese", + "fy_x-FY": "Frisian", "it_IT": "Italian", "no_NO": "Norwegian", "nl_NL": "Dutch", @@ -21,6 +22,7 @@ LANG_TEXT = { "tr_TR": "Turkish", "de_DE": "German", "ar_AE": "Arabic", + "uk_UA": "Ukrainian", "sv_SE": "Swedish", "pl_PL": "Polish", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -30,6 +32,7 @@ LANG_TEXT = { "fr_FR": "Französisch", "fi_FI": "Finnisch", "pt_PT": "portugiesisch", + "fy_x-FY": "Frisian", "it_IT": "Italienisch", "no_NO": "Norwegisch", "nl_NL": "Holländisch", @@ -47,6 +50,7 @@ LANG_TEXT = { "tr_TR": "Türkisch", "de_DE": "Deutsch", "ar_AE": "Arabisch", + "uk_UA": "Ukrainian", "sv_SE": "Schwedisch", "pl_PL": "Polnisch", "T1": "Bitte benutzen Sie die Hoch/Runter-Tasten, um Ihre Sprache auszuwählen. Danach drücken Sie bitte OK.", @@ -56,6 +60,7 @@ LANG_TEXT = { "fr_FR": "French", "fi_FI": "Finnish", "pt_PT": "Portuguese", + "fy_x-FY": "Frisian", "it_IT": "Italian", "no_NO": "Norwegian", "nl_NL": "Dutch", @@ -73,6 +78,7 @@ LANG_TEXT = { "tr_TR": "Turkish", "de_DE": "المانـى", "ar_AE": "Arabic", + "uk_UA": "Ukrainian", "sv_SE": "Swedish", "pl_PL": "Polish", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -82,6 +88,7 @@ LANG_TEXT = { "fr_FR": "Francès", "fi_FI": "Finlandès", "pt_PT": "Portuguès", + "fy_x-FY": "Frisian", "it_IT": "Italià", "no_NO": "Noruec", "nl_NL": "Holandès", @@ -99,6 +106,7 @@ LANG_TEXT = { "tr_TR": "Turc", "de_DE": "Alemany", "ar_AE": "Àrab", + "uk_UA": "Ukrainian", "sv_SE": "Suec", "pl_PL": "Polish", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -108,6 +116,7 @@ LANG_TEXT = { "fr_FR": "Francuski", "fi_FI": "Finski", "pt_PT": "Portugalski", + "fy_x-FY": "Frisian", "it_IT": "Talijanski", "no_NO": "Norveški", "nl_NL": "Nizozemski", @@ -125,6 +134,7 @@ LANG_TEXT = { "tr_TR": "Turski", "de_DE": "Njemački", "ar_AE": "Arabski", + "uk_UA": "Ukrainian", "sv_SE": "Švedski", "pl_PL": "Poljski", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -134,6 +144,7 @@ LANG_TEXT = { "fr_FR": "Francouzsky", "fi_FI": "Finsky", "pt_PT": "Portugalsky", + "fy_x-FY": "Frisian", "it_IT": "Italsky", "no_NO": "Norsky", "nl_NL": "Holandsky", @@ -151,6 +162,7 @@ LANG_TEXT = { "tr_TR": "Turecky", "de_DE": "Německy", "ar_AE": "Arabsky", + "uk_UA": "Ukrainian", "sv_SE": "Švédsky", "pl_PL": "Polsky", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -160,6 +172,7 @@ LANG_TEXT = { "fr_FR": "Fransk", "fi_FI": "Finsk", "pt_PT": "Portugisisk", + "fy_x-FY": "Frisian", "it_IT": "Italiensk", "no_NO": "Norsk", "nl_NL": "Hollandsk", @@ -177,6 +190,7 @@ LANG_TEXT = { "tr_TR": "Tyrkisk", "de_DE": "Tysk", "ar_AE": "Arabisk", + "uk_UA": "Ukrainian", "sv_SE": "Svensk", "pl_PL": "Polsk", "T1": "Benyt venligst OP og NED tasten til at vælge sprog. Tryk bagefter på OK knappen.", @@ -186,6 +200,7 @@ LANG_TEXT = { "fr_FR": "Frans", "fi_FI": "Fins", "pt_PT": "Portugees", + "fy_x-FY": "Frisian", "it_IT": "Italiaans", "no_NO": "Noors", "nl_NL": "Nederlands", @@ -203,6 +218,7 @@ LANG_TEXT = { "tr_TR": "Turks", "de_DE": "Duits", "ar_AE": "Arabisch", + "uk_UA": "Ukrainian", "sv_SE": "Zweeds", "pl_PL": "Pools", "T1": "Gebruik de omhoog/omlaag toeten om de gewenste taal te selecteren. Druk daarna op OK.", @@ -212,6 +228,7 @@ LANG_TEXT = { "fr_FR": "Ranska", "fi_FI": "Suomi", "pt_PT": "Portugali", + "fy_x-FY": "Frisian", "it_IT": "Italia", "no_NO": "Norja", "nl_NL": "Hollanti", @@ -229,15 +246,17 @@ LANG_TEXT = { "tr_TR": "Turkki", "de_DE": "Saksa", "ar_AE": "Arabia", + "uk_UA": "Ukrainian", "sv_SE": "Ruotsi", "pl_PL": "Puola", - "T1": "Valitse kieli ylös/alas nappuloilla ja paina OK.", + "T1": "Valitse kieli ylös/alas näppäimillä ja paina OK-näppäintä.", "T2": "Kielivalinta", }, "fr_FR": { "fr_FR": "Français", "fi_FI": "Finlandais", "pt_PT": "Portugais", + "fy_x-FY": "Frisian", "it_IT": "Italien", "no_NO": "Norvégien", "nl_NL": "Hollandais", @@ -255,6 +274,7 @@ LANG_TEXT = { "tr_TR": "Turke", "de_DE": "Allemand", "ar_AE": "Arabe", + "uk_UA": "Ukrainian", "sv_SE": "Suédois", "pl_PL": "Polonais", "T1": "Veuillez utiliser les touches HAUT et BAS pour choisir votre langage. Ensuite presser le bouton OK.", @@ -264,6 +284,7 @@ LANG_TEXT = { "fr_FR": "Γαλλικά", "fi_FI": "Φιλλανδικά", "pt_PT": "Πορτογαλλικά", + "fy_x-FY": "Frisian", "it_IT": "Ιταλικά", "no_NO": "Νορβηφικά", "nl_NL": "Ολλανδικά", @@ -281,6 +302,7 @@ LANG_TEXT = { "tr_TR": "Τούρκικα", "de_DE": "Γερμανικά", "ar_AE": "Αραβικά", + "uk_UA": "Ukrainian", "sv_SE": "Σουιδεζικά", "pl_PL": "Πολωνικά", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -290,6 +312,7 @@ LANG_TEXT = { "fr_FR": "Francia", "fi_FI": "Finn", "pt_PT": "Portugál", + "fy_x-FY": "Frisian", "it_IT": "Olasz", "no_NO": "Norvég", "nl_NL": "Holland", @@ -307,6 +330,7 @@ LANG_TEXT = { "tr_TR": "Török", "de_DE": "Német", "ar_AE": "Arab", + "uk_UA": "Ukrainian", "sv_SE": "Svéd", "pl_PL": "Lengyel", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -316,6 +340,7 @@ LANG_TEXT = { "fr_FR": "Prancūzų", "fi_FI": "Suomių", "pt_PT": "Portugalų", + "fy_x-FY": "Frisian", "it_IT": "Italų", "no_NO": "Norvegų", "nl_NL": "Olandų", @@ -333,6 +358,7 @@ LANG_TEXT = { "tr_TR": "Turkų", "de_DE": "Vokiečių", "ar_AE": "Arabų", + "uk_UA": "Ukrainiečių", "sv_SE": "Švedų", "pl_PL": "Lenkų", "T1": "Prašome naudoti AUKŠTYN IR ŽEMYN mygtukus, kad išsirinktumėte savo kalbą. Po to spauskite OK mygtuką.", @@ -342,6 +368,7 @@ LANG_TEXT = { "fr_FR": "Franska", "fi_FI": "Finnska", "pt_PT": "Portúgalska", + "fy_x-FY": "Frisian", "it_IT": "Ítalska", "no_NO": "Norska", "nl_NL": "Hollenska", @@ -359,15 +386,17 @@ LANG_TEXT = { "tr_TR": "Tyrkneska", "de_DE": "Þýska", "ar_AE": "Arabíska", + "uk_UA": "Ukrainian", "sv_SE": "Sænskt", "pl_PL": "Pólska", - "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", + "T1": "Vinsamlega notið UP og NIÐUR takka til að velja tungumál. Ýttu svo á OK til að nota.", "T2": "Val tungumáls", }, "it_IT": { "fr_FR": "Francese", "fi_FI": "Finlandese", "pt_PT": "Portoghese", + "fy_x-FY": "Frisian", "it_IT": "Italiano", "no_NO": "Norvegese", "nl_NL": "Olandese", @@ -385,6 +414,7 @@ LANG_TEXT = { "tr_TR": "Turco", "de_DE": "Tedesco", "ar_AE": "Arabo", + "uk_UA": "Ucraino", "sv_SE": "Svedese", "pl_PL": "Polacco", "T1": "Selezionare la propria lingua utilizzando i tasti Sù/Giù. Premere OK per confermare.", @@ -394,6 +424,7 @@ LANG_TEXT = { "fr_FR": "Fransk", "fi_FI": "Finsk", "pt_PT": "Portugisisk", + "fy_x-FY": "Frisian", "it_IT": "Italiensk", "no_NO": "Norsk", "nl_NL": "Nederlandsk", @@ -411,6 +442,7 @@ LANG_TEXT = { "tr_TR": "Tyrkisk", "de_DE": "Tysk", "ar_AE": "Arabisk", + "uk_UA": "Ukrainian", "sv_SE": "Svensk", "pl_PL": "Polsk", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -420,6 +452,7 @@ LANG_TEXT = { "fr_FR": "Francuski", "fi_FI": "Fiński", "pt_PT": "Portugalski", + "fy_x-FY": "Frisian", "it_IT": "Włoski", "no_NO": "Norweski", "nl_NL": "Holenderski", @@ -437,6 +470,7 @@ LANG_TEXT = { "tr_TR": "Turecki", "de_DE": "Niemiecki", "ar_AE": "Arabski", + "uk_UA": "Ukrainian", "sv_SE": "Szwedzki", "pl_PL": "Polski", "T1": "W celu wyboru języka użyj klawiszy GÓRA i DÓŁ. Nastepnie nacisnij przycisk OK.", @@ -446,6 +480,7 @@ LANG_TEXT = { "fr_FR": "Francês", "fi_FI": "Finlandês", "pt_PT": "Português", + "fy_x-FY": "Frisian", "it_IT": "Italiano", "no_NO": "Norueguês", "nl_NL": "Holandês", @@ -463,6 +498,7 @@ LANG_TEXT = { "tr_TR": "Turco", "de_DE": "Alemão", "ar_AE": "Arabe", + "uk_UA": "Ukrainian", "sv_SE": "Sueco", "pl_PL": "Polaco", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -472,6 +508,7 @@ LANG_TEXT = { "fr_FR": "Французский", "fi_FI": "Окончание", "pt_PT": "Portuguese", + "fy_x-FY": "Frisian", "it_IT": "Итальянский", "no_NO": "Норвежский", "nl_NL": "Нидерландский", @@ -489,6 +526,7 @@ LANG_TEXT = { "tr_TR": "Турецкий", "de_DE": "Немецкий", "ar_AE": "Арабский", + "uk_UA": "Ukrainian", "sv_SE": "Шведский", "pl_PL": "Polish", "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", @@ -498,6 +536,7 @@ LANG_TEXT = { "fr_FR": "Francés", "fi_FI": "Finlandés", "pt_PT": "Portugués", + "fy_x-FY": "Frisian", "it_IT": "Italiano", "no_NO": "Noruego", "nl_NL": "Alemán", @@ -515,6 +554,7 @@ LANG_TEXT = { "tr_TR": "Turco", "de_DE": "Alemán", "ar_AE": "Arábigo", + "uk_UA": "Ukrainian", "sv_SE": "Sueco", "pl_PL": "Polaco", "T1": "Use las teclas ARRIBA y ABAJO para seleccionar su idioma. Después, pulse el botón OK.", @@ -524,6 +564,7 @@ LANG_TEXT = { "fr_FR": "Franska", "fi_FI": "Finska", "pt_PT": "Portugisiska", + "fy_x-FY": "Frisian", "it_IT": "Italienska", "no_NO": "Norska", "nl_NL": "Holländska", @@ -541,6 +582,7 @@ LANG_TEXT = { "tr_TR": "Turkiska", "de_DE": "Tyska", "ar_AE": "Arabiska", + "uk_UA": "Ukrainian", "sv_SE": "Svenska", "pl_PL": "Polska", "T1": "Vänligen använd UPP och NER pil för att välja språk. Efter val tryck på OK knappen.", @@ -548,28 +590,86 @@ LANG_TEXT = { }, "tr_TR": { "fr_FR": "Fransızca", - "fi_FI": "Bitiş", - "pt_PT": "Portuguese", - "it_IT": "İtalya", - "no_NO": "Norveç", - "nl_NL": "Almanca", + "fi_FI": "Fince", + "pt_PT": "Portekizce", + "fy_x-FY": "Frisian", + "it_IT": "İtalyanca", + "no_NO": "Norveççe", + "nl_NL": "Flemenkçe", "el_GR": "Greek", - "hu_HU": "Hungarian", - "lt_LT": "Lithuanian", - "hr_HR": "Croatian", + "hu_HU": "Macarca", + "lt_LT": "Litvanyaca", + "hr_HR": "Hırvatça", "en_EN": "İngilizce", "es_ES": "İspanyolca", - "ca_AD": "Catalan", - "ru_RU": "Russian", - "is_IS": "izlanda", - "da_DK": "Çanak", - "cs_CZ": "Czech", - "tr_TR": "Turkish", - "de_DE": "Alman", + "ca_AD": "Katalanca", + "ru_RU": "Rusça", + "is_IS": "İzlandaca", + "da_DK": "Danca", + "cs_CZ": "Çekçe", + "tr_TR": "Türkçe", + "de_DE": "Almanca", "ar_AE": "Arapça", - "sv_SE": "İsveç", + "uk_UA": "Ukraynaca", + "sv_SE": "İsveççe", "pl_PL": "Polish", - "T1": "Please use the UP and DOWN keys to select your language. Afterwards press the OK button.", - "T2": "Lisan Seçimi", + "T1": "Dil seçiminizi, yapmak için YUKARI ve AŞAĞI tuşlarını, onaylamak için OK tuşunu kullanın.", + "T2": "Dil seçimi", +}, +"uk_UA": { + "fr_FR": "Французька", + "fi_FI": "Фінська", + "pt_PT": "Португальська", + "fy_x-FY": "Frisian", + "it_IT": "Італійська", + "no_NO": "Норвежська", + "nl_NL": "Данська", + "el_GR": "Грецька", + "hu_HU": "Угорська", + "lt_LT": "Литовська", + "hr_HR": "Хорватьска", + "en_EN": "Англійська", + "es_ES": "Іспанська", + "ca_AD": "Каталонська", + "ru_RU": "Російська", + "is_IS": "Ісландська", + "da_DK": "Данська", + "cs_CZ": "Чешська", + "tr_TR": "Турецька", + "de_DE": "Німецька", + "ar_AE": "Арабський", + "uk_UA": "Ukrainian", + "sv_SE": "Шведська", + "pl_PL": "Польська", + "T1": "Використовуйте кнопки ВВЕРХ і ВНИЗ, щоб вибрати Вашу мову. Після вибору натисніть OK.", + "T2": "Вибір мови", +}, +"fy_x-FY": { + "fr_FR": "Frans", + "fi_FI": "Finsk", + "pt_PT": "Portugeesk", + "fy_x-FY": "Frisian", + "it_IT": "Italiaansk", + "no_NO": "Noarsk", + "nl_NL": "Nederlansk", + "el_GR": "Gryks", + "hu_HU": "Hongaarsk", + "lt_LT": "Lithuaniansk", + "hr_HR": "Kroatysk", + "en_EN": "Engelsk", + "es_ES": "Spaans", + "ca_AD": "Catalânsk", + "ru_RU": "Russysk", + "is_IS": "Iislansk", + "da_DK": "Deensk", + "cs_CZ": "Tsjechysk", + "tr_TR": "Turks", + "de_DE": "Dúts", + "ar_AE": "Arabysk", + "uk_UA": "Ukrainian", + "sv_SE": "Zweeds", + "pl_PL": "Poolsk", + "T1": "Brúk de op en del toets om jo taal te kiezen. Dernei druk op OK", + "T2": "Taal Kieze", }, } |
