diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2009-03-31 15:51:31 +0200 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2009-03-31 15:51:31 +0200 |
| commit | bce53d4a67d1655a496eebe5912c8573e880114e (patch) | |
| tree | 9b410fbcaf0f4a22f1cf3489b635e3e94e47a6d8 /lib/python/Components | |
| parent | 166db5a9c9222c82939eede51d964c706039ebe8 (diff) | |
| parent | 54475ce18e43482b2ec1a150f7fa07c3464ec6d2 (diff) | |
| download | enigma2-bce53d4a67d1655a496eebe5912c8573e880114e.tar.gz enigma2-bce53d4a67d1655a496eebe5912c8573e880114e.zip | |
Merge commit 'origin/master' into tmbinc/FixTimingBugs
Diffstat (limited to 'lib/python/Components')
33 files changed, 418 insertions, 362 deletions
diff --git a/lib/python/Components/AVSwitch.py b/lib/python/Components/AVSwitch.py index 3188469a..8f4255b8 100644 --- a/lib/python/Components/AVSwitch.py +++ b/lib/python/Components/AVSwitch.py @@ -1,4 +1,5 @@ -from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, ConfigEnableDisable, ConfigSubsection, ConfigBoolean +from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, \ + ConfigEnableDisable, ConfigSubsection, ConfigBoolean, ConfigNumber from enigma import eAVSwitch, getDesktop from SystemInfo import SystemInfo @@ -110,6 +111,8 @@ def InitAVSwitch(): config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal") config.av.wss = ConfigEnableDisable(default = True) config.av.defaultac3 = ConfigYesNo(default = False) + config.av.generalAC3delay = ConfigNumber(default = 0) + config.av.generalPCMdelay = ConfigNumber(default = 0) config.av.vcrswitch = ConfigEnableDisable(default = False) iAVSwitch = AVSwitch() diff --git a/lib/python/Components/Converter/FrontendInfo.py b/lib/python/Components/Converter/FrontendInfo.py index 796ac330..4043a1be 100644 --- a/lib/python/Components/Converter/FrontendInfo.py +++ b/lib/python/Components/Converter/FrontendInfo.py @@ -29,7 +29,7 @@ class FrontendInfo(Converter, object): @cached def getText(self): - assert self.type not in [self.LOCK, self.SLOT_NUMBER], "the text output of FrontendInfo cannot be used for lock info" + assert self.type not in (self.LOCK, self.SLOT_NUMBER), "the text output of FrontendInfo cannot be used for lock info" percent = None if self.type == self.BER: # as count count = self.source.ber @@ -54,7 +54,7 @@ class FrontendInfo(Converter, object): @cached def getBool(self): - assert self.type in [self.LOCK, self.BER], "the boolean output of FrontendInfo can only be used for lock or BER info" + assert self.type in (self.LOCK, self.BER), "the boolean output of FrontendInfo can only be used for lock or BER info" if self.type == self.LOCK: lock = self.source.lock if lock is None: diff --git a/lib/python/Components/Converter/RdsInfo.py b/lib/python/Components/Converter/RdsInfo.py index 3a7b2be3..f3f2b673 100644 --- a/lib/python/Components/Converter/RdsInfo.py +++ b/lib/python/Components/Converter/RdsInfo.py @@ -9,18 +9,12 @@ class RdsInfo(Converter, object): def __init__(self, type): Converter.__init__(self, type) - self.type = { - "RadioText": self.RADIO_TEXT_CHANGED, - "RtpText": self.RTP_TEXT_CHANGED, - "RasInteractiveAvailable": self.RASS_INTERACTIVE_AVAILABLE + self.type, self.interesting_events = { + "RadioText": (self.RADIO_TEXT_CHANGED, (iPlayableService.evUpdatedRadioText,)), + "RtpText": (self.RTP_TEXT_CHANGED, (iPlayableService.evUpdatedRtpText,)), + "RasInteractiveAvailable": (self.RASS_INTERACTIVE_AVAILABLE, (iPlayableService.evUpdatedRassInteractivePicMask,)) }[type] - self.interesting_events = { - self.RADIO_TEXT_CHANGED: [iPlayableService.evUpdatedRadioText], - self.RTP_TEXT_CHANGED: [iPlayableService.evUpdatedRtpText], - self.RASS_INTERACTIVE_AVAILABLE: [iPlayableService.evUpdatedRassInteractivePicMask] - }[self.type] - @cached def getText(self): decoder = self.source.decoder diff --git a/lib/python/Components/Converter/ServiceInfo.py b/lib/python/Components/Converter/ServiceInfo.py index 71180254..d4054f0c 100644 --- a/lib/python/Components/Converter/ServiceInfo.py +++ b/lib/python/Components/Converter/ServiceInfo.py @@ -13,26 +13,16 @@ class ServiceInfo(Converter, object): def __init__(self, type): Converter.__init__(self, type) - self.type = { - "HasTelext": self.HAS_TELETEXT, - "IsMultichannel": self.IS_MULTICHANNEL, - "IsCrypted": self.IS_CRYPTED, - "IsWidescreen": self.IS_WIDESCREEN, - "SubservicesAvailable": self.SUBSERVICES_AVAILABLE, - "VideoWidth": self.XRES, - "VideoHeight": self.YRES, + self.type, self.interesting_events = { + "HasTelext": (self.HAS_TELETEXT, (iPlayableService.evUpdatedInfo,)), + "IsMultichannel": (self.IS_MULTICHANNEL, (iPlayableService.evUpdatedInfo,)), + "IsCrypted": (self.IS_CRYPTED, (iPlayableService.evUpdatedInfo,)), + "IsWidescreen": (self.IS_WIDESCREEN, (iPlayableService.evVideoSizeChanged,)), + "SubservicesAvailable": (self.SUBSERVICES_AVAILABLE, (iPlayableService.evUpdatedEventInfo,)), + "VideoWidth": (self.XRES, (iPlayableService.evVideoSizeChanged,)), + "VideoHeight": (self.YRES, (iPlayableService.evVideoSizeChanged,)), }[type] - self.interesting_events = { - self.HAS_TELETEXT: [iPlayableService.evUpdatedInfo], - self.IS_MULTICHANNEL: [iPlayableService.evUpdatedInfo], - self.IS_CRYPTED: [iPlayableService.evUpdatedInfo], - self.IS_WIDESCREEN: [iPlayableService.evVideoSizeChanged], - self.SUBSERVICES_AVAILABLE: [iPlayableService.evUpdatedEventInfo], - self.XRES: [iPlayableService.evVideoSizeChanged], - self.YRES: [iPlayableService.evVideoSizeChanged], - }[self.type] - def getServiceInfoString(self, info, what): v = info.getInfo(what) if v == -1: @@ -56,16 +46,18 @@ class ServiceInfo(Converter, object): audio = service.audioTracks() if audio: n = audio.getNumberOfTracks() - for x in range(n): - i = audio.getTrackInfo(x) + idx = 0 + while idx < n: + i = audio.getTrackInfo(idx) description = i.getDescription(); - if description.find("AC3") != -1 or description.find("DTS") != -1: + if "AC3" in description or "DTS" in description: return True + idx += 1 return False elif self.type == self.IS_CRYPTED: return info.getInfo(iServiceInformation.sIsCrypted) == 1 elif self.type == self.IS_WIDESCREEN: - return info.getInfo(iServiceInformation.sAspect) in [3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10] + return info.getInfo(iServiceInformation.sAspect) in (3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10) elif self.type == self.SUBSERVICES_AVAILABLE: subservices = service.subServices() return subservices and subservices.getNumberOfSubservices() > 0 diff --git a/lib/python/Components/Converter/ServiceName.py b/lib/python/Components/Converter/ServiceName.py index 18b1f2a5..210c1aab 100644 --- a/lib/python/Components/Converter/ServiceName.py +++ b/lib/python/Components/Converter/ServiceName.py @@ -47,5 +47,5 @@ class ServiceName(Converter, object): text = property(getText) def changed(self, what): - if what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evStart]: + if what[0] != self.CHANGED_SPECIFIC or what[1] in (iPlayableService.evStart,): Converter.changed(self, what) diff --git a/lib/python/Components/Converter/ServicePosition.py b/lib/python/Components/Converter/ServicePosition.py index 2bcc5492..b92af40b 100644 --- a/lib/python/Components/Converter/ServicePosition.py +++ b/lib/python/Components/Converter/ServicePosition.py @@ -35,7 +35,7 @@ class ServicePosition(Converter, Poll, object): elif type == "Gauge": self.type = self.TYPE_GAUGE else: - raise ElementError("type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|NoSeconds}") + raise ElementError("type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|ShowNoSeconds} for ServicePosition converter") self.poll_enabled = self.type != self.TYPE_LENGTH @@ -128,8 +128,8 @@ class ServicePosition(Converter, Poll, object): value = property(getValue) def changed(self, what): - cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evCuesheetChanged] - time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in [iPlayableService.evCuesheetChanged] + cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in (iPlayableService.evCuesheetChanged,) + time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in (iPlayableService.evCuesheetChanged,) if cutlist_refresh: if self.type == self.TYPE_GAUGE: diff --git a/lib/python/Components/Converter/ServiceTime.py b/lib/python/Components/Converter/ServiceTime.py index 89965067..d30839c6 100644 --- a/lib/python/Components/Converter/ServiceTime.py +++ b/lib/python/Components/Converter/ServiceTime.py @@ -16,7 +16,7 @@ class ServiceTime(Converter, object): elif type == "Duration": self.type = self.DURATION else: - raise ElementError("'%s' is not <StartTime|EndTime|Duration> for eEventTime converter" % type) + raise ElementError("'%s' is not <StartTime|EndTime|Duration> for ServiceTime converter" % type) @cached def getTime(self): diff --git a/lib/python/Components/Converter/Streaming.py b/lib/python/Components/Converter/Streaming.py index 2746ee84..0c0d274c 100644 --- a/lib/python/Components/Converter/Streaming.py +++ b/lib/python/Components/Converter/Streaming.py @@ -9,9 +9,6 @@ from Components.Element import cached # "+d:[p:t[,p:t...]]" with d=demux nr, p: pid, t: type class Streaming(Converter): - def __init__(self, type): - Converter.__init__(self, type) - @cached def getText(self): service = self.source.service diff --git a/lib/python/Components/Converter/StringList.py b/lib/python/Components/Converter/StringList.py index 226247c4..d0886620 100644 --- a/lib/python/Components/Converter/StringList.py +++ b/lib/python/Components/Converter/StringList.py @@ -55,4 +55,5 @@ class StringList(Converter): index = property(getIndex, setIndex) def entry_changed(self, index): - self.downstream_elements.entry_changed(index) + if self.content: + self.content.invalidateEntry(index) diff --git a/lib/python/Components/DreamInfoHandler.py b/lib/python/Components/DreamInfoHandler.py index c5f82629..2f2e757c 100644 --- a/lib/python/Components/DreamInfoHandler.py +++ b/lib/python/Components/DreamInfoHandler.py @@ -31,7 +31,7 @@ class InfoHandler(xml.sax.ContentHandler): def startElement(self, name, attrs): #print name, ":", attrs.items() self.elements.append(name) - if name in ["hardware", "bcastsystem", "satellite", "tag"]: + if name in ("hardware", "bcastsystem", "satellite", "tag"): if not attrs.has_key("type"): self.printError(str(name) + " tag with no type attribute") if self.elements[-3] == "default": diff --git a/lib/python/Components/Element.py b/lib/python/Components/Element.py index f4a8f127..509a1c8d 100644 --- a/lib/python/Components/Element.py +++ b/lib/python/Components/Element.py @@ -18,10 +18,10 @@ def cached(f): class ElementError(Exception): def __init__(self, message): - self.message = message + self.msg = message def __str__(self): - return self.message + return self.msg class Element(object): CHANGED_DEFAULT = 0 # initial "pull" state diff --git a/lib/python/Components/EpgList.py b/lib/python/Components/EpgList.py index 2494ca08..fa60400f 100644 --- a/lib/python/Components/EpgList.py +++ b/lib/python/Components/EpgList.py @@ -297,6 +297,8 @@ class EPGList(HTMLComponent, GUIComponent): return x and x[1] def moveToService(self,serviceref): + if not serviceref: + return index = 0 refstr = serviceref.toString() for x in self.list: @@ -306,6 +308,8 @@ class EPGList(HTMLComponent, GUIComponent): index += 1 def moveToEventId(self, eventId): + if not eventId: + return index = 0 for x in self.list: if x[1] == eventId: diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 75d68fad..ad6c1a3b 100755 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -44,8 +44,8 @@ class Harddisk: self.timer.callback.remove(self.runIdle) def bus(self): - ide_cf = self.device.find("hd") == 0 and self.devidex2.find("host0") == -1 # 7025 specific - internal = self.device.find("hd") == 0 + ide_cf = self.device[:2] == "hd" and "host0" not in self.devidex2 # 7025 specific + internal = self.device[:2] == "hd" if ide_cf: ret = "External (CF)" elif internal: @@ -73,14 +73,14 @@ class Harddisk: return "%d.%03d GB" % (cap/1024, cap%1024) def model(self): - if self.device.find("hd") == 0: + if self.device[:2] == "hd": procfile = tryOpen("/proc/ide/"+self.device+"/model") if procfile == "": return "" line = procfile.readline() procfile.close() return line.strip() - elif self.device.find("sd") == 0: + elif self.device[:2] == "sd": procfile = tryOpen("/sys/block/"+self.device+"/device/vendor") if procfile == "": return "" @@ -230,9 +230,8 @@ class Harddisk: # 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 + (nr_read, _, _, _, nr_write) = l.split()[:5] + return int(nr_read), int(nr_write) def startIdle(self): self.last_access = time.time() @@ -358,8 +357,7 @@ class HarddiskManager: ("/", _("Internal Flash")) ] - for x in p: - self.partitions.append(Partition(mountpoint = x[0], description = x[1])) + self.partitions.extend([ Partition(mountpoint = x[0], description = x[1]) for x in p ]) def getBlockDevInfo(self, blockdev): devpath = "/sys/block/" + blockdev @@ -371,14 +369,14 @@ class HarddiskManager: try: removable = bool(int(open(devpath + "/removable").read())) dev = int(open(devpath + "/dev").read().split(':')[0]) - if dev in [7, 31]: # loop, mtdblock + if dev in (7, 31): # loop, mtdblock blacklisted = True if blockdev[0:2] == 'sr': is_cdrom = True if blockdev[0:2] == 'hd': try: media = open("/proc/ide/%s/media" % blockdev).read() - if media.find("cdrom") != -1: + if "cdrom" in media: is_cdrom = True except IOError: error = True @@ -457,11 +455,10 @@ class HarddiskManager: self.on_partition_list_change("remove", x) l = len(device) if l and not device[l-1].isdigit(): - idx = 0 for hdd in self.hdd: if hdd.device == device: - self.hdd[x].stop() - del self.hdd[idx] + hdd.stop() + self.hdd.remove(hdd) break SystemInfo["Harddisk"] = len(self.hdd) > 0 diff --git a/lib/python/Components/HelpMenuList.py b/lib/python/Components/HelpMenuList.py index ddf871a7..66139dfb 100755 --- a/lib/python/Components/HelpMenuList.py +++ b/lib/python/Components/HelpMenuList.py @@ -17,8 +17,6 @@ class HelpMenuList(GUIComponent): l = [ ] for (actionmap, context, actions) in helplist: for (action, help) in actions: - entry = [ ] - buttons = queryKeyBinding(context, action) # do not display entries which are not accessible from keys @@ -36,13 +34,15 @@ class HelpMenuList(GUIComponent): if flags & 8: # for long keypresses, prepend l_ into the key name. name = (name[0], "long") - entry.append( (actionmap, context, action, name ) ) - + entry = [ (actionmap, context, action, name ) ] + if isinstance(help, list): self.extendedHelp = True print "extendedHelpEntry found" - entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 26, 0, 0, help[0]) ) - entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 28, 400, 20, 1, 0, help[1]) ) + entry.extend(( + (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 26, 0, 0, help[0]), + (eListboxPythonMultiContent.TYPE_TEXT, 0, 28, 400, 20, 1, 0, help[1]) + )) else: entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 28, 0, 0, help) ) diff --git a/lib/python/Components/Language.py b/lib/python/Components/Language.py index 74dd67d8..268fdb21 100644 --- a/lib/python/Components/Language.py +++ b/lib/python/Components/Language.py @@ -64,18 +64,17 @@ class Language: self.activateLanguage(self.langlist[index]) def getLanguageList(self): - list = [] - for x in self.langlist: - list.append((x, self.lang[x])) - return list + return [ (x, self.lang[x]) for x in self.langlist ] def getActiveLanguage(self): return self.activeLanguage def getActiveLanguageIndex(self): - for count in range(len(self.langlist)): - if self.langlist[count] == self.activeLanguage: - return count + idx = 0 + for x in self.langlist: + if x == self.activeLanguage: + return idx + idx += 1 return None def getLanguage(self): diff --git a/lib/python/Components/MediaPlayer.py b/lib/python/Components/MediaPlayer.py index 87ba977c..12f2727f 100644 --- a/lib/python/Components/MediaPlayer.py +++ b/lib/python/Components/MediaPlayer.py @@ -25,7 +25,7 @@ def PlaylistEntryComponent(serviceref, state): text = serviceref.getName() if text is "": text = path.split(serviceref.getPath().split('/')[-1])[1] - res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 0, 470, 32, 0, RT_VALIGN_CENTER, text)) + res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 1, 470, 22, 0, RT_VALIGN_CENTER, text)) png = None if state == STATE_PLAY: png = PlayIcon @@ -39,7 +39,7 @@ def PlaylistEntryComponent(serviceref, state): png = ForwardIcon if png is not None: - res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 0, 16, 16, png)) + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 3, 16, 16, png)) return res @@ -47,7 +47,7 @@ class PlayList(MenuList): def __init__(self, enableWrapAround = False): MenuList.__init__(self, [], enableWrapAround, eListboxPythonMultiContent) self.l.setFont(0, gFont("Regular", 18)) - self.l.setItemHeight(22) + self.l.setItemHeight(23) self.currPlaying = -1 self.oldCurrPlaying = -1 self.serviceHandler = eServiceCenter.getInstance() diff --git a/lib/python/Components/Network.py b/lib/python/Components/Network.py index 64b3aa6c..5f7095c4 100755 --- a/lib/python/Components/Network.py +++ b/lib/python/Components/Network.py @@ -3,6 +3,8 @@ from re import compile as re_compile, search as re_search from socket import * from enigma import eConsoleAppContainer from Components.Console import Console +from Components.PluginComponent import plugins +from Plugins.Plugin import PluginDescriptor class Network: def __init__(self): @@ -22,6 +24,7 @@ class Network: self.activateConsole = Console() self.resetNetworkConsole = Console() self.DnsConsole = Console() + self.config_ready = None self.getInterfaces() def getInterfaces(self, callback = None): @@ -222,6 +225,8 @@ class Network: self.loadNameserverConfig() print "read configured interfac:", ifaces print "self.ifaces after loading:", self.ifaces + self.config_ready = True + self.msgPlugins() if callback is not None: callback(True) @@ -418,6 +423,8 @@ class Network: def restartNetwork(self,callback = None): self.restartConsole = Console() + self.config_ready = False + self.msgPlugins() self.commands = [] self.commands.append("/etc/init.d/avahi-daemon stop") for iface in self.ifaces.keys(): @@ -448,24 +455,34 @@ class Network: def stopLinkStateConsole(self): if self.LinkConsole is not None: - self.LinkConsole = None - + if len(self.LinkConsole.appContainers): + for name in self.LinkConsole.appContainers.keys(): + self.LinkConsole.kill(name) + def stopDNSConsole(self): if self.DnsConsole is not None: - self.DnsConsole = None - + if len(self.DnsConsole.appContainers): + for name in self.DnsConsole.appContainers.keys(): + self.DnsConsole.kill(name) + def stopRestartConsole(self): if self.restartConsole is not None: - self.restartConsole = None - + if len(self.restartConsole.appContainers): + for name in self.restartConsole.appContainers.keys(): + self.restartConsole.kill(name) + def stopGetInterfacesConsole(self): if self.Console is not None: - self.Console = None - + if len(self.Console.appContainers): + for name in self.Console.appContainers.keys(): + self.Console.kill(name) + def stopDeactivateInterfaceConsole(self): - if self.deactivateInterfaceConsole: - self.deactivateInterfaceConsole = None - + if self.deactivateInterfaceConsole is not None: + if len(self.deactivateInterfaceConsole.appContainers): + for name in self.deactivateInterfaceConsole.appContainers.keys(): + self.deactivateInterfaceConsole.kill(name) + def checkforInterface(self,iface): if self.getAdapterAttribute(iface, 'up') is True: return True @@ -547,6 +564,11 @@ class Network: netmask = str(inet_ntoa(pack('>L', nm))) return netmask + def msgPlugins(self): + if self.config_ready is not None: + for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKCONFIG_READ): + p(reason=self.config_ready) + iNetwork = Network() def InitNetwork(): diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 6dc49dcf..aa915937 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -112,7 +112,7 @@ class SecConfigure: def getRoot(self, slotid, connto): visited = [] - while (self.NimManager.getNimConfig(connto).configMode.value in ["satposdepends", "equal", "loopthrough"]): + while (self.NimManager.getNimConfig(connto).configMode.value in ("satposdepends", "equal", "loopthrough")): connto = int(self.NimManager.getNimConfig(connto).connectedTo.value) if connto in visited: # prevent endless loop return slotid @@ -168,7 +168,7 @@ class SecConfigure: hw = HardwareInfo() if slot.isCompatible("DVB-S"): print "slot: " + str(x) + " configmode: " + str(nim.configMode.value) - if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]: + if nim.configMode.value in ( "loopthrough", "satposdepends", "nothing" ): pass else: sec.setSlotNotLinked(x) @@ -389,20 +389,20 @@ class SecConfigure: else: sec.setLoDirection(rotorParam.WEST) - if currLnb.powerMeasurement.value: - sec.setUseInputpower(True) - sec.setInputpowerDelta(currLnb.powerThreshold.value) - turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW } - if turn_speed_dict.has_key(currLnb.turningSpeed.value): - turning_speed = turn_speed_dict[currLnb.turningSpeed.value] + if currLnb.powerMeasurement.value: + sec.setUseInputpower(True) + sec.setInputpowerDelta(currLnb.powerThreshold.value) + turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW } + if turn_speed_dict.has_key(currLnb.turningSpeed.value): + turning_speed = turn_speed_dict[currLnb.turningSpeed.value] + else: + beg_time = localtime(currLnb.fastTurningBegin.value) + end_time = localtime(currLnb.fastTurningEnd.value) + turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16 + turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1 + sec.setRotorTurningSpeed(turning_speed) else: - beg_time = localtime(currLnb.fastTurningBegin.value) - end_time = localtime(currLnb.fastTurningEnd.value) - turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16 - turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1 - sec.setRotorTurningSpeed(turning_speed) - else: - sec.setUseInputpower(False) + sec.setUseInputpower(False) sec.setLNBSlotMask(tunermask) @@ -447,7 +447,7 @@ class NIM(object): def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None): self.slot = slot - if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]: + if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None): print "warning: unknown NIM type %s, not using." % type type = None @@ -458,20 +458,20 @@ class NIM(object): def isCompatible(self, what): compatible = { - None: [None], - "DVB-S": ["DVB-S", None], - "DVB-C": ["DVB-C", None], - "DVB-T": ["DVB-T", None], - "DVB-S2": ["DVB-S", "DVB-S2", None] + None: (None,), + "DVB-S": ("DVB-S", None), + "DVB-C": ("DVB-C", None), + "DVB-T": ("DVB-T", None), + "DVB-S2": ("DVB-S", "DVB-S2", None) } return what in compatible[self.type] def connectableTo(self): connectable = { - "DVB-S": ["DVB-S", "DVB-S2"], - "DVB-C": ["DVB-C"], - "DVB-T": ["DVB-T"], - "DVB-S2": ["DVB-S", "DVB-S2"] + "DVB-S": ("DVB-S", "DVB-S2"), + "DVB-C": ("DVB-C",), + "DVB-T": ("DVB-T",), + "DVB-S2": ("DVB-S", "DVB-S2") } return connectable[self.type] @@ -781,10 +781,10 @@ class NimManager: if configMode == "simple": dm = nim.diseqcMode.value - if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]: + if dm in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"): if nim.diseqcA.orbital_position != 3601: list.append(self.satList[nim.diseqcA.index-1]) - if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]: + if dm in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"): if nim.diseqcB.orbital_position != 3601: list.append(self.satList[nim.diseqcB.index-1]) if dm == "diseqc_a_b_c_d": @@ -835,9 +835,13 @@ class NimManager: def InitSecParams(): config.sec = ConfigSubsection() - x = ConfigInteger(default=15, limits = (0, 9999)) - x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value)) - config.sec.delay_after_continuous_tone_change = x + x = ConfigInteger(default=25, limits = (0, 9999)) + x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC, configElement.value)) + config.sec.delay_after_continuous_tone_disable_before_diseqc = x + + x = ConfigInteger(default=10, limits = (0, 9999)) + x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_CONT_TONE_CHANGE, configElement.value)) + config.sec.delay_after_final_continuous_tone_change = x x = ConfigInteger(default=10, limits = (0, 9999)) x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value)) @@ -922,57 +926,58 @@ def InitNimManager(nimmgr): "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"]}} + "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"]}, + "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"]}, + "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"]}, + "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"]}, + "EXR501":("1400","1516","1632","1748"), + "EXR551":("1400","1516","1632","1748"), + "EXR552":("1400","1516")}, "ROTEK": { - "EKL2/1":["1400","1516"], - "EKL2/1E":["0","0","1632","1748"]}, + "EKL2/1":("1400","1516"), + "EKL2/1E":("0","0","1632","1748")}, "Smart": { - "DPA 51":["1284","1400","1516","1632","1748","1864","1980","2096"]}, + "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"]}, + "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"]}} + "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() @@ -982,59 +987,9 @@ def InitNimManager(nimmgr): "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)] @@ -1073,26 +1028,174 @@ def InitNimManager(nimmgr): 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()); + + def configLOFChanged(configElement): + if configElement.value == "unicable": + x = configElement.slot_id + lnb = configElement.lnb_id + nim = config.Nims[x] + lnbs = nim.advanced.lnb + section = lnbs[lnb] + if isinstance(section.unicable, ConfigNothing): + if lnb == 1: + section.unicable = ConfigSelection(unicable_choices, unicable_choices_default) + elif lnb == 2: + section.unicable = ConfigSelection(choices = {"unicable_matrix": _("Unicable Martix"),"unicable_user": "Unicable "+_("User defined")}, default = "unicable_matrix") + else: + section.unicable = ConfigSelection(choices = {"unicable_user": _("User defined")}, default = "unicable_user") + + if lnb < 3: + section.unicableMatrix = ConfigSubDict() + section.unicableMatrixManufacturer = ConfigSelection(choices = UnicableMatrixManufacturers, default = UnicableMatrixManufacturers[0]) + for y in unicablematrixproducts: + products = unicablematrixproducts[y].keys() + products.sort() + tmp = ConfigSubsection() + tmp.product = ConfigSelection(choices = products, default = products[0]) + tmp.scr = ConfigSubDict() + tmp.vco = ConfigSubDict() + for z in products: + scrlist = [] + vcolist = unicablematrixproducts[y][z] + tmp.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)) + tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) + tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) + section.unicableMatrix[y] = tmp + + if lnb < 2: + section.unicableLnb = ConfigSubDict() + section.unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0]) + for y in unicablelnbproducts: + products = unicablelnbproducts[y].keys() + products.sort() + tmp = ConfigSubsection() + tmp.product = ConfigSelection(choices = products, default = products[0]) + tmp.scr = ConfigSubDict() + tmp.vco = ConfigSubDict() + for z in products: + scrlist = [] + vcolist = unicablelnbproducts[y][z] + tmp.vco[z] = ConfigSubList() + for cnt in range(1,1+len(vcolist)): + scrlist.append(("%d" %cnt,"SCR %d" %cnt)) + vcofreq = int(vcolist[cnt-1]) + tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) + tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) + section.unicableLnb[y] = tmp + + section.satcruser = ConfigSelection(advanced_lnb_satcruser_choices, default="1") + tmp = ConfigSubList() + tmp.append(ConfigInteger(default=1284, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1400, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1516, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1632, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1748, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1864, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1980, limits = (0, 9999))) + tmp.append(ConfigInteger(default=2096, limits = (0, 9999))) + section.satcrvcouser = tmp + + def configDiSEqCModeChanged(configElement): + section = configElement.section + if configElement.value == "1_2" and isinstance(section.longitude, ConfigNothing): + section.longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)]) + section.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east") + section.latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)]) + section.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north") + section.powerMeasurement = ConfigYesNo(default=True) + section.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100)) + section.turningSpeed = ConfigSelection(turning_speed_choices, "fast") + section.fastTurningBegin = ConfigDateTime(default=advanced_lnb_fast_turning_btime, formatstring = _("%H:%M"), increment = 600) + section.fastTurningEnd = ConfigDateTime(default=advanced_lnb_fast_turning_etime, formatstring = _("%H:%M"), increment = 600) + + def configLNBChanged(configElement): + x = configElement.slot_id + nim = config.Nims[x] + if isinstance(configElement.value, tuple): + lnb = int(configElement.value[0]) + else: + lnb = int(configElement.value) + lnbs = nim.advanced.lnb + if lnb and lnb not in lnbs: + section = lnbs[lnb] = ConfigSubsection() + section.lofl = ConfigInteger(default=9750, limits = (0, 99999)) + section.lofh = ConfigInteger(default=10600, limits = (0, 99999)) + section.threshold = ConfigInteger(default=11700, limits = (0, 99999)) +# section.output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V") + section.increased_voltage = ConfigYesNo(False) + section.toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none") + section.longitude = ConfigNothing() + if lnb > 32: + tmp = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2") + tmp.section = section + configDiSEqCModeChanged(tmp) + else: + tmp = ConfigSelection(advanced_lnb_diseqcmode_choices, "none") + tmp.section = section + tmp.addNotifier(configDiSEqCModeChanged) + section.diseqcMode = tmp + section.commitedDiseqcCommand = ConfigSelection(advanced_lnb_csw_choices) + section.fastDiseqc = ConfigYesNo(False) + section.sequenceRepeat = ConfigYesNo(False) + section.commandOrder1_0 = ConfigSelection(advanced_lnb_commandOrder1_0_choices, "ct") + section.commandOrder = ConfigSelection(advanced_lnb_commandOrder_choices, "ct") + section.uncommittedDiseqcCommand = ConfigSelection(advanced_lnb_ucsw_choices) + section.diseqcRepeats = ConfigSelection(advanced_lnb_diseqc_repeat_choices, "none") + section.prio = ConfigSelection(prio_list, "-1") + section.unicable = ConfigNothing() + tmp = ConfigSelection(lnb_choices, lnb_choices_default) + tmp.slot_id = x + tmp.lnb_id = lnb + tmp.addNotifier(configLOFChanged, initial_call = False) + section.lof = tmp + + def configModeChanged(configMode): + slot_id = configMode.slot_id + nim = config.Nims[slot_id] + if configMode.value == "advanced" and isinstance(nim.advanced, ConfigNothing): + # advanced config: + nim.advanced = ConfigSubsection() + nim.advanced.sat = ConfigSubDict() + nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices) + nim.advanced.lnb = ConfigSubDict() + nim.advanced.lnb[0] = ConfigNothing() + for x in nimmgr.satList: + tmp = ConfigSubsection() + tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization") + tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band") + tmp.usals = ConfigYesNo(True) + tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255)) + lnb = ConfigSelection(advanced_lnb_choices, "0") + lnb.slot_id = slot_id + lnb.addNotifier(configLNBChanged, initial_call = False) + tmp.lnb = lnb + nim.advanced.sat[x[0]] = tmp + for x in range(3601, 3605): + tmp = ConfigSubsection() + tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization") + tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band") + tmp.usals = ConfigYesNo(default=True) + tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255)) + lnbnum = 33+x-3601 + lnb = ConfigSelection([("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], "0") + lnb.slot_id = slot_id + lnb.addNotifier(configLNBChanged, initial_call = False) + tmp.lnb = lnb + nim.advanced.sat[x] = tmp + for slot in nimmgr.nim_slots: x = slot.slot nim = config.Nims[x] - if slot.isCompatible("DVB-S"): - config_mode_choices = [ ("nothing", _("nothing connected")), - ("simple", _("simple")), ("advanced", _("advanced"))] - if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0: - config_mode_choices.append(("equal", _("equal to"))) - config_mode_choices.append(("satposdepends", _("second cable of motorized LNB"))) - if len(nimmgr.canConnectTo(x)) > 0: - 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) @@ -1112,75 +1215,18 @@ def InitNimManager(nimmgr): nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900) etime = datetime(1970, 1, 1, 19, 0); nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900) - - # advanced config: - nim.advanced = ConfigSubsection() - nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices) - nim.advanced.sat = ConfigSubDict() - - for x in nimmgr.satList: - nim.advanced.sat[x[0]] = ConfigSubsection() - 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(advanced_lnb_choices, "0") - - for x in range(3601, 3605): - nim.advanced.sat[x] = ConfigSubsection() - 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([("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(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(False) - nim.advanced.lnb[x].toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none") - if x > 32: - nim.advanced.lnb[x].diseqcMode = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2") - else: - 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(longitude_orientation_choices, "east") - nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)]) - 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(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") + config_mode_choices = [ ("nothing", _("nothing connected")), + ("simple", _("simple")), ("advanced", _("advanced"))] + if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0: + config_mode_choices.append(("equal", _("equal to"))) + config_mode_choices.append(("satposdepends", _("second cable of motorized LNB"))) + if len(nimmgr.canConnectTo(x)) > 0: + config_mode_choices.append(("loopthrough", _("loopthrough to"))) + nim.advanced = ConfigNothing() + tmp = ConfigSelection(config_mode_choices, "nothing") + tmp.slot_id = x + tmp.addNotifier(configModeChanged, initial_call = False) + nim.configMode = tmp elif slot.isCompatible("DVB-C"): nim.configMode = ConfigSelection( choices = { diff --git a/lib/python/Components/ParentalControl.py b/lib/python/Components/ParentalControl.py index 8c8a3305..d68e01ff 100644 --- a/lib/python/Components/ParentalControl.py +++ b/lib/python/Components/ParentalControl.py @@ -33,7 +33,7 @@ def InitParentalControl(): config.ParentalControl.servicepin = ConfigSubList() - for i in range(3): + for i in (0, 1, 2): config.ParentalControl.servicepin.append(ConfigPIN(default = -1)) #config.ParentalControl.servicepin.append(configElement("config.ParentalControl.servicepin.level" + str(i), configSequence, "0000", configSequenceArg().get("PINCODE", (4, "")))) @@ -117,10 +117,7 @@ class ParentalControl: return -1 def getPinList(self): - pinList = [] - for x in config.ParentalControl.servicepin: - pinList.append(x.value) - return pinList + return [ x.value for x in config.ParentalControl.servicepin ] def servicePinEntered(self, service, result): # levelNeeded = 0 diff --git a/lib/python/Components/ParentalControlList.py b/lib/python/Components/ParentalControlList.py index 71912620..128e6d3e 100644 --- a/lib/python/Components/ParentalControlList.py +++ b/lib/python/Components/ParentalControlList.py @@ -8,8 +8,10 @@ from Tools.LoadPixmap import LoadPixmap lockPicture = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock.png")) def ParentalControlEntryComponent(service, name, locked = True): - res = [ (service, name, locked) ] - res.append((eListboxPythonMultiContent.TYPE_TEXT, 80, 5, 300, 50, 0, RT_HALIGN_LEFT, name)) + res = [ + (service, name, locked), + (eListboxPythonMultiContent.TYPE_TEXT, 80, 5, 300, 50, 0, RT_HALIGN_LEFT, name) + ] if locked: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 32, 32, lockPicture)) return res diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py index 6e357cd0..fff5c475 100644 --- a/lib/python/Components/PluginComponent.py +++ b/lib/python/Components/PluginComponent.py @@ -96,9 +96,9 @@ class PluginComponent: res = [ ] for x in where: - for p in self.plugins.get(x, [ ]): - res.append(p) - return res + res.extend(self.plugins.get(x, [ ])) + + return res def getPluginsForMenu(self, menuid): res = [ ] diff --git a/lib/python/Components/PluginList.py b/lib/python/Components/PluginList.py index 63136cce..39c60ff7 100644 --- a/lib/python/Components/PluginList.py +++ b/lib/python/Components/PluginList.py @@ -7,40 +7,38 @@ from enigma import eListboxPythonMultiContent, gFont from Tools.LoadPixmap import LoadPixmap def PluginEntryComponent(plugin): - res = [ plugin ] - - res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=plugin.name)) - res.append(MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description)) - if plugin.icon is None: png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/plugin.png")) else: png = plugin.icon - res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(100, 40), png = png)) - - return res + + return [ + plugin, + MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=plugin.name), + MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description), + MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(100, 40), png = png) + ] def PluginCategoryComponent(name, png): - res = [ name ] - - res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name)) - res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png)) - - return res + return [ + name, + MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name), + MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png) + ] def PluginDownloadComponent(plugin, name): - res = [ plugin ] - - res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name)) - res.append(MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description)) - if plugin.icon is None: png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/plugin.png")) else: png = plugin.icon - res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png)) + + return [ + plugin, + MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name), + MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description), + MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png) + ] - return res class PluginList(MenuList): def __init__(self, list, enableWrapAround=False): diff --git a/lib/python/Components/Renderer/FrontpanelLed.py b/lib/python/Components/Renderer/FrontpanelLed.py index cd329b56..dcb9cd2f 100644 --- a/lib/python/Components/Renderer/FrontpanelLed.py +++ b/lib/python/Components/Renderer/FrontpanelLed.py @@ -2,9 +2,6 @@ from Components.Element import Element # this is not a GUI renderer. class FrontpanelLed(Element): - def __init__(self): - Element.__init__(self) - def changed(self, *args, **kwargs): if self.source.value or 1: pattern = 0x55555555 diff --git a/lib/python/Components/Renderer/Picon.py b/lib/python/Components/Renderer/Picon.py index de19c9aa..5ae43ed8 100644 --- a/lib/python/Components/Renderer/Picon.py +++ b/lib/python/Components/Renderer/Picon.py @@ -6,9 +6,9 @@ from enigma import ePixmap from Tools.Directories import fileExists, SCOPE_SKIN_IMAGE, SCOPE_CURRENT_SKIN, resolveFilename class Picon(Renderer): - searchPaths = ['/usr/share/enigma2/%s/', + searchPaths = ('/usr/share/enigma2/%s/', '/media/cf/%s/', - '/media/usb/%s/'] + '/media/usb/%s/') def __init__(self): Renderer.__init__(self) diff --git a/lib/python/Components/Scanner.py b/lib/python/Components/Scanner.py index 17c4aaa8..813c09f8 100644 --- a/lib/python/Components/Scanner.py +++ b/lib/python/Components/Scanner.py @@ -114,13 +114,10 @@ def scanDevice(mountpoint): # ...then remove with_subdir=False when same path exists # with with_subdirs=True - for p in set(paths_to_scan): + for p in paths_to_scan: if p.with_subdirs == True and ScanPath(path=p.path) in paths_to_scan: paths_to_scan.remove(ScanPath(path=p.path)) - # convert to list - paths_to_scan = list(paths_to_scan) - from Components.Harddisk import harddiskmanager blockdev = mountpoint.rstrip("/").rsplit('/',1)[-1] error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.getBlockDevInfo(blockdev) diff --git a/lib/python/Components/SelectionList.py b/lib/python/Components/SelectionList.py index a4f1d71a..08af7d02 100644 --- a/lib/python/Components/SelectionList.py +++ b/lib/python/Components/SelectionList.py @@ -6,8 +6,10 @@ from Tools.LoadPixmap import LoadPixmap selectionpng = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/selectioncross.png")) def SelectionEntryComponent(description, value, index, selected): - res = [ (description, value, index, selected) ] - res.append((eListboxPythonMultiContent.TYPE_TEXT, 30, 3, 500, 30, 0, RT_HALIGN_LEFT, description)) + res = [ + (description, value, index, selected), + (eListboxPythonMultiContent.TYPE_TEXT, 30, 3, 500, 30, 0, RT_HALIGN_LEFT, description) + ] if selected: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 30, selectionpng)) return res @@ -23,13 +25,11 @@ class SelectionList(MenuList): self.setList(self.list) def toggleSelection(self): - item = self.list[self.getSelectedIndex()][0] - self.list[self.getSelectedIndex()] = SelectionEntryComponent(item[0], item[1], item[2], not item[3]) + idx = self.getSelectedIndex() + item = self.list[idx][0] + self.list[idx] = SelectionEntryComponent(item[0], item[1], item[2], not item[3]) self.setList(self.list) def getSelectionsList(self): - list = [] - for item in self.list: - if item[0][3]: - list.append((item[0][0], item[0][1], item[0][2])) - return list + return [ (item[0][0], item[0][1], item[0][2]) for item in self.list if item[0][3] ] + diff --git a/lib/python/Components/Sources/List.py b/lib/python/Components/Sources/List.py index dbe442d1..1eab32b2 100644 --- a/lib/python/Components/Sources/List.py +++ b/lib/python/Components/Sources/List.py @@ -27,7 +27,7 @@ to generate HTML.""" def entry_changed(self, index): if not self.disable_callbacks: - self.downstream_elements.entry_changed(self, index) + self.downstream_elements.entry_changed(index) def modifyEntry(self, index, data): self.__list[index] = data diff --git a/lib/python/Components/Sources/RdsDecoder.py b/lib/python/Components/Sources/RdsDecoder.py index 3ec9a25d..26a3e5a7 100644 --- a/lib/python/Components/Sources/RdsDecoder.py +++ b/lib/python/Components/Sources/RdsDecoder.py @@ -23,7 +23,7 @@ class RdsDecoder(PerServiceBase, Source, object): decoder = property(getDecoder) def gotEvent(self, what): - if what in [iPlayableService.evStart, iPlayableService.evEnd]: + if what in (iPlayableService.evStart, iPlayableService.evEnd): self.changed((self.CHANGED_CLEAR,)) else: self.changed((self.CHANGED_SPECIFIC, what)) diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py index a237c364..44a7eb4f 100644 --- a/lib/python/Components/TimerList.py +++ b/lib/python/Components/TimerList.py @@ -21,7 +21,7 @@ class TimerList(HTMLComponent, GUIComponent, object): res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, width, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.name)) repeatedtext = "" - days = [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ] + days = ( _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ) if timer.repeated: flags = timer.repeated count = 0 @@ -93,7 +93,7 @@ class TimerList(HTMLComponent, GUIComponent, object): def getCurrentIndex(self): return self.instance.getCurrentIndex() - currentIndex = property(moveToIndex, getCurrentIndex) + currentIndex = property(getCurrentIndex, moveToIndex) currentSelection = property(getCurrent) def moveDown(self): diff --git a/lib/python/Components/TimerSanityCheck.py b/lib/python/Components/TimerSanityCheck.py index cf505022..c0ca10fa 100644 --- a/lib/python/Components/TimerSanityCheck.py +++ b/lib/python/Components/TimerSanityCheck.py @@ -135,8 +135,7 @@ class TimerSanityCheck: self.nrep_eventlist.extend([(new_event_begin, self.bflag, event[1]),(new_event_end, self.eflag, event[1])]) else: offset_0 = 345600 # the Epoch begins on Thursday - weeks = 2 # test two weeks to take care of Sunday-Monday transitions - for cnt in range(weeks): + for cnt in (0, 1): # test two weeks to take care of Sunday-Monday transitions for event in self.rep_eventlist: if event[1] == -1: # -1 is the identifier of the changed timer event_begin = self.newtimer.begin diff --git a/lib/python/Components/Timezones.py b/lib/python/Components/Timezones.py index f3e24ee6..7f709159 100644 --- a/lib/python/Components/Timezones.py +++ b/lib/python/Components/Timezones.py @@ -52,11 +52,8 @@ class Timezones: e_tzset() def getTimezoneList(self): - list = [] - for x in self.timezones: - list.append(str(x[0])) - return list - + return [ str(x[0]) for x in self.timezones ] + def getDefaultTimezone(self): # TODO return something more useful - depending on country-settings? t = "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Vienna" diff --git a/lib/python/Components/TuneTest.py b/lib/python/Components/TuneTest.py index de7b0098..e3b7d9e3 100644 --- a/lib/python/Components/TuneTest.py +++ b/lib/python/Components/TuneTest.py @@ -4,8 +4,8 @@ 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 + # transponder = (frequency, symbolrate, polarisation, fec, inversion, orbpos, system, modulation, rolloff, pilot, tsid, onid) + # 0 1 2 3 4 5 6 7 8 9 10 11 def tune(self, transponder): if self.frontend: print "tuning to transponder with data", transponder @@ -102,8 +102,8 @@ class TuneTest: 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])}]) + if self.tsid != self.currTuned[10] or self.onid != self.currTuned[11]: + self.failedTune.append([self.currTuned, self.oldTuned, "pids_failed", {"real": (self.tsid, self.onid), "expected": (self.currTuned[10], self.currTuned[11])}]) pidsFailed = True else: self.successfullyTune.append([self.currTuned, self.oldTuned]) @@ -140,7 +140,7 @@ class TuneTest: # 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)): + while (index < len(self.transponderlist) and (self.transponderlist[index][10] == -1 or self.transponderlist[index][11] == -1)): index += 1 print "FirstTransponder final index:", index return index @@ -153,7 +153,7 @@ class TuneTest: # 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)): + while (index < len(self.transponderlist) and (self.transponderlist[index][10] == -1 or self.transponderlist[index][11] == -1)): index += 1 print "next transponder index:", index @@ -203,8 +203,8 @@ class TuneTest: 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 + # transponder = (frequency, symbolrate, polarisation, fec, inversion, orbpos, <system>, <modulation>, <rolloff>, <pilot>, <tsid>, <onid>) + # 0 1 2 3 4 5 6 7 8 9 10 11 def addTransponder(self, transponder): self.transponderlist.append(transponder) diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index a6d34152..c810e14b 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -279,8 +279,8 @@ class ConfigSelection(ConfigElement): if default is None: default = self.choices.default() + self._descr = None self.default = self._value = self.last_value = default - self.changed() def setChoices(self, choices, default = None): self.choices = choicesList(choices) @@ -296,6 +296,7 @@ class ConfigSelection(ConfigElement): self._value = value else: self._value = self.default + self._descr = None self.changed() def tostring(self, val): @@ -307,7 +308,7 @@ class ConfigSelection(ConfigElement): def setCurrentText(self, text): i = self.choices.index(self.value) self.choices[i] = text - self.description[text] = text + self._descr = self.description[text] = text self._value = text value = property(getValue, setValue) @@ -336,13 +337,18 @@ class ConfigSelection(ConfigElement): self.value = self.choices[(i + 1) % nchoices] def getText(self): - descr = self.description[self.value] + if self._descr is not None: + return self._descr + descr = self._descr = self.description[self.value] if descr: return _(descr) return descr def getMulti(self, selected): - descr = self.description[self.value] + if self._descr is not None: + descr = self._descr + else: + descr = self._descr = self.description[self.value] if descr: return ("text", _(descr)) return ("text", descr) @@ -378,7 +384,7 @@ class ConfigBoolean(ConfigElement): self.value = self.last_value = self.default = default def handleKey(self, key): - if key in [KEY_LEFT, KEY_RIGHT]: + if key in (KEY_LEFT, KEY_RIGHT): self.value = not self.value elif key == KEY_HOME: self.value = False @@ -1022,6 +1028,13 @@ class ConfigNumber(ConfigText): value = property(getValue, setValue) _value = property(getValue, setValue) + def isChanged(self): + sv = self.saved_value + strv = self.tostring(self.value) + if sv is None and strv == self.default: + return False + return strv != sv + def conform(self): pos = len(self.text) - self.marked_pos self.text = self.text.lstrip("0") @@ -1180,7 +1193,7 @@ class ConfigSet(ConfigElement): self.pos = -1 else: self.pos += 1 - elif key in [KEY_HOME, KEY_END]: + elif key in (KEY_HOME, KEY_END): self.pos = -1 def genString(self, lst): @@ -1345,7 +1358,7 @@ class ConfigLocations(ConfigElement): self.pos += 1 if self.pos >= len(self.value): self.pos = -1 - elif key in [KEY_HOME, KEY_END]: + elif key in (KEY_HOME, KEY_END): self.pos = -1 def getText(self): @@ -1607,8 +1620,9 @@ class Config(ConfigSubsection): self.setSavedValue(tree["config"]) def saveToFile(self, filename): + text = self.pickle() f = open(filename, "w") - f.write(self.pickle()) + f.write(text) f.close() def loadFromFile(self, filename): |
