From e0700c8302b02d051be365dfdd6a2d14088cc85d Mon Sep 17 00:00:00 2001 From: acid-burn Date: Tue, 17 Feb 2009 09:26:39 +0100 Subject: allow multiple ipkg configuration files. Limit: one url entry per file really write edited url back dont show arch.conf file variable_width support for inputbox to work properly with sd and hd skins --- .../SystemPlugins/SoftwareManager/plugin.py | 144 +++++++++++++++++---- 1 file changed, 122 insertions(+), 22 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index 09b61bd5..1df061e2 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -19,7 +19,7 @@ from Components.SelectionList import SelectionList from Components.PluginComponent import plugins from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE from Tools.LoadPixmap import LoadPixmap -from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont +from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop from cPickle import dump, load from os import path as os_path, system as os_system, unlink, stat, mkdir, popen, makedirs, listdir, access, rename, remove, W_OK, R_OK, F_OK @@ -82,7 +82,7 @@ class UpdatePluginMenu(Screen): {"template": [ - MultiContentEntryText(pos = (2, 2), size = (230, 300), flags = RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, text = 2), # index 0 is the MenuText, + MultiContentEntryText(pos = (2, 2), size = (230, 300), flags = RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, text = 2), # index 2 is the Description, ], "fonts": [gFont("Regular", 20)], "itemHeight": 230 @@ -157,7 +157,8 @@ class UpdatePluginMenu(Screen): if (current == "ipkg-manager"): self.session.open(PacketManager, self.skin_path) elif (current == "ipkg-source"): - self.session.open(IPKGSource) + self.session.open(IPKGMenu, self.skin_path) + #self.session.open(IPKGSource) elif (current == "ipkg-install"): try: from Plugins.Extensions.MediaScanner.plugin import main @@ -223,34 +224,123 @@ class UpdatePluginMenu(Screen): self.exe = True self.session.open(RestoreScreen, runRestore = True) +class IPKGMenu(Screen): + skin = """ + + + + + + + """ + + def __init__(self, session, plugin_path): + Screen.__init__(self, session) + self.skin_path = plugin_path + + self["closetext"] = Label(_("Close")) + self["edittext"] = Label(_("Edit")) + + self.sel = [] + self.val = [] + self.entry = False + self.exe = False + + self.path = "" + + self["actions"] = NumberActionMap(["SetupActions"], + { + "ok": self.KeyOk, + "cancel": self.keyCancel + }, -1) + + self["shortcuts"] = ActionMap(["ShortcutActions"], + { + "red": self.keyCancel, + "green": self.KeyOk, + }) + self.flist = [] + self["filelist"] = MenuList(self.flist) + self.fill_list() + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setWindowTitle() + + def setWindowTitle(self): + self.setTitle(_("Select IPKG source to edit...")) + + + def fill_list(self): + self.flist = [] + self.path = '/etc/ipkg/' + if (os_path.exists(self.path) == False): + self.entry = False + return + for file in listdir(self.path): + if (file.endswith(".conf")): + if file != 'arch.conf': + self.flist.append((file)) + self.entry = True + self["filelist"].l.setList(self.flist) + + def KeyOk(self): + if (self.exe == False) and (self.entry == True): + self.sel = self["filelist"].getCurrent() + self.val = self.path + self.sel + self.session.open(IPKGSource, self.val) + + def keyCancel(self): + self.close() + + def Exit(self): + self.close() + class IPKGSource(Screen): skin = """ - - + + + + + + """ - def __init__(self, session, args = None): + def __init__(self, session, configfile = None): Screen.__init__(self, session) self.session = session - - #FIXMEEEE add handling for more than one feed conf file! + self.configfile = configfile text = "" - try: - fp = file('/etc/ipkg/official-feed.conf', 'r') - sources = fp.readlines() - if sources: - text = sources[0] - fp.close() - except IOError: - pass - - self["text"] = Input(text, maxSize=False, type=Input.TEXT) - - self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions"], + if self.configfile: + try: + fp = file(configfile, 'r') + sources = fp.readlines() + if sources: + text = sources[0] + fp.close() + except IOError: + pass + + desk = getDesktop(0) + x= int(desk.size().width()) + y= int(desk.size().height()) + #print "[IPKGSource] mainscreen: current desktop size: %dx%d" % (x,y) + + self["closetext"] = Label(_("Cancel")) + self["edittext"] = Label(_("Save")) + + if (y>=720): + self["text"] = Input(text, maxSize=False, type=Input.TEXT) + else: + self["text"] = Input(text, maxSize=False, visible_width = 55, type=Input.TEXT) + + self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions","ShortcutActions"], { "ok": self.go, "back": self.close, + "red": self.close, + "green": self.go, "left": self.keyLeft, "right": self.keyRight, "home": self.keyHome, @@ -268,12 +358,22 @@ class IPKGSource(Screen): "9": self.keyNumberGlobal, "0": self.keyNumberGlobal }, -1) + + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setWindowTitle() + self["text"].right() + + def setWindowTitle(self): + self.setTitle(_("Edit IPKG source URL...")) def go(self): text = self["text"].getText() if text: - fp = file('/etc/ipkg/official-feed.conf', 'w') - fp.write() + fp = file(self.configfile, 'w') + fp.write(text) + fp.write("\n") fp.close() self.close() -- cgit v1.2.3 From 18d5fedc236e3374f8a31af5e312d12bb16fd31d Mon Sep 17 00:00:00 2001 From: acid-burn Date: Tue, 17 Feb 2009 16:45:43 +0100 Subject: follow Console() changes add WHERE_NETWORKCONFIG_READ to Plugin Descriptor make Reichi happy ;-) --- lib/python/Components/Network.py | 44 ++++++++++++++++++++++++++++++---------- lib/python/Plugins/Plugin.py | 3 +++ 2 files changed, 36 insertions(+), 11 deletions(-) mode change 100644 => 100755 lib/python/Plugins/Plugin.py (limited to 'lib/python') diff --git a/lib/python/Components/Network.py b/lib/python/Components/Network.py index f32a648c..c0b799ba 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/Plugins/Plugin.py b/lib/python/Plugins/Plugin.py old mode 100644 new mode 100755 index 53e7b0b8..d7fc6898 --- a/lib/python/Plugins/Plugin.py +++ b/lib/python/Plugins/Plugin.py @@ -49,6 +49,9 @@ class PluginDescriptor: # or return a function which is called with session and the interface name for extended setup of this interface WHERE_EVENTINFO = 11 + # reason (True: Networkconfig read finished, False: Networkconfig reload initiated ) + WHERE_NETWORKCONFIG_READ = 12 + def __init__(self, name = "Plugin", where = [ ], description = "", icon = None, fnc = None, wakeupfnc = None, internal = False): self.name = name self.internal = internal -- cgit v1.2.3 From 1c5acf90ed52a7b8ce29aefa108fa2888bd48a98 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 18 Feb 2009 21:28:17 +0100 Subject: speedup --- lib/python/Components/config.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index a6d34152..e3a29b52 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -279,6 +279,7 @@ class ConfigSelection(ConfigElement): if default is None: default = self.choices.default() + self._descr = None self.default = self._value = self.last_value = default self.changed() @@ -296,6 +297,7 @@ class ConfigSelection(ConfigElement): self._value = value else: self._value = self.default + self._descr = None self.changed() def tostring(self, val): @@ -307,7 +309,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 +338,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) -- cgit v1.2.3 From 9208ede8da1fd495eafc24b9dd2d75d84f8a5952 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Thu, 19 Feb 2009 01:56:43 +0100 Subject: - increase video wizard timeout from 10 to 20 seconds - rearrange summary screen widgets - set summary screen before anything else in the wizard --- lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py | 4 ++-- lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml | 12 ++++++------ lib/python/Screens/Wizard.py | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py index 1d7ce7b5..095e94c0 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -13,8 +13,8 @@ config.misc.showtestcard = ConfigBoolean(default = False) class VideoWizardSummary(WizardSummary): skin = """ - - + + diff --git a/lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml b/lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml index 2a592aae..29ac4297 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml +++ b/lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml @@ -1,7 +1,7 @@ - + - + self["portpic"].show() @@ -9,7 +9,7 @@ self.clearSelectedKeys() self.selectKey("OK") - + @@ -20,7 +20,7 @@ self.selectKey("DOWN") self["portpic"].hide() - + self.condition = (self.port != "DVI" or self.mode == "PC") @@ -46,7 +46,7 @@ self.selectKey("DOWN") self.rateSelect("60Hz") - + self.condition = (self.port == "DVI" and self.mode in ["720p", "1080i"]) @@ -77,7 +77,7 @@ self.selectKey("UP") self.selectKey("DOWN") - + self.condition = (self.port == "DVI" and self.mode in ["720p", "1080i"]) diff --git a/lib/python/Screens/Wizard.py b/lib/python/Screens/Wizard.py index 2326b915..7d454f43 100755 --- a/lib/python/Screens/Wizard.py +++ b/lib/python/Screens/Wizard.py @@ -475,6 +475,11 @@ class Wizard(Screen): self.currStep += 1 self.updateValues() else: + if self.wizard[self.currStep].has_key("displaytext"): + displaytext = self.wizard[self.currStep]["displaytext"] + print "set LCD text" + for x in self.lcdCallbacks: + x(displaytext) if len(self.stepHistory) == 0 or self.stepHistory[-1] != self.currStep: self.stepHistory.append(self.currStep) print "wizard step:", self.wizard[self.currStep] -- cgit v1.2.3 From 6bb47ff06e84149578671195a702e22ada245d37 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Thu, 19 Feb 2009 13:29:45 +0100 Subject: always show option to open file browser in exit dialoge (also when playing from actual dvd medium) --- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index 8e2a9f3a..6a8ffc6f 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -511,7 +511,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP def askLeavePlayer(self): choices = [(_("Exit"), "exit"), (_("Continue playing"), "play")] - if not self.physicalDVD: + if True or not self.physicalDVD: choices.insert(1,(_("Return to file browser"), "browser")) self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list = choices) -- cgit v1.2.3 From e180b709f892553d73784a30dc32e8251ad7b544 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 20 Feb 2009 02:21:50 +0100 Subject: split "delay after continuous tone" value in "delay after continuous tone disable before diseqc" and "delay after final continuous tone change" value and increment the first value now to 25 to fix "tune failed" problems with some diseqc switches --- lib/dvb/sec.cpp | 8 ++++---- lib/dvb/sec.h | 3 ++- lib/python/Components/NimManager.py | 10 +++++++--- .../Plugins/SystemPlugins/SatelliteEquipmentControl/plugin.py | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) (limited to 'lib/python') diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index ac1a2028..8aa0631c 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -563,7 +563,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA compare.tone = iDVBFrontend::toneOff; sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) ); sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) ); - sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE]) ); + sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC]) ); if (diseqc13V) vlt = iDVBFrontend::voltage13; @@ -705,7 +705,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA compare.tone = iDVBFrontend::toneOff; sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) ); sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) ); - sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE]) ); + sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC]) ); compare.voltage = iDVBFrontend::voltageOff; compare.steps = +4; @@ -839,7 +839,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA compare.tone = tone; sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) ); sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) ); - sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE]) ); + sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_FINAL_CONT_TONE_CHANGE]) ); sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) ); cmd.direction=1; // check for running rotor @@ -884,7 +884,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA compare.tone = tone; sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) ); sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) ); - sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE]) ); + sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_FINAL_CONT_TONE_CHANGE]) ); } sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_SWITCHPARMS) ); diff --git a/lib/dvb/sec.h b/lib/dvb/sec.h index 5bff6bf7..5d969328 100644 --- a/lib/dvb/sec.h +++ b/lib/dvb/sec.h @@ -271,7 +271,8 @@ class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl DECLARE_REF(eDVBSatelliteEquipmentControl); public: enum { - DELAY_AFTER_CONT_TONE=0, // delay after continuous tone change + DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC=0, // delay after continuous tone disable before diseqc command + DELAY_AFTER_FINAL_CONT_TONE_CHANGE, // delay after continuous tone change before tune DELAY_AFTER_FINAL_VOLTAGE_CHANGE, // delay after voltage change at end of complete sequence DELAY_BETWEEN_DISEQC_REPEATS, // delay between repeated diseqc commands DELAY_AFTER_LAST_DISEQC_CMD, // delay after last diseqc command diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 6dc49dcf..75ad3779 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -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)) diff --git a/lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/plugin.py b/lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/plugin.py index ec223d3e..ec472e72 100644 --- a/lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/plugin.py @@ -25,7 +25,8 @@ class SecParameterSetup(Screen, ConfigListScreen): list = [ ("Delay after diseqc reset command", config.sec.delay_after_diseqc_reset_cmd), ("Delay after diseqc peripherial poweron command", config.sec.delay_after_diseqc_peripherial_poweron_cmd), - ("Delay after continuous tone change", config.sec.delay_after_continuous_tone_change), + ("Delay after continuous tone disable before diseqc", config.sec.delay_after_continuous_tone_disable_before_diseqc), + ("Delay after final continuous tone change", config.sec.delay_after_final_continuous_tone_change), ("Delay after last voltage change", config.sec.delay_after_final_voltage_change), ("Delay between diseqc commands", config.sec.delay_between_diseqc_repeats), ("Delay after last diseqc command", config.sec.delay_after_last_diseqc_command), -- cgit v1.2.3 From f22a2aca3352ab78bd73da7edae59071293ace73 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 20 Feb 2009 11:22:35 +0100 Subject: improve usability: hide some advanced options below expert, clear out and resort main menu, hide button text of inactive buttons, warn when adding a new title which causes exceeding single and dual layer medium size --- .../Plugins/Extensions/DVDBurn/ProjectSettings.py | 47 +++++++++++++--------- lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 26 +++++++----- .../Plugins/Extensions/DVDBurn/TitleProperties.py | 26 ++++++------ 3 files changed, 58 insertions(+), 41 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py b/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py index 7407263d..e97961b4 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py +++ b/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py @@ -102,9 +102,15 @@ class ProjectSettings(Screen,ConfigListScreen): self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self["key_yellow"] = StaticText(_("Load")) - self["key_blue"] = StaticText(_("Save")) + if config.usage.setup_level.index >= 2: # expert+ + self["key_blue"] = StaticText(_("Save")) + else: + self["key_blue"] = StaticText() - infotext = _("Available format variables") + ":\n$i=" + _("Track") + ", $t=" + _("Title") + ", $d=" + _("Description") + ", $l=" + _("length") + ", $c=" + _("chapters") + ",\n" + _("Record") + " $T=" + _("Begin time") + ", $Y=" + _("Year") + ", $M=" + _("month") + ", $D=" + _("day") + ",\n$A=" + _("audio tracks") + ", $C=" + _("Channel") + ", $f=" + _("filename") + if config.usage.setup_level.index >= 2: # expert+ + infotext = _("Available format variables") + ":\n$i=" + _("Track") + ", $t=" + _("Title") + ", $d=" + _("Description") + ", $l=" + _("length") + ", $c=" + _("chapters") + ",\n" + _("Record") + " $T=" + _("Begin time") + ", $Y=" + _("Year") + ", $M=" + _("month") + ", $D=" + _("day") + ",\n$A=" + _("audio tracks") + ", $C=" + _("Channel") + ", $f=" + _("filename") + else: + infotext = "" self["info"] = StaticText(infotext) self.settings = project.settings @@ -141,9 +147,10 @@ class ProjectSettings(Screen,ConfigListScreen): self.list.append(getConfigListEntry(_("ISO path"), self.settings.isopath)) if authormode.startswith("menu"): self.list.append(getConfigListEntry(_("Menu")+' '+_("template file"), self.settings.menutemplate)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("Title"), self.project.menutemplate.settings.titleformat)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("Subtitles"), self.project.menutemplate.settings.subtitleformat)) - self.list.append(getConfigListEntry(_("Menu")+' '+_("background image"), self.project.menutemplate.settings.menubg)) + if config.usage.setup_level.index >= 2: # expert+ + self.list.append(getConfigListEntry(_("Menu")+' '+_("Title"), self.project.menutemplate.settings.titleformat)) + self.list.append(getConfigListEntry(_("Menu")+' '+_("Subtitles"), self.project.menutemplate.settings.subtitleformat)) + self.list.append(getConfigListEntry(_("Menu")+' '+_("background image"), self.project.menutemplate.settings.menubg)) #self.list.append(getConfigListEntry(_("Menu")+' '+_("headline")+' '+_("color"), self.settings.color_headline)) #self.list.append(getConfigListEntry(_("Menu")+' '+_("text")+' '+_("color"), self.settings.color_button)) #self.list.append(getConfigListEntry(_("Menu")+' '+_("highlighted button")+' '+_("color"), self.settings.color_highlight)) @@ -151,12 +158,13 @@ class ProjectSettings(Screen,ConfigListScreen): #self.list.append(getConfigListEntry(_("Font size")+' ('+_("headline")+', '+_("Title")+', '+_("Subtitles")+')', self.settings.font_size)) #self.list.append(getConfigListEntry(_("Menu")+' '+_("spaces (top, between rows, left)"), self.settings.space)) #self.list.append(getConfigListEntry(_("Menu")+' '+_("Audio"), self.settings.menuaudio)) - if authormode != "data_ts": - self.list.append(getConfigListEntry(_("Titleset mode"), self.settings.titlesetmode)) - if self.settings.titlesetmode.getValue() == "single" or authormode == "just_linked": - self.list.append(getConfigListEntry(_("VMGM (intro trailer)"), self.settings.vmgm)) - else: - self.list.append(getConfigListEntry(("DVD data format"), self.settings.dataformat)) + if config.usage.setup_level.index >= 2: # expert+ + if authormode != "data_ts": + self.list.append(getConfigListEntry(_("Titleset mode"), self.settings.titlesetmode)) + if self.settings.titlesetmode.getValue() == "single" or authormode == "just_linked": + self.list.append(getConfigListEntry(_("VMGM (intro trailer)"), self.settings.vmgm)) + else: + self.list.append(getConfigListEntry(("DVD data format"), self.settings.dataformat)) self["config"].setList(self.list) @@ -192,14 +200,15 @@ class ProjectSettings(Screen,ConfigListScreen): self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, "project", self.settings) def saveProject(self): - self.applySettings() - ret = self.project.saveProject(resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/") - if ret.startswith: - text = _("Save")+' '+_('OK')+':\n'+ret - self.session.open(MessageBox,text,type = MessageBox.TYPE_INFO) - else: - text = _("Save")+' '+_('Error') - self.session.open(MessageBox,text,type = MessageBox.TYPE_ERROR) + if config.usage.setup_level.index >= 2: # expert+ + self.applySettings() + ret = self.project.saveProject(resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/") + if ret.startswith: + text = _("Save")+' '+_('OK')+':\n'+ret + self.session.open(MessageBox,text,type = MessageBox.TYPE_INFO) + else: + text = _("Save")+' '+_('Error') + self.session.open(MessageBox,text,type = MessageBox.TYPE_ERROR) def FileBrowserClosed(self, path, scope): if scope == "menutemplate": diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index 749f80eb..7e736f9f 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -57,9 +57,9 @@ class TitleList(Screen, HelpableScreen): "cancel": self.leave }) - self["key_red"] = StaticText(_("Remove title")) + self["key_red"] = StaticText() self["key_green"] = StaticText(_("Add title")) - self["key_yellow"] = StaticText(_("Title properties")) + self["key_yellow"] = StaticText() self["key_blue"] = StaticText(_("Settings")) self["title_label"] = StaticText() @@ -74,6 +74,7 @@ class TitleList(Screen, HelpableScreen): self["titles"] = List(list = [ ], enableWrapAround = True, item_height=30, fonts = [gFont("Regular", 20)]) self.updateTitleList() + self.previous_size = 0 def checkBackgroundJobs(self): for job in job_manager.getPendingJobs(): @@ -90,19 +91,15 @@ class TitleList(Screen, HelpableScreen): if self.backgroundJob: j = self.backgroundJob menu.append(("%s: %s (%d%%)" % (j.getStatustext(), j.name, int(100*j.progress/float(j.end))), self.showBackgroundJob)) + menu.append((_("DVD media toolbox"), self.toolbox)) + menu.append((_("Preview menu"), self.previewMenu)) if self.project.settings.output.getValue() == "dvd": menu.append((_("Burn DVD"), self.burnProject)) elif self.project.settings.output.getValue() == "iso": menu.append((_("Create DVD-ISO"), self.burnProject)) menu.append((_("Burn existing image to DVD"), self.selectImage)) - menu.append((_("DVD media toolbox"), self.toolbox)) - menu.append((_("Preview menu"), self.previewMenu)) - menu.append((_("Collection settings"), self.settings)) - menu.append((_("Reset and renumerate title names"), self.resetTitles)) menu.append((_("Edit chapters of current title"), self.editTitle)) - menu.append((_("Properties of current title"), self.titleProperties)) - menu.append((_("Add a new title"), self.addTitle)) - menu.append((_("Remove title"), self.removeCurrentTitle)) + menu.append((_("Reset and renumerate title names"), self.resetTitles)) menu.append((_("Exit"), self.leave)) self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu) @@ -235,6 +232,12 @@ class TitleList(Screen, HelpableScreen): totalsize += title.estimatedDiskspace self["titles"].list = res self.updateSize(totalsize) + if len(res): + self["key_red"].text = _("Remove title") + self["key_yellow"].text = _("Title properties") + else: + self["key_red"].text = "" + self["key_yellow"].text = "" def updateSize(self, totalsize): size = int((totalsize/1024)/1024) @@ -244,14 +247,19 @@ class TitleList(Screen, HelpableScreen): percent = 100 * size / float(max_DL) self["space_label"].text = "%d MB - " % size + _("exceeds dual layer medium!") + " (%.2f%% " % (100-percent) + _("free") + ")" self["space_bar"].value = int(percent) + if self.previous_size < max_DL: + self.session.open(MessageBox,text = _("exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR) elif size > max_SL: percent = 100 * size / float(max_DL) self["space_label"].text = "%d MB " % size + _("of a DUAL layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")" self["space_bar"].value = int(percent) + if self.previous_size < max_SL: + self.session.open(MessageBox,text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), type = MessageBox.TYPE_INFO) elif size < max_SL: percent = 100 * size / float(max_SL) self["space_label"].text = "%d MB " % size + _("of a SINGLE layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")" self["space_bar"].value = int(percent) + self.previous_size = size def getCurrentTitle(self): t = self["titles"].getCurrent() diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py index 63ae6c1f..40b85b70 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py @@ -72,19 +72,19 @@ class TitleProperties(Screen,ConfigListScreen): self.list.append(getConfigListEntry("DVD " + _("Track"), self.properties.position)) self.list.append(getConfigListEntry("DVD " + _("Title"), self.properties.menutitle)) self.list.append(getConfigListEntry("DVD " + _("Description"), self.properties.menusubtitle)) - for audiotrack in self.properties.audiotracks: - DVB_aud = audiotrack.DVB_lang.getValue() or audiotrack.pid.getValue() - self.list.append(getConfigListEntry(_("burn audio track (%s)") % DVB_aud, audiotrack.active)) - if audiotrack.active.getValue(): - self.list.append(getConfigListEntry(_("audio track (%s) format") % DVB_aud, audiotrack.format)) - self.list.append(getConfigListEntry(_("audio track (%s) language") % DVB_aud, audiotrack.language)) - - self.list.append(getConfigListEntry("DVD " + _("Aspect Ratio"), self.properties.aspect)) - if self.properties.aspect.getValue() == "16:9": - self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.widescreen)) - else: - self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.crop)) - + if config.usage.setup_level.index >= 2: # expert+ + for audiotrack in self.properties.audiotracks: + DVB_aud = audiotrack.DVB_lang.getValue() or audiotrack.pid.getValue() + self.list.append(getConfigListEntry(_("burn audio track (%s)") % DVB_aud, audiotrack.active)) + if audiotrack.active.getValue(): + self.list.append(getConfigListEntry(_("audio track (%s) format") % DVB_aud, audiotrack.format)) + self.list.append(getConfigListEntry(_("audio track (%s) language") % DVB_aud, audiotrack.language)) + + self.list.append(getConfigListEntry("DVD " + _("Aspect Ratio"), self.properties.aspect)) + if self.properties.aspect.getValue() == "16:9": + self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.widescreen)) + else: + self.list.append(getConfigListEntry("DVD " + "widescreen", self.properties.crop)) if len(title.chaptermarks) == 0: self.list.append(getConfigListEntry(_("Auto chapter split every ? minutes (0=never)"), self.properties.autochapter)) infotext = "DVB " + _("Title") + ': ' + title.DVBname + "\n" + _("Description") + ': ' + title.DVBdescr + "\n" + _("Channel") + ': ' + title.DVBchannel + '\n' + _("Begin time") + title.formatDVDmenuText(": $D.$M.$Y, $T\n", self.title_idx+1) -- cgit v1.2.3 From b38a38eabbfc7cf4814d6bb9be90d857e8282f9d Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 20 Feb 2009 14:17:18 +0100 Subject: follow changes in module Tuner with added rolloff, pilot and system/modulation in DiseqcTester/TuneTest --- lib/python/Components/TuneTest.py | 12 ++++++------ lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Components/TuneTest.py b/lib/python/Components/TuneTest.py index de7b0098..8e8644e3 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]) @@ -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, , , , ) - # 0 1 2 3 4 5 6 7 8 9 + # transponder = (frequency, symbolrate, polarisation, fec, inversion, orbpos, , , , , , ) + # 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/Plugins/SystemPlugins/DiseqcTester/plugin.py b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py index 07861954..2bd01522 100644 --- a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py +++ b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py @@ -264,8 +264,8 @@ class DiseqcTester(Screen, TuneTest, ResultParser): def readTransponderList(self): for sat in nimmanager.getSatListForNim(self.feid): for transponder in nimmanager.getTransponders(sat[0]): - #print transponder - mytransponder = (transponder[1] / 1000, transponder[2] / 1000, transponder[3], transponder[4], transponder[5], sat[0], None, None, transponder[10], transponder[11]) + print transponder + mytransponder = (transponder[1] / 1000, transponder[2] / 1000, transponder[3], transponder[4], transponder[7], sat[0], transponder[5], transponder[6], transponder[8], transponder[9], transponder[10], transponder[11]) self.analyseTransponder(mytransponder) def getIndexForTransponder(self, transponder): -- cgit v1.2.3 From 2898c67ef32408ab8b8191294eee59e8784a4870 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 20 Feb 2009 15:48:49 +0100 Subject: remove debug print --- lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py index 2bd01522..cbd6bc89 100644 --- a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py +++ b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py @@ -264,7 +264,7 @@ class DiseqcTester(Screen, TuneTest, ResultParser): def readTransponderList(self): for sat in nimmanager.getSatListForNim(self.feid): for transponder in nimmanager.getTransponders(sat[0]): - print transponder + #print transponder mytransponder = (transponder[1] / 1000, transponder[2] / 1000, transponder[3], transponder[4], transponder[7], sat[0], transponder[5], transponder[6], transponder[8], transponder[9], transponder[10], transponder[11]) self.analyseTransponder(mytransponder) -- cgit v1.2.3 From 7a8ce89bacc1f2f6ff77409b9a879462daf09afe Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sun, 22 Feb 2009 23:16:25 +0100 Subject: fix entry_changed --- lib/python/Components/Converter/StringList.py | 3 ++- lib/python/Components/Sources/List.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Components/Converter/StringList.py b/lib/python/Components/Converter/StringList.py index 213f08bc..b21a7cf9 100644 --- a/lib/python/Components/Converter/StringList.py +++ b/lib/python/Components/Converter/StringList.py @@ -52,4 +52,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/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 -- cgit v1.2.3 From 75b79db2285d206174382ba81366d50447c4b830 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sun, 22 Feb 2009 23:17:07 +0100 Subject: disable KEY_0 to convert current item to mark as there is no way to undo this --- lib/python/Plugins/Extensions/CutListEditor/keymap.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/CutListEditor/keymap.xml b/lib/python/Plugins/Extensions/CutListEditor/keymap.xml index 741d9eb6..ae4fbb4b 100644 --- a/lib/python/Plugins/Extensions/CutListEditor/keymap.xml +++ b/lib/python/Plugins/Extensions/CutListEditor/keymap.xml @@ -33,7 +33,7 @@ - + -- cgit v1.2.3 From 4b8fe9d6650b7527b3c588f72540cea3c04423b9 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 23 Feb 2009 15:42:59 +0100 Subject: show warning message when trying to play video container with DTS stream (requires gst-plugins-dvbmedisink > 20090223) --- lib/python/Plugins/Extensions/MediaPlayer/plugin.py | 15 +++++++++++---- lib/service/servicemp3.cpp | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 3e023841..e81750ba 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -224,7 +224,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.__event_tracker = ServiceEventTracker(screen=self, eventmap= { iPlayableService.evUpdatedInfo: self.__evUpdatedInfo, - iPlayableService.evUser+11: self.__evDecodeError, + iPlayableService.evUser+10: self.__evAudioDecodeError, + iPlayableService.evUser+11: self.__evVideoDecodeError, iPlayableService.evUser+12: self.__evPluginError, iPlayableService.evUser+13: self["coverArt"].embeddedCoverArt }) @@ -268,11 +269,17 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB print "[__evUpdatedInfo] title %d of %d (%s)" % (currenttitle, totaltitles, sTitle) self.readTitleInformation() - def __evDecodeError(self): + def __evAudioDecodeError(self): + currPlay = self.session.nav.getCurrentService() + sAudioType = currPlay.info().getInfoString(iServiceInformation.sUser+10) + print "[__evAudioDecodeError] audio-codec %s can't be decoded by hardware" % (sAudioType) + self.session.open(MessageBox, _("This Dreambox can't decode %s streams!") % sAudioType, type = MessageBox.TYPE_INFO,timeout = 20 ) + + def __evVideoDecodeError(self): currPlay = self.session.nav.getCurrentService() sVideoType = currPlay.info().getInfoString(iServiceInformation.sVideoType) - print "[__evDecodeError] video-codec %s can't be decoded by hardware" % (sVideoType) - self.session.open(MessageBox, _("This Dreambox can't decode %s video streams!") % sVideoType, type = MessageBox.TYPE_INFO,timeout = 20 ) + print "[__evVideoDecodeError] video-codec %s can't be decoded by hardware" % (sVideoType) + self.session.open(MessageBox, _("This Dreambox can't decode %s streams!") % sVideoType, type = MessageBox.TYPE_INFO,timeout = 20 ) def __evPluginError(self): currPlay = self.session.nav.getCurrentService() diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index bbcb3b5c..d90186a5 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -838,6 +838,7 @@ int eServiceMP3::getInfo(int w) case sGenre: case sVideoType: case sTimeCreate: + case sUser+10: case sUser+12: return resIsString; case sCurrentTitle: @@ -886,6 +887,9 @@ std::string eServiceMP3::getInfoString(int w) case sGenre: tag = GST_TAG_GENRE; break; + case sUser+10: + tag = GST_TAG_AUDIO_CODEC; + break; case sVideoType: tag = GST_TAG_VIDEO_CODEC; break; @@ -1025,7 +1029,7 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) source = GST_MESSAGE_SRC(msg); sourceName = gst_object_get_name(source); -#if 0 +#if 1 if (gst_message_get_structure(msg)) { gchar *string = gst_structure_to_string(gst_message_get_structure(msg)); @@ -1050,8 +1054,13 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) eWarning("Gstreamer error: %s (%i) from %s", err->message, err->code, sourceName ); if ( err->domain == GST_STREAM_ERROR ) { - if ( err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND && g_strrstr(sourceName, "videosink") ) - m_event((iPlayableService*)this, evUser+11); + if ( err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND ) + { + if ( g_strrstr(sourceName, "videosink") ) + m_event((iPlayableService*)this, evUser+11); + else if ( g_strrstr(sourceName, "audiosink") ) + m_event((iPlayableService*)this, evUser+10); + } else if ( err->code == GST_STREAM_ERROR_FAILED && g_strrstr(sourceName, "file-source") ) { eWarning("error in tag parsing, linking mp3parse directly to file-sink, bypassing id3demux..."); -- cgit v1.2.3 From 574f425cc1ebece0aa5f09fb77a8cb7ad0310a1f Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 24 Feb 2009 20:56:21 +0100 Subject: small optimizations and cleanups by Moritz Venn --- RecordTimer.py | 2 +- keymapparser.py | 4 +- lib/python/Components/Converter/FrontendInfo.py | 4 +- lib/python/Components/Converter/RdsInfo.py | 14 +- lib/python/Components/Converter/ServiceInfo.py | 36 +- lib/python/Components/Converter/ServiceName.py | 2 +- lib/python/Components/Converter/ServicePosition.py | 6 +- lib/python/Components/Converter/ServiceTime.py | 2 +- lib/python/Components/Converter/Streaming.py | 3 - lib/python/Components/DreamInfoHandler.py | 2 +- lib/python/Components/Element.py | 4 +- lib/python/Components/Harddisk.py | 15 +- lib/python/Components/HelpMenuList.py | 12 +- lib/python/Components/Language.py | 13 +- lib/python/Components/NimManager.py | 28 +- lib/python/Components/ParentalControl.py | 7 +- lib/python/Components/ParentalControlList.py | 6 +- lib/python/Components/PluginComponent.py | 6 +- lib/python/Components/PluginList.py | 40 +- lib/python/Components/Renderer/FrontpanelLed.py | 3 - lib/python/Components/Renderer/Picon.py | 4 +- lib/python/Components/Scanner.py | 5 +- lib/python/Components/SelectionList.py | 18 +- lib/python/Components/Sources/RdsDecoder.py | 2 +- lib/python/Components/TimerList.py | 2 +- lib/python/Components/TimerSanityCheck.py | 3 +- lib/python/Components/Timezones.py | 7 +- lib/python/Components/config.py | 6 +- .../Plugins/Extensions/CutListEditor/plugin.py | 6 +- .../Plugins/Extensions/DVDBurn/TitleProperties.py | 7 +- lib/python/Plugins/Extensions/DVDBurn/plugin.py | 5 +- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 2 +- .../Plugins/Extensions/FileManager/plugin.py | 5 +- .../Plugins/Extensions/MediaPlayer/plugin.py | 8 +- .../Plugins/Extensions/MediaScanner/plugin.py | 10 +- .../Plugins/Extensions/PicturePlayer/plugin.py | 2 +- lib/python/Plugins/Extensions/SocketMMI/plugin.py | 2 +- .../Plugins/SystemPlugins/DiseqcTester/plugin.py | 2 +- .../SystemPlugins/SoftwareManager/BackupRestore.py | 2 - .../SystemPlugins/Videomode/VideoHardware.py | 4 +- .../Plugins/SystemPlugins/Videomode/VideoWizard.py | 2 +- .../Plugins/SystemPlugins/Videomode/plugin.py | 13 +- lib/python/Screens/About.py | 4 +- lib/python/Screens/ChannelSelection.py | 40 +- lib/python/Screens/Ci.py | 2 +- lib/python/Screens/Console.py | 3 +- lib/python/Screens/DefaultWizard.py | 4 +- lib/python/Screens/EpgSelection.py | 2 +- lib/python/Screens/EventView.py | 16 +- lib/python/Screens/HarddiskSetup.py | 2 +- lib/python/Screens/HelpMenu.py | 16 +- lib/python/Screens/InfoBar.py | 4 +- lib/python/Screens/InfoBarGenerics.py | 83 ++- lib/python/Screens/LanguageSelection.py | 19 +- lib/python/Screens/LocationBox.py | 17 +- lib/python/Screens/Menu.py | 5 +- lib/python/Screens/MessageBox.py | 4 +- lib/python/Screens/MovieSelection.py | 18 +- lib/python/Screens/Mute.py | 3 +- lib/python/Screens/NetworkSetup.py | 23 +- lib/python/Screens/NumericalTextInputHelpDialog.py | 2 +- lib/python/Screens/PVRState.py | 4 +- lib/python/Screens/ParentalControlSetup.py | 4 +- lib/python/Screens/PluginBrowser.py | 18 +- lib/python/Screens/Rc.py | 1 - lib/python/Screens/Satconfig.py | 14 +- lib/python/Screens/ServiceInfo.py | 24 +- lib/python/Screens/Setup.py | 7 +- lib/python/Screens/Standby.py | 7 +- lib/python/Screens/SubservicesQuickzap.py | 24 +- lib/python/Screens/SubtitleDisplay.py | 5 +- lib/python/Screens/Subtitles.py | 31 +- lib/python/Screens/TaskView.py | 6 +- lib/python/Screens/TimeDateInput.py | 7 +- lib/python/Screens/TimerEdit.py | 13 +- lib/python/Screens/TimerEntry.py | 30 +- lib/python/Screens/TimerSelection.py | 1 - lib/python/Screens/VirtualKeyBoard.py | 580 +++++++++++---------- lib/python/Screens/Wizard.py | 7 +- lib/python/Screens/WizardLanguage.py | 4 - lib/python/Tools/NumericalTextInput.py | 2 +- mytest.py | 15 +- skin.py | 8 +- timer.py | 4 +- 84 files changed, 673 insertions(+), 736 deletions(-) (limited to 'lib/python') diff --git a/RecordTimer.py b/RecordTimer.py index aeff9d05..9f3b2ffb 100644 --- a/RecordTimer.py +++ b/RecordTimer.py @@ -63,7 +63,7 @@ class RecordTimerEntry(timer.TimerEntry, object): if event == iRecordableService.evEnd: print "RecordTimer.staticGotRecordEvent(iRecordableService.evEnd)" recordings = NavigationInstance.instance.getRecordings() - if not len(recordings): # no more recordings exist + if not recordings: # no more recordings exist rec_time = NavigationInstance.instance.RecordTimer.getNextRecordingTime() if rec_time > 0 and (rec_time - time.time()) < 360: print "another recording starts in", rec_time - time.time(), "seconds... do not shutdown yet" diff --git a/keymapparser.py b/keymapparser.py index 63bca0f9..0e544e94 100644 --- a/keymapparser.py +++ b/keymapparser.py @@ -8,10 +8,10 @@ from Tools.KeyBindings import addKeyBinding class KeymapError(Exception): def __init__(self, message): - self.message = message + self.msg = message def __str__(self): - return self.message + return self.msg def parseKeys(context, filename, actionmap, device, keys): for x in keys.findall("key"): 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 for eEventTime converter" % type) + raise ElementError("'%s' is not 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/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/Harddisk.py b/lib/python/Components/Harddisk.py index 75d68fad..8664f79a 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 "" @@ -358,8 +358,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 +370,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 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/NimManager.py b/lib/python/Components/NimManager.py index 75ad3779..48778571 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) @@ -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": 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 7bb584e5..c0083966 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: 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/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..1109860a 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 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/config.py b/lib/python/Components/config.py index e3a29b52..79e99b03 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -385,7 +385,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 @@ -1187,7 +1187,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): @@ -1352,7 +1352,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): diff --git a/lib/python/Plugins/Extensions/CutListEditor/plugin.py b/lib/python/Plugins/Extensions/CutListEditor/plugin.py index 1ef15a53..ed7cfb70 100644 --- a/lib/python/Plugins/Extensions/CutListEditor/plugin.py +++ b/lib/python/Plugins/Extensions/CutListEditor/plugin.py @@ -317,7 +317,7 @@ class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, He elif result == CutListContextMenu.RET_ENDCUT: # remove in/out marks between the new cut for (where, what) in self.cut_list[:]: - if self.cut_start <= where <= self.context_position and what in [0,1]: + if self.cut_start <= where <= self.context_position and what in (0,1): self.cut_list.remove((where, what)) bisect.insort(self.cut_list, (self.cut_start, 1)) @@ -350,7 +350,7 @@ class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, He elif result == CutListContextMenu.RET_REMOVEBEFORE: # remove in/out marks before current position for (where, what) in self.cut_list[:]: - if where <= self.context_position and what in [0,1]: + if where <= self.context_position and what in (0,1): self.cut_list.remove((where, what)) # add 'in' point bisect.insort(self.cut_list, (self.context_position, 0)) @@ -358,7 +358,7 @@ class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, He elif result == CutListContextMenu.RET_REMOVEAFTER: # remove in/out marks after current position for (where, what) in self.cut_list[:]: - if where >= self.context_position and what in [0,1]: + if where >= self.context_position and what in (0,1): self.cut_list.remove((where, what)) # add 'out' point bisect.insort(self.cut_list, (self.context_position, 1)) diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py index 40b85b70..1c2099fb 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py @@ -154,7 +154,7 @@ class LanguageChoices(): if len(key) == 2: self.langdict[key] = val[0] for key, val in self.langdict.iteritems(): - if key not in [syslang, 'en']: + if key not in (syslang, 'en'): self.langdict[key] = val self.choices.append((key, val)) self.choices.sort() @@ -164,8 +164,7 @@ class LanguageChoices(): def getLanguage(self, DVB_lang): DVB_lang = DVB_lang.lower() - stripwords = ["stereo", "audio", "description", "2ch", "dolby digital"] - for word in stripwords: + for word in ("stereo", "audio", "description", "2ch", "dolby digital"): DVB_lang = DVB_lang.replace(word,"").strip() for key, val in LanguageCodes.iteritems(): if DVB_lang.find(key.lower()) == 0: @@ -183,4 +182,4 @@ class LanguageChoices(): return key return "nolang" -languageChoices = LanguageChoices() \ No newline at end of file +languageChoices = LanguageChoices() diff --git a/lib/python/Plugins/Extensions/DVDBurn/plugin.py b/lib/python/Plugins/Extensions/DVDBurn/plugin.py index 29076cea..45f438da 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/plugin.py +++ b/lib/python/Plugins/Extensions/DVDBurn/plugin.py @@ -12,5 +12,6 @@ def main_add(session, service, **kwargs): dvdburn.selectedSource(service) def Plugins(**kwargs): - return [PluginDescriptor(name="DVD Burn", description=_("Burn to DVD..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc=main_add, icon="dvdburn.png"), - PluginDescriptor(name="DVD Burn", description=_("Burn to DVD..."), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main, icon="dvdburn.png") ] + descr = _("Burn to DVD...") + return [PluginDescriptor(name="DVD Burn", description=descr, where = PluginDescriptor.WHERE_MOVIELIST, fnc=main_add, icon="dvdburn.png"), + PluginDescriptor(name="DVD Burn", description=descr, where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main, icon="dvdburn.png") ] diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index 6a8ffc6f..80629c5d 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -705,7 +705,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "DVD", - description = "Play DVD", + description = _("Play DVD"), openfnc = filescan_open, )] diff --git a/lib/python/Plugins/Extensions/FileManager/plugin.py b/lib/python/Plugins/Extensions/FileManager/plugin.py index 12389813..62c9e7b2 100644 --- a/lib/python/Plugins/Extensions/FileManager/plugin.py +++ b/lib/python/Plugins/Extensions/FileManager/plugin.py @@ -59,5 +59,6 @@ def main(session, **kwargs): session.open(FileManager) def Plugins(**kwargs): - return [PluginDescriptor(name="File-Manager", description="Lets you view/edit files in your Dreambox", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main), - PluginDescriptor(name="File-Manager", description="Lets you view/edit files in your Dreambox", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)] + descr = _("Lets you view/edit files in your Dreambox") + return [PluginDescriptor(name="File-Manager", description=descr, where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main), + PluginDescriptor(name="File-Manager", description=descr, where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)] diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index e81750ba..e26c65d4 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -991,7 +991,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "Movie", - description = "View Movies...", + description = _("View Movies..."), openfnc = filescan_open, ), Scanner(mimetypes = ["video/x-vcd"], @@ -1001,7 +1001,7 @@ def filescan(**kwargs): ScanPath(path = "MPEGAV", with_subdirs = False), ], name = "Video CD", - description = "View Video CD...", + description = _("View Video CD..."), openfnc = filescan_open, ), Scanner(mimetypes = ["audio/mpeg", "audio/x-wav", "application/ogg", "audio/x-flac"], @@ -1010,7 +1010,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "Music", - description = "Play Music...", + description = _("Play Music..."), openfnc = filescan_open, )] try: @@ -1022,7 +1022,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "Audio-CD", - description = "Play Audio-CD...", + description = _("Play Audio-CD..."), openfnc = audioCD_open, )) return mediatypes diff --git a/lib/python/Plugins/Extensions/MediaScanner/plugin.py b/lib/python/Plugins/Extensions/MediaScanner/plugin.py index 2c31197d..0cefa353 100755 --- a/lib/python/Plugins/Extensions/MediaScanner/plugin.py +++ b/lib/python/Plugins/Extensions/MediaScanner/plugin.py @@ -23,16 +23,16 @@ def mountpoint_choosen(option): list = [ (r.description, r, res[r], session) for r in res ] - if list == [ ]: + if not list: from Screens.MessageBox import MessageBox if access(mountpoint, F_OK|R_OK): - session.open(MessageBox, "No displayable files on this medium found!", MessageBox.TYPE_ERROR) + session.open(MessageBox, _("No displayable files on this medium found!"), MessageBox.TYPE_ERROR) else: print "ignore", mountpoint, "because its not accessible" return session.openWithCallback(execute, ChoiceBox, - title = "The following files were found...", + title = _("The following files were found..."), list = list) def scan(session): @@ -41,7 +41,7 @@ def scan(session): from Components.Harddisk import harddiskmanager parts = [ (r.description, r.mountpoint, session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)] - if len(parts): + if parts: for x in parts: if not access(x[1], F_OK|R_OK): parts.remove(x) @@ -91,7 +91,7 @@ def autostart(reason, **kwargs): def Plugins(**kwargs): return [ - PluginDescriptor(name="MediaScanner", description="Scan Files...", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main), + PluginDescriptor(name="MediaScanner", description=_("Scan Files..."), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main), # PluginDescriptor(where = PluginDescriptor.WHERE_MENU, fnc=menuHook), PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart), PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart) diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py index 05adb633..10e4e514 100644 --- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py +++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py @@ -586,7 +586,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "Pictures", - description = "View Photos...", + description = _("View Photos..."), openfnc = filescan_open, ) diff --git a/lib/python/Plugins/Extensions/SocketMMI/plugin.py b/lib/python/Plugins/Extensions/SocketMMI/plugin.py index 4eadf2ea..387c8306 100644 --- a/lib/python/Plugins/Extensions/SocketMMI/plugin.py +++ b/lib/python/Plugins/Extensions/SocketMMI/plugin.py @@ -22,6 +22,6 @@ def autostart(reason, **kwargs): socketHandler = SocketMMIMessageHandler() def Plugins(**kwargs): - return [ PluginDescriptor(name = "SocketMMI", description = "Python frontend for /tmp/mmi.socket", where = PluginDescriptor.WHERE_MENU, fnc = menu), + return [ PluginDescriptor(name = "SocketMMI", description = _("Python frontend for /tmp/mmi.socket"), where = PluginDescriptor.WHERE_MENU, fnc = menu), PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart), PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart) ] diff --git a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py index cbd6bc89..a4793949 100644 --- a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py +++ b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py @@ -623,7 +623,7 @@ class DiseqcTesterNimSelection(NimSelection): def showNim(self, nim): nimConfig = nimmanager.getNimConfig(nim.slot) if nim.isCompatible("DVB-S"): - if nimConfig.configMode.value in ["loopthrough", "equal", "satposdepends", "nothing"]: + if nimConfig.configMode.value in ("loopthrough", "equal", "satposdepends", "nothing"): return False if nimConfig.configMode.value == "simple": if nimConfig.diseqcMode.value == "positioner": diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py index 947452e9..327f08ed 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py @@ -308,5 +308,3 @@ class RestoreScreen(Screen, ConfigListScreen): def runAsync(self, finished_cb): self.finished_cb = finished_cb self.doRestore() - - \ No newline at end of file diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index 6a85c4da..64f79e04 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -67,7 +67,7 @@ class VideoHardware: else: mode = config.av.videomode[port].value force_widescreen = self.isWidescreenMode(port, mode) - is_widescreen = force_widescreen or config.av.aspect.value in ["16_9", "16_10"] + is_widescreen = force_widescreen or config.av.aspect.value in ("16_9", "16_10") is_auto = config.av.aspect.value == "auto" if is_widescreen: if force_widescreen: @@ -283,7 +283,7 @@ class VideoHardware: force_widescreen = self.isWidescreenMode(port, mode) - is_widescreen = force_widescreen or config.av.aspect.value in ["16_9", "16_10"] + is_widescreen = force_widescreen or config.av.aspect.value in ("16_9", "16_10") is_auto = config.av.aspect.value == "auto" policy2 = "policy" # use main policy diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py index 095e94c0..8f8bea09 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -165,7 +165,7 @@ class VideoWizard(WizardLanguage, Rc): config.misc.showtestcard.value = False def keyNumberGlobal(self, number): - if number in [1,2,3]: + if number in (1,2,3): if number == 1: self.hw.saveMode("DVI", "720p", "multi") elif number == 2: diff --git a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py index 30bdf796..5a7dfd1b 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py @@ -52,8 +52,9 @@ class VideoSetup(Screen, ConfigListScreen): def createSetup(self): level = config.usage.setup_level.index - self.list = [ ] - self.list.append(getConfigListEntry(_("Video Output"), config.av.videoport)) + self.list = [ + getConfigListEntry(_("Video Output"), config.av.videoport) + ] # if we have modes for this port: if config.av.videoport.value in config.av.videomode: @@ -76,9 +77,11 @@ class VideoSetup(Screen, ConfigListScreen): if not force_wide: self.list.append(getConfigListEntry(_("Aspect Ratio"), config.av.aspect)) - if force_wide or config.av.aspect.value in ["16_9", "16_10"]: - self.list.append(getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43)) - self.list.append(getConfigListEntry(_("Display >16:9 content as"), config.av.policy_169)) + if force_wide or config.av.aspect.value in ("16_9", "16_10"): + self.list.extend(( + getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43), + getConfigListEntry(_("Display >16:9 content as"), config.av.policy_169) + )) elif config.av.aspect.value == "4_3": self.list.append(getConfigListEntry(_("Display 16:9 content as"), config.av.policy_169)) diff --git a/lib/python/Screens/About.py b/lib/python/Screens/About.py index e184512b..6cf0f7b4 100644 --- a/lib/python/Screens/About.py +++ b/lib/python/Screens/About.py @@ -25,7 +25,7 @@ class About(Screen): self["FPVersion"] = StaticText(fp_version) nims = nimmanager.nimList() - for count in range(4): + for count in (0, 1, 2, 3): if count < len(nims): self["Tuner" + str(count)] = StaticText(nims[count]) else: @@ -33,7 +33,7 @@ class About(Screen): self["HDDHeader"] = StaticText(_("Detected HDD:")) hddlist = harddiskmanager.HDDList() - hdd = len(hddlist) > 0 and hddlist[0][1] or None + hdd = hddlist and hddlist[0][1] or None if hdd is not None and hdd.model() != "": self["hddA"] = StaticText(_("%s\n(%s, %d MB free)") % (hdd.model(), hdd.capacity(),hdd.free())) else: diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index ebfbe812..bae8f7de 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -95,7 +95,7 @@ class ChannelContextMenu(Screen): inBouquet = csel.getMutableList() is not None haveBouquets = config.usage.multibouquet.value - if not (len(current_sel_path) or current_sel_flags & (eServiceReference.isDirectory|eServiceReference.isMarker)): + if not (current_sel_path or current_sel_flags & (eServiceReference.isDirectory|eServiceReference.isMarker)): append_when_current_valid(current, menu, (_("show transponder info"), self.showServiceInformations), level = 2) if csel.bouquet_mark_edit == OFF and not csel.movemode: if not inBouquetRootList: @@ -558,7 +558,7 @@ class ChannelSelectionEdit: del self.servicePath[:] # remove all elements self.servicePath += self.savedPath # add saved elements del self.savedPath - self.setRoot(self.servicePath[len(self.servicePath)-1]) + self.setRoot(self.servicePath[-1]) def clearMarks(self): self.servicelist.clearMarks() @@ -781,13 +781,13 @@ class ChannelSelectionBase(Screen): def getServiceName(self, ref): str = self.removeModeStr(ServiceReference(ref).getServiceName()) - if not len(str): + if not str: pathstr = ref.getPath() - if pathstr.find('FROM PROVIDERS') != -1: + if 'FROM PROVIDERS' in pathstr: return _("Provider") - if pathstr.find('FROM SATELLITES') != -1: + if 'FROM SATELLITES' in pathstr: return _("Satellites") - if pathstr.find(') ORDER BY name') != -1: + if ') ORDER BY name' in pathstr: return _("All") return str @@ -831,9 +831,8 @@ class ChannelSelectionBase(Screen): def pathUp(self, justSet=False): prev = self.servicePath.pop() - length = len(self.servicePath) - if length: - current = self.servicePath[length-1] + if self.servicePath: + current = self.servicePath[-1] self.setRoot(current, justSet) if not justSet: self.setCurrentSelection(prev) @@ -961,7 +960,7 @@ class ChannelSelectionBase(Screen): self.enterPath(ref) def inBouquet(self): - if len(self.servicePath) > 0 and self.servicePath[0] == self.bouquet_root: + if self.servicePath and self.servicePath[0] == self.bouquet_root: return True return False @@ -1235,8 +1234,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect del self.servicePath[:] self.servicePath += path self.saveRoot() - plen = len(path) - root = path[plen-1] + root = path[-1] cur_root = self.getRoot() if cur_root and cur_root != root: self.setRoot(root) @@ -1249,7 +1247,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect for i in self.servicePath: path += i.toString() path += ';' - if len(path) and path != self.lastroot.value: + if path and path != self.lastroot.value: self.lastroot.value = path self.lastroot.save() @@ -1259,7 +1257,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect tmp = re.findall(self.lastroot.value) cnt = 0 for i in tmp: - self.servicePath.append(eServiceReference(i[:len(i)-1])) + self.servicePath.append(eServiceReference(i[:-1])) cnt += 1 if cnt: path = self.servicePath.pop() @@ -1269,7 +1267,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect self.saveRoot() def preEnterPath(self, refstr): - if len(self.servicePath) and self.servicePath[0] != eServiceReference(refstr): + if self.servicePath and self.servicePath[0] != eServiceReference(refstr): pathstr = self.lastroot.value if pathstr is not None and pathstr.find(refstr) == 0: self.restoreRoot() @@ -1289,16 +1287,14 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect self.lastservice.save() def setCurrentServicePath(self, path): - hlen = len(self.history) - if hlen > 0: + if self.history: self.history[self.history_pos] = path else: self.history.append(path) self.setHistoryPath() def getCurrentServicePath(self): - hlen = len(self.history) - if hlen > 0: + if self.history: return self.history[self.history_pos] return None @@ -1411,7 +1407,7 @@ class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelS for i in self.servicePathRadio: path += i.toString() path += ';' - if len(path) and path != config.radio.lastroot.value: + if path and path != config.radio.lastroot.value: config.radio.lastroot.value = path config.radio.lastroot.save() @@ -1421,7 +1417,7 @@ class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelS tmp = re.findall(config.radio.lastroot.value) cnt = 0 for i in tmp: - self.servicePathRadio.append(eServiceReference(i[:len(i)-1])) + self.servicePathRadio.append(eServiceReference(i[:-1])) cnt += 1 if cnt: path = self.servicePathRadio.pop() @@ -1431,7 +1427,7 @@ class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelS self.saveRoot() def preEnterPath(self, refstr): - if len(self.servicePathRadio) and self.servicePathRadio[0] != eServiceReference(refstr): + if self.servicePathRadio and self.servicePathRadio[0] != eServiceReference(refstr): pathstr = config.radio.lastroot.value if pathstr is not None and pathstr.find(refstr) == 0: self.restoreRoot() diff --git a/lib/python/Screens/Ci.py b/lib/python/Screens/Ci.py index 5028301e..a997f7fe 100644 --- a/lib/python/Screens/Ci.py +++ b/lib/python/Screens/Ci.py @@ -121,7 +121,7 @@ class MMIDialog(Screen): elif self.tag == "WAIT": self.handler.stopMMI(self.slotid) self.closeMmi() - elif self.tag in [ "MENU", "LIST" ]: + elif self.tag in ( "MENU", "LIST" ): print "cancel list" self.handler.answerMenu(self.slotid, 0) self.showWait() diff --git a/lib/python/Screens/Console.py b/lib/python/Screens/Console.py index c6b156cf..2058c041 100644 --- a/lib/python/Screens/Console.py +++ b/lib/python/Screens/Console.py @@ -11,7 +11,6 @@ class Console(Screen): """ def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None, closeOnSuccess = False): - self.skin = Console.skin Screen.__init__(self, session) self.finishedCallback = finishedCallback @@ -68,4 +67,4 @@ class Console(Screen): self.container.dataAvail.remove(self.dataAvail) def dataAvail(self, str): - self["text"].setText(self["text"].getText() + str) \ No newline at end of file + self["text"].setText(self["text"].getText() + str) diff --git a/lib/python/Screens/DefaultWizard.py b/lib/python/Screens/DefaultWizard.py index 9883dc8e..73b07acf 100644 --- a/lib/python/Screens/DefaultWizard.py +++ b/lib/python/Screens/DefaultWizard.py @@ -96,8 +96,6 @@ def filescan_open(list, session, **kwargs): def filescan(**kwargs): from Components.Scanner import Scanner, ScanPath - from mimetypes import add_type - add_type("application/x-dream-package", "dmpkg") return \ Scanner(mimetypes = ["application/x-dream-package"], paths_to_scan = @@ -106,7 +104,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "Dream-Package", - description = "Install settings, skins, software...", + description = _("Install settings, skins, software..."), openfnc = filescan_open, ) print "add dreampackage scanner plugin" diff --git a/lib/python/Screens/EpgSelection.py b/lib/python/Screens/EpgSelection.py index e7388fc2..ae96333e 100644 --- a/lib/python/Screens/EpgSelection.py +++ b/lib/python/Screens/EpgSelection.py @@ -68,7 +68,7 @@ class EPGSelection(Screen): self["key_green"] = Button(_("Add timer")) self.key_green_choice = self.ADD_TIMER self.key_red_choice = self.EMPTY - self["list"] = EPGList(type = self.type, selChangedCB = self.onSelectionChanged, timer = self.session.nav.RecordTimer) + self["list"] = EPGList(type = self.type, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer) self["actions"] = ActionMap(["EPGSelectActions", "OkCancelActions"], { diff --git a/lib/python/Screens/EventView.py b/lib/python/Screens/EventView.py index 6aed1e11..c55d9527 100644 --- a/lib/python/Screens/EventView.py +++ b/lib/python/Screens/EventView.py @@ -20,7 +20,7 @@ class EventViewBase: self.similarEPGCB = similarEPGCB self.cbFunc = callback self.currentService=Ref - self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and len(Ref.ref.getPath()) + self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and Ref.ref.getPath() self.event = Event self["epg_description"] = ScrollLabel() self["datetime"] = Label() @@ -134,12 +134,12 @@ class EventViewBase: text = event.getEventName() short = event.getShortDescription() ext = event.getExtendedDescription() - if len(short) > 0 and short != text: - text = text + '\n\n' + short - if len(ext) > 0: - if len(text) > 0: - text = text + '\n\n' - text = text + ext + if short and short != text: + text += '\n\n' + short + if ext: + if text: + text += '\n\n' + text += ext self.setTitle(event.getEventName()) self["epg_description"].setText(text) @@ -189,7 +189,7 @@ class EventViewBase: self["key_red"].setText(_("Similar")) def openSimilarList(self): - if self.similarEPGCB is not None and len(self["key_red"].getText()): + if self.similarEPGCB is not None and self["key_red"].getText(): id = self.event and self.event.getEventId() refstr = str(self.currentService) if id is not None: diff --git a/lib/python/Screens/HarddiskSetup.py b/lib/python/Screens/HarddiskSetup.py index 19a674ec..c9f069fe 100644 --- a/lib/python/Screens/HarddiskSetup.py +++ b/lib/python/Screens/HarddiskSetup.py @@ -39,7 +39,7 @@ class HarddiskSetup(Screen): Screen.__init__(self, session) self.hdd = hdd - if type not in [self.HARDDISK_INITIALIZE, self.HARDDISK_CHECK]: + if type not in (self.HARDDISK_INITIALIZE, self.HARDDISK_CHECK): self.type = self.HARDDISK_INITIALIZE else: self.type = type diff --git a/lib/python/Screens/HelpMenu.py b/lib/python/Screens/HelpMenu.py index abef38db..74882a35 100644 --- a/lib/python/Screens/HelpMenu.py +++ b/lib/python/Screens/HelpMenu.py @@ -29,13 +29,13 @@ class HelpMenu(Screen, Rc): #arrow = self["arrowup"] print "selection:", selection - if selection and len(selection) > 1 and selection[1] == "SHIFT": - self.selectKey("SHIFT") - - if selection and len(selection) > 1 and selection[1] == "long": - self["long_key"].setText(_("Long Keypress")) - else: - self["long_key"].setText("") + longText = "" + if selection and len(selection) > 1: + if selection[1] == "SHIFT": + self.selectKey("SHIFT") + elif selection[1] == "long": + longText = _("Long Keypress") + self["long_key"].setText(longText) self.selectKey(selection[0]) #if selection is None: @@ -55,6 +55,6 @@ class HelpableScreen: self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList) def callHelpAction(self, *args): - if len(args): + if args: (actionmap, context, action) = args actionmap.action(context, action) diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py index bd9ea182..4d92bd39 100644 --- a/lib/python/Screens/InfoBar.py +++ b/lib/python/Screens/InfoBar.py @@ -148,8 +148,8 @@ class MoviePlayer(InfoBarBase, InfoBarShowHide, \ InfoBarPlugins: x.__init__(self) - self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference() - self.session.nav.playService(service) + self.lastservice = session.nav.getCurrentlyPlayingServiceReference() + session.nav.playService(service) self.returning = False self.onClose.append(self.__onClose) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 3f9fe213..e39e028d 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -369,25 +369,27 @@ class InfoBarSimpleEventView: }) def openEventView(self): - self.epglist = [ ] + epglist = [ ] + self.epglist = epglist service = self.session.nav.getCurrentService() ref = self.session.nav.getCurrentlyPlayingServiceReference() info = service.info() ptr=info.getEvent(0) if ptr: - self.epglist.append(ptr) + epglist.append(ptr) ptr=info.getEvent(1) if ptr: - self.epglist.append(ptr) - if len(self.epglist) > 0: - self.session.open(EventViewSimple, self.epglist[0], ServiceReference(ref), self.eventViewCallback) + epglist.append(ptr) + if epglist: + self.session.open(EventViewSimple, epglist[0], ServiceReference(ref), self.eventViewCallback) def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying - if len(self.epglist) > 1: - tmp = self.epglist[0] - self.epglist[0]=self.epglist[1] - self.epglist[1]=tmp - setEvent(self.epglist[0]) + epglist = self.epglist + if len(epglist) > 1: + tmp = epglist[0] + epglist[0] = epglist[1] + epglist[1] = tmp + setEvent(epglist[0]) class InfoBarEPG: """ EPG - Opens an EPG list when the showEPGList action fires """ @@ -440,7 +442,7 @@ class InfoBarEPG: def openBouquetEPG(self, bouquet, withCallback=True): services = self.getBouquetServices(bouquet) - if len(services): + if services: self.epg_bouquet = bouquet if withCallback: self.dlg_stack.append(self.session.openWithCallback(self.closed, EPGSelection, services, self.zapToService, None, self.changeBouquetCB)) @@ -455,7 +457,7 @@ class InfoBarEPG: self.bouquetSel.up() bouquet = self.bouquetSel.getCurrent() services = self.getBouquetServices(bouquet) - if len(services): + if services: self.epg_bouquet = bouquet epg.setServices(services) @@ -642,9 +644,9 @@ class InfoBarSeek: return 1 elif action[:8] == "seekdef:": key = int(action[8:]) - time = [-config.seek.selfdefined_13.value, False, config.seek.selfdefined_13.value, + time = (-config.seek.selfdefined_13.value, False, config.seek.selfdefined_13.value, -config.seek.selfdefined_46.value, False, config.seek.selfdefined_46.value, - -config.seek.selfdefined_79.value, False, config.seek.selfdefined_79.value][key-1] + -config.seek.selfdefined_79.value, False, config.seek.selfdefined_79.value)[key-1] self.screen.doSeekRelative(time * 90000) return 1 else: @@ -772,7 +774,7 @@ class InfoBarSeek: return False if not self.isSeekable(): - if state not in [self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE]: + if state not in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE): state = self.SEEK_STATE_PLAY pauseable = service.pause() @@ -885,30 +887,31 @@ class InfoBarSeek: self.setSeekState(self.makeStateSlowMotion(speed)) def seekBack(self): - if self.seekstate == self.SEEK_STATE_PLAY: + seekstate = self.seekstate + if seekstate == self.SEEK_STATE_PLAY: self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value))) - elif self.seekstate == self.SEEK_STATE_EOF: + elif seekstate == self.SEEK_STATE_EOF: self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value))) self.doSeekRelative(-6) - elif self.seekstate == self.SEEK_STATE_PAUSE: + elif seekstate == self.SEEK_STATE_PAUSE: self.doSeekRelative(-3) - elif self.isStateForward(self.seekstate): - speed = self.seekstate[1] - if self.seekstate[2]: - speed /= self.seekstate[2] + elif self.isStateForward(seekstate): + speed = seekstate[1] + if seekstate[2]: + speed /= seekstate[2] speed = self.getLower(speed, config.seek.speeds_forward.value) if speed: self.setSeekState(self.makeStateForward(speed)) else: self.setSeekState(self.SEEK_STATE_PLAY) - elif self.isStateBackward(self.seekstate): - speed = -self.seekstate[1] - if self.seekstate[2]: - speed /= self.seekstate[2] + elif self.isStateBackward(seekstate): + speed = -seekstate[1] + if seekstate[2]: + speed /= seekstate[2] speed = self.getHigher(speed, config.seek.speeds_backward.value) or config.seek.speeds_backward.value[-1] self.setSeekState(self.makeStateBackward(speed)) - elif self.isStateSlowMotion(self.seekstate): - speed = self.getHigher(self.seekstate[2], config.seek.speeds_slowmotion.value) + elif self.isStateSlowMotion(seekstate): + speed = self.getHigher(seekstate[2], config.seek.speeds_slowmotion.value) if speed: self.setSeekState(self.makeStateSlowMotion(speed)) else: @@ -994,7 +997,7 @@ class InfoBarSeek: self.eofState = 0 if not self.seekstate == self.SEEK_STATE_PAUSE: self.setSeekState(self.SEEK_STATE_EOF) - if eofstate == -1 or not seekstate in [self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE]: + if eofstate == -1 or not seekstate in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE): seekable = self.getSeek() if seekable is not None: seekable.seekTo(-1) @@ -1480,7 +1483,7 @@ class InfoBarInstantRecord: def isInstantRecordRunning(self): print "self.recording:", self.recording - if len(self.recording) > 0: + if self.recording: for x in self.recording: if x.isRunning(): return True @@ -1631,13 +1634,13 @@ class InfoBarAudioSelection: break if SystemInfo["CanDownmixAC3"]: - tlist = [(_("AC3 downmix") + " - " +[_("Off"), _("On")][config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix), - ([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), + tlist = [(_("AC3 downmix") + " - " +(_("Off"), _("On"))[config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix), + ((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist keys = [ "red", "green", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n selection += 3 else: - tlist = [([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist + tlist = [((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n selection += 2 self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys) @@ -1649,7 +1652,7 @@ class InfoBarAudioSelection: list = choicelist.list t = list[0][1] list[0][1]=(t[0], t[1], t[2], t[3], t[4], t[5], t[6], - _("AC3 downmix") + " - " +[_("On"), _("Off")][config.av.downmix_ac3.value and 1 or 0]) + _("AC3 downmix") + " - " + (_("On"), _("Off"))[config.av.downmix_ac3.value and 1 or 0]) choicelist.setList(list) if config.av.downmix_ac3.value: config.av.downmix_ac3.value = False @@ -2080,9 +2083,6 @@ class InfoBarSummary(Screen): # Reference # - def __init__(self, session, parent): - Screen.__init__(self, session, parent = parent) - class InfoBarSummarySupport: def __init__(self): pass @@ -2108,9 +2108,6 @@ class InfoBarMoviePlayerSummary(Screen): """ - def __init__(self, session, parent): - Screen.__init__(self, session) - class InfoBarMoviePlayerSummarySupport: def __init__(self): pass @@ -2211,7 +2208,7 @@ class InfoBarServiceErrorPopupSupport: else: self.last_error = error - errors = { + error = { eDVBServicePMTHandler.eventNoResources: _("No free tuner!"), eDVBServicePMTHandler.eventTuneFailed: _("Tune failed!"), eDVBServicePMTHandler.eventNoPAT: _("No data on transponder!\n(Timeout reading PAT)"), @@ -2222,9 +2219,7 @@ class InfoBarServiceErrorPopupSupport: eDVBServicePMTHandler.eventSOF: None, eDVBServicePMTHandler.eventEOF: None, eDVBServicePMTHandler.eventMisconfiguration: _("Service unavailable!\nCheck tuner configuration!"), - } - - error = errors.get(error) #this returns None when the key not exist in the dict + }.get(error) #this returns None when the key not exist in the dict if error is not None: Notifications.AddPopup(text = error, type = MessageBox.TYPE_ERROR, timeout = 5, id = "ZapError") diff --git a/lib/python/Screens/LanguageSelection.py b/lib/python/Screens/LanguageSelection.py index 94ede08c..082daa55 100644 --- a/lib/python/Screens/LanguageSelection.py +++ b/lib/python/Screens/LanguageSelection.py @@ -76,21 +76,22 @@ class LanguageSelection(Screen): print "ok" def updateList(self): - first_time = len(self.list) == 0 + first_time = not self.list - self.list = [] - if len(language.getLanguageList()) == 0: # no language available => display only english - self.list.append(LanguageEntryComponent("en", _cached("en_EN"), "en_EN")) + languageList = language.getLanguageList() + if not languageList: # no language available => display only english + list = [ LanguageEntryComponent("en", _cached("en_EN"), "en_EN") ] else: - for x in language.getLanguageList(): - self.list.append(LanguageEntryComponent(file = x[1][2].lower(), name = _cached("%s_%s" % x[1][1:3]), index = x[0])) - #self.list.sort(key=lambda x: x[1][7]) + list = [ LanguageEntryComponent(file = x[1][2].lower(), name = _cached("%s_%s" % x[1][1:3]), index = x[0]) for x in languageList] + self.list = list + + #list.sort(key=lambda x: x[1][7]) print "updateList" if first_time: - self["languages"].list = self.list + self["languages"].list = list else: - self["languages"].updateList(self.list) + self["languages"].updateList(list) print "done" def changed(self): diff --git a/lib/python/Screens/LocationBox.py b/lib/python/Screens/LocationBox.py index fa47b1f2..61d7105d 100644 --- a/lib/python/Screens/LocationBox.py +++ b/lib/python/Screens/LocationBox.py @@ -163,11 +163,11 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen): }) # Run some functions when shown - self.onShown.extend([ + self.onShown.extend(( boundFunction(self.setTitle, windowTitle), self.updateTarget, self.showHideRename, - ]) + )) self.onLayoutFinish.append(self.switchToFileListOnStart) @@ -241,7 +241,7 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen): ) def createDirCallback(self, res): - if res is not None and len(res): + if res: path = os.path.join(self["filelist"].current_directory, res) if not pathExists(path): if not createDir(path): @@ -454,7 +454,7 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen): def selectByStart(self): # Don't do anything on initial call - if not len(self.quickselect): + if not self.quickselect: return # Don't select if no dir @@ -503,16 +503,12 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen): return str(type(self)) + "(" + self.text + ")" class MovieLocationBox(LocationBox): - skinName = "LocationBox" - def __init__(self, session, text, dir, minFree = None): inhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/lib", "/proc", "/sbin", "/sys", "/usr", "/var"] LocationBox.__init__(self, session, text = text, currDir = dir, bookmarks = config.movielist.videodirs, autoAdd = True, editDir = True, inhibitDirs = inhibitDirs, minFree = minFree) + self.skinName = "LocationBox" class TimeshiftLocationBox(LocationBox): - - skinName = "LocationBox" # XXX: though we could use a custom skin or inherit the hardcoded one we stick with the original :-) - def __init__(self, session): inhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/lib", "/proc", "/sbin", "/sys", "/usr", "/var"] LocationBox.__init__( @@ -524,8 +520,9 @@ class TimeshiftLocationBox(LocationBox): autoAdd = True, editDir = True, inhibitDirs = inhibitDirs, - minFree = 1024 # XXX: the same requirement is hardcoded in servicedvb.cpp + minFree = 1024 # the same requirement is hardcoded in servicedvb.cpp ) + self.skinName = "LocationBox" def cancel(self): config.usage.timeshift_path.cancel() diff --git a/lib/python/Screens/Menu.py b/lib/python/Screens/Menu.py index 93f23dfb..5f2032f1 100644 --- a/lib/python/Screens/Menu.py +++ b/lib/python/Screens/Menu.py @@ -61,9 +61,6 @@ class MenuSummary(Screen): """ - def __init__(self, session, parent): - Screen.__init__(self, session, parent) - class Menu(Screen): ALLOW_SUSPEND = True @@ -118,7 +115,7 @@ class Menu(Screen): self.menuClosed(*res) def menuClosed(self, *res): - if len(res) and res[0]: + if res and res[0]: self.close(True) def addItem(self, destList, node): diff --git a/lib/python/Screens/MessageBox.py b/lib/python/Screens/MessageBox.py index 8a5989c7..10485680 100644 --- a/lib/python/Screens/MessageBox.py +++ b/lib/python/Screens/MessageBox.py @@ -43,7 +43,7 @@ class MessageBox(Screen): else: self.list = [ (_("no"), 1), (_("yes"), 0) ] - if len(self.list): + if self.list: self["selectedChoice"].setText(self.list[0][0]) self["list"] = MenuList(self.list) @@ -134,7 +134,7 @@ class MessageBox(Screen): if self.close_on_any_key: self.close(True) self["list"].instance.moveSelection(direction) - if len(self.list): + if self.list: self["selectedChoice"].setText(self["list"].getCurrent()[0]) self.stopTimer() diff --git a/lib/python/Screens/MovieSelection.py b/lib/python/Screens/MovieSelection.py index 5951653f..174a4f07 100644 --- a/lib/python/Screens/MovieSelection.py +++ b/lib/python/Screens/MovieSelection.py @@ -65,20 +65,20 @@ class MovieContextMenu(Screen): }) menu = [(_("delete..."), self.delete)] - - for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST): - menu.append((p.description, boundFunction(self.execPlugin, p))) - + menu.extend([(p.description, boundFunction(self.execPlugin, p)) for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST)]) + if config.movielist.moviesort.value == MovieList.SORT_ALPHANUMERIC: menu.append((_("sort by date"), boundFunction(self.sortBy, MovieList.SORT_RECORDED))) else: menu.append((_("alphabetic sort"), boundFunction(self.sortBy, MovieList.SORT_ALPHANUMERIC))) - menu.append((_("list style default"), boundFunction(self.listType, MovieList.LISTTYPE_ORIGINAL))) - menu.append((_("list style compact with description"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT_DESCRIPTION))) - menu.append((_("list style compact"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT))) - menu.append((_("list style single line"), boundFunction(self.listType, MovieList.LISTTYPE_MINIMAL))) - + menu.extend(( + (_("list style default"), boundFunction(self.listType, MovieList.LISTTYPE_ORIGINAL)), + (_("list style compact with description"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT_DESCRIPTION)), + (_("list style compact"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT)), + (_("list style single line"), boundFunction(self.listType, MovieList.LISTTYPE_MINIMAL)) + )) + if config.movielist.description.value == MovieList.SHOW_DESCRIPTION: menu.append((_("hide extended description"), boundFunction(self.showDescription, MovieList.HIDE_DESCRIPTION))) else: diff --git a/lib/python/Screens/Mute.py b/lib/python/Screens/Mute.py index f64be901..f80267ad 100644 --- a/lib/python/Screens/Mute.py +++ b/lib/python/Screens/Mute.py @@ -1,6 +1,5 @@ from Screen import Screen class Mute(Screen): - def __init__(self, session): - Screen.__init__(self, session) + pass diff --git a/lib/python/Screens/NetworkSetup.py b/lib/python/Screens/NetworkSetup.py index ea2d17e6..50f8c41b 100755 --- a/lib/python/Screens/NetworkSetup.py +++ b/lib/python/Screens/NetworkSetup.py @@ -28,8 +28,10 @@ class InterfaceList(MenuList): self.l.setItemHeight(30) def InterfaceEntryComponent(index,name,default,active ): - res = [ (index) ] - res.append(MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name)) + res = [ + (index), + MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name) + ] num_configured_if = len(iNetwork.getConfiguredAdapters()) if num_configured_if >= 2: if default is True: @@ -62,7 +64,7 @@ class NetworkAdapterSelection(Screen,HelpableScreen): self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()] - if len(self.adapters) == 0: + if not self.adapters: self.onFirstExecBegin.append(self.NetworkFallback) self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", @@ -232,17 +234,16 @@ class NameserverSetup(Screen, ConfigListScreen, HelpableScreen): def createConfig(self): self.nameservers = iNetwork.getNameserverList() - self.nameserverEntries = [] - - for nameserver in self.nameservers: - self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver))) + self.nameserverEntries = [ NoSave(ConfigIP(default=nameserver)) for nameserver in self.nameservers] def createSetup(self): self.list = [] - - for i in range(len(self.nameserverEntries)): - self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i])) - + + i = 1 + for x in self.nameserverEntries: + self.list.append(getConfigListEntry(_("Nameserver %d") % (i), x)) + i += 1 + self["config"].list = self.list self["config"].l.setList(self.list) diff --git a/lib/python/Screens/NumericalTextInputHelpDialog.py b/lib/python/Screens/NumericalTextInputHelpDialog.py index 39c644b9..e0979587 100644 --- a/lib/python/Screens/NumericalTextInputHelpDialog.py +++ b/lib/python/Screens/NumericalTextInputHelpDialog.py @@ -4,7 +4,7 @@ from Components.Label import Label class NumericalTextInputHelpDialog(Screen): def __init__(self, session, textinput): Screen.__init__(self, session) - for x in range(1, 10): + for x in (1, 2, 3, 4, 5, 6, 7, 8, 9): self["key%d" % x] = Label(text=textinput.mapping[x].encode("utf-8")) self.last_marked = 0 diff --git a/lib/python/Screens/PVRState.py b/lib/python/Screens/PVRState.py index 8b90c420..891379ca 100644 --- a/lib/python/Screens/PVRState.py +++ b/lib/python/Screens/PVRState.py @@ -8,5 +8,5 @@ class PVRState(Screen): self["state"] = Label(text="") class TimeshiftState(PVRState): - def __init__(self, session): - PVRState.__init__(self, session) + pass + diff --git a/lib/python/Screens/ParentalControlSetup.py b/lib/python/Screens/ParentalControlSetup.py index 6ae12cae..4c63dd5c 100644 --- a/lib/python/Screens/ParentalControlSetup.py +++ b/lib/python/Screens/ParentalControlSetup.py @@ -215,9 +215,7 @@ class ParentalControlEditor(Screen): if result is not None: print "result:", result self.currentLetter = result[1] - self.list = [] - for x in self.servicesList[result[1]]: - self.list.append(ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionLevel(x[0]) != -1)) + self.list = [ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionLevel(x[0]) != -1) for x in self.servicesList[result[1]]] self.servicelist.setList(self.list) else: parentalControl.save() diff --git a/lib/python/Screens/PluginBrowser.py b/lib/python/Screens/PluginBrowser.py index 0f6ee746..cd17e2e0 100644 --- a/lib/python/Screens/PluginBrowser.py +++ b/lib/python/Screens/PluginBrowser.py @@ -51,11 +51,9 @@ class PluginBrowser(Screen): plugin(session=self.session) def updateList(self): - self.list = [ ] self.pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU) - for plugin in self.pluginlist: - self.list.append(PluginEntryComponent(plugin)) - + self.list = [PluginEntryComponent(plugin) for plugin in self.pluginlist] + self["list"].l.setList(self.list) def delete(self): @@ -187,7 +185,7 @@ class PluginDownloadBrowser(Screen): self.pluginlist.append(plugin) def updateList(self): - self.list = [] + list = [] expandableIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/expandable-plugins.png")) expandedIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/expanded-plugins.png")) verticallineIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/verticalline-plugins.png")) @@ -204,10 +202,10 @@ class PluginDownloadBrowser(Screen): for x in self.plugins.keys(): if x in self.expanded: - self.list.append(PluginCategoryComponent(x, expandedIcon)) - for plugin in self.plugins[x]: - self.list.append(PluginDownloadComponent(plugin[0], plugin[1])) + list.append(PluginCategoryComponent(x, expandedIcon)) + list.extend([PluginDownloadComponent(plugin[0], plugin[1]) for plugin in self.plugins[x]]) else: - self.list.append(PluginCategoryComponent(x, expandableIcon)) - self["list"].l.setList(self.list) + list.append(PluginCategoryComponent(x, expandableIcon)) + self.list = list + self["list"].l.setList(list) diff --git a/lib/python/Screens/Rc.py b/lib/python/Screens/Rc.py index 3a7c78b3..27ba1abd 100644 --- a/lib/python/Screens/Rc.py +++ b/lib/python/Screens/Rc.py @@ -81,4 +81,3 @@ class Rc: for selectPic in self.selectpics: for pic in selectPic[1]: self[pic].hide() - \ No newline at end of file diff --git a/lib/python/Screens/Satconfig.py b/lib/python/Screens/Satconfig.py index da6fcc12..8b5089a3 100644 --- a/lib/python/Screens/Satconfig.py +++ b/lib/python/Screens/Satconfig.py @@ -21,7 +21,7 @@ class NimSetup(Screen, ConfigListScreen): else: list.append(getConfigListEntry(_("Port A"), nim.diseqcA)) - if mode in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]: + if mode in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"): list.append(getConfigListEntry(_("Port B"), nim.diseqcB)) if mode == "diseqc_a_b_c_d": list.append(getConfigListEntry(_("Port C"), nim.diseqcC)) @@ -99,7 +99,7 @@ class NimSetup(Screen, ConfigListScreen): if self.nimConfig.configMode.value == "simple": #simple setup self.diseqcModeEntry = getConfigListEntry(_("Mode"), self.nimConfig.diseqcMode) self.list.append(self.diseqcModeEntry) - if self.nimConfig.diseqcMode.value in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]: + if self.nimConfig.diseqcMode.value in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"): self.createSimpleSetup(self.list, self.nimConfig.diseqcMode.value) if self.nimConfig.diseqcMode.value == "positioner": self.createPositionerSetup(self.list) @@ -204,7 +204,7 @@ class NimSetup(Screen, ConfigListScreen): if self.have_advanced and self.nim.config_mode == "advanced": self.fillAdvancedList() for x in self.list: - if x in [self.turnFastEpochBegin, self.turnFastEpochEnd]: + if x in (self.turnFastEpochBegin, self.turnFastEpochEnd): # workaround for storing only hour*3600+min*60 value in configfile # not really needed.. just for cosmetics.. tm = localtime(x[1].value) @@ -453,7 +453,7 @@ class NimSelection(Screen): text = nimConfig.configMode.value if self.showNim(x): if x.isCompatible("DVB-S"): - if nimConfig.configMode.value in ["loopthrough", "equal", "satposdepends"]: + if nimConfig.configMode.value in ("loopthrough", "equal", "satposdepends"): text = { "loopthrough": _("loopthrough to"), "equal": _("equal to"), "satposdepends": _("second cable of motorized LNB") } [nimConfig.configMode.value] @@ -461,11 +461,11 @@ class NimSelection(Screen): elif nimConfig.configMode.value == "nothing": text = _("nothing connected") elif nimConfig.configMode.value == "simple": - if nimConfig.diseqcMode.value in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]: + if nimConfig.diseqcMode.value in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"): text = _("Sats") + ": " if nimConfig.diseqcA.orbital_position != 3601: text += nimmanager.getSatName(int(nimConfig.diseqcA.value)) - if nimConfig.diseqcMode.value in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]: + if nimConfig.diseqcMode.value in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"): if nimConfig.diseqcB.orbital_position != 3601: text += "," + nimmanager.getSatName(int(nimConfig.diseqcB.value)) if nimConfig.diseqcMode.value == "diseqc_a_b_c_d": @@ -491,4 +491,4 @@ class NimSelection(Screen): self.list.append((slotid, x.friendly_full_description, text, x)) self["nimlist"].setList(self.list) - self["nimlist"].updateList(self.list) \ No newline at end of file + self["nimlist"].updateList(self.list) diff --git a/lib/python/Screens/ServiceInfo.py b/lib/python/Screens/ServiceInfo.py index df8af4b4..fa2f4474 100644 --- a/lib/python/Screens/ServiceInfo.py +++ b/lib/python/Screens/ServiceInfo.py @@ -19,11 +19,6 @@ def to_unsigned(x): return x & 0xFFFFFFFF def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4): - res = [ ] - - #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags; - res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, "")) - res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a)) print "b:", b if not isinstance(b, str): if valueType == TYPE_VALUE_HEX: @@ -34,10 +29,13 @@ def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4): b = ("0x%0" + str(param) + "x (%dd)") % (to_unsigned(b), b) else: b = str(b) - - res.append((eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b)) - return res + return [ + #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags; + (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""), + (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a), + (eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b) + ] class ServiceInfoList(HTMLComponent, GUIComponent): def __init__(self, source): @@ -151,9 +149,7 @@ class ServiceInfo(Screen): "transmission_mode": _("Transmission Mode"), "guard_interval" : _("Guard Interval"), "hierarchy_information": _("Hierarchy Information") } - Labels = [ ] - for i in tp_info.keys(): - Labels.append( (conv[i], tp_info[i], TYPE_VALUE_DEC) ) + Labels = [(conv[i], tp_info[i], TYPE_VALUE_DEC) for i in tp_info.keys()] self.fillList(Labels) def pids(self): @@ -186,7 +182,7 @@ class ServiceInfo(Screen): if frontendDataOrg and len(frontendDataOrg): frontendData = ConvertToHumanReadable(frontendDataOrg) if frontendDataOrg["tuner_type"] == "DVB-S": - return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT), + return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT), ("Type", frontendData["system"], TYPE_TEXT), ("Modulation", frontendData["modulation"], TYPE_TEXT), ("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC), @@ -198,7 +194,7 @@ class ServiceInfo(Screen): ("Pilot", frontendData.get("pilot", None), TYPE_TEXT), ("Rolloff", frontendData.get("rolloff", None), TYPE_TEXT)) elif frontendDataOrg["tuner_type"] == "DVB-C": - return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT), + return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT), ("Type", frontendData["tuner_type"], TYPE_TEXT), ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC), ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC), @@ -206,7 +202,7 @@ class ServiceInfo(Screen): ("Inversion", frontendData["inversion"], TYPE_TEXT), ("FEC inner", frontendData["fec_inner"], TYPE_TEXT)) elif frontendDataOrg["tuner_type"] == "DVB-T": - return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT), + return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT), ("Type", frontendData["tuner_type"], TYPE_TEXT), ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC), ("Inversion", frontendData["inversion"], TYPE_TEXT), diff --git a/lib/python/Screens/Setup.py b/lib/python/Screens/Setup.py index 1d035b8a..7226562f 100644 --- a/lib/python/Screens/Setup.py +++ b/lib/python/Screens/Setup.py @@ -21,10 +21,10 @@ setupfile.close() class SetupError(Exception): def __init__(self, message): - self.message = message + self.msg = message def __str__(self): - return self.message + return self.msg class SetupSummary(Screen): skin = """ @@ -35,11 +35,10 @@ class SetupSummary(Screen): """ def __init__(self, session, parent): - Screen.__init__(self, session) + Screen.__init__(self, session, parent = parent) self["SetupTitle"] = Label(_(parent.setup_title)) self["SetupEntry"] = Label("") self["SetupValue"] = Label("") - self.parent = parent self.onShow.append(self.addWatcher) self.onHide.append(self.removeWatcher) diff --git a/lib/python/Screens/Standby.py b/lib/python/Screens/Standby.py index d09f28af..afea94b9 100644 --- a/lib/python/Screens/Standby.py +++ b/lib/python/Screens/Standby.py @@ -87,9 +87,6 @@ class StandbySummary(Screen): """ - def __init__(self, session, parent): - Screen.__init__(self, session) - from enigma import quitMainloop, iRecordableService from Screens.MessageBox import MessageBox from time import time @@ -100,7 +97,7 @@ inTryQuitMainloop = False class TryQuitMainloop(MessageBox): def __init__(self, session, retvalue=1, timeout=-1, default_yes = True): self.retval=retvalue - recordings = len(session.nav.getRecordings()) + recordings = session.nav.getRecordings() jobs = len(job_manager.getPendingJobs()) self.connected = False reason = "" @@ -137,7 +134,7 @@ class TryQuitMainloop(MessageBox): def getRecordEvent(self, recservice, event): if event == iRecordableService.evEnd: recordings = self.session.nav.getRecordings() - if not len(recordings): # no more recordings exist + if not recordings: # no more recordings exist rec_time = self.session.nav.RecordTimer.getNextRecordingTime() if rec_time > 0 and (rec_time - time()) < 360: self.initTimeout(360) # wait for next starting timer diff --git a/lib/python/Screens/SubservicesQuickzap.py b/lib/python/Screens/SubservicesQuickzap.py index 24af517d..3bcc3c46 100644 --- a/lib/python/Screens/SubservicesQuickzap.py +++ b/lib/python/Screens/SubservicesQuickzap.py @@ -9,10 +9,17 @@ from Components.ServiceEventTracker import InfoBarBase from enigma import eTimer -class SubservicesQuickzap(InfoBarBase, InfoBarShowHide, InfoBarMenu, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection, Screen): +class SubservicesQuickzap(InfoBarBase, InfoBarShowHide, InfoBarMenu, \ + InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, \ + InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, \ + InfoBarAudioSelection, Screen): + def __init__(self, session, subservices): Screen.__init__(self, session) - for x in [InfoBarBase, InfoBarShowHide, InfoBarMenu, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarSubtitleSupport, InfoBarExtensions, InfoBarAudioSelection]: + for x in InfoBarBase, InfoBarShowHide, InfoBarMenu, \ + InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, \ + InfoBarTimeshiftState, InfoBarSubtitleSupport, \ + InfoBarExtensions, InfoBarAudioSelection: x.__init__(self) self.restoreService = self.session.nav.getCurrentlyPlayingServiceReference() @@ -97,12 +104,15 @@ class SubservicesQuickzap(InfoBarBase, InfoBarShowHide, InfoBarMenu, InfoBarInst def showSelection(self): self.updateSubservices() tlist = [] - if self.n is not None: - for x in range(self.n): - i = self.subservices.getSubservice(x) - tlist.append((i.getName(), x)) + n = self.n or 0 + if n: + idx = 0 + while idx < n: + i = self.subservices.getSubservice(idx) + tlist.append((i.getName(), idx)) + idx += 1 - keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * self.n + keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = self.currentlyPlayingSubservice, keys = keys) def subserviceSelected(self, service): diff --git a/lib/python/Screens/SubtitleDisplay.py b/lib/python/Screens/SubtitleDisplay.py index 80d3bd26..13ece59a 100644 --- a/lib/python/Screens/SubtitleDisplay.py +++ b/lib/python/Screens/SubtitleDisplay.py @@ -1,7 +1,6 @@ from Screens.Screen import Screen class SubtitleDisplay(Screen): - def __init__(self, session): - Screen.__init__(self, session) - + pass + # not really much to do... diff --git a/lib/python/Screens/Subtitles.py b/lib/python/Screens/Subtitles.py index e6378619..54bc7a5b 100644 --- a/lib/python/Screens/Subtitles.py +++ b/lib/python/Screens/Subtitles.py @@ -30,10 +30,11 @@ class Subtitles(Screen, ConfigListScreen): self.__selected_subtitle = None def fillList(self): - del self.list[:] - print "self.list", self.list + list = self.list + del list[:] + print "self.list", list if self.subtitlesEnabled(): - self.list.append(getConfigListEntry(_("Disable Subtitles"), ConfigNothing(), None)) + list.append(getConfigListEntry(_("Disable Subtitles"), ConfigNothing(), None)) sel = self.infobar.selected_subtitle else: sel = None @@ -44,29 +45,29 @@ class Subtitles(Screen, ConfigListScreen): text = _("Enable") if x[0] == 0: if LanguageCodes.has_key(x[4]): - self.list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x)) + list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x)) else: - self.list.append(getConfigListEntry(text+" DVB "+x[4], ConfigNothing(), x)) + list.append(getConfigListEntry(text+" DVB "+x[4], ConfigNothing(), x)) elif x[0] == 1: if x[4] == 'und': #undefined - self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2]), ConfigNothing(), x)) + list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2]), ConfigNothing(), x)) else: if LanguageCodes.has_key(x[4]): - self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+LanguageCodes[x[4]][0], ConfigNothing(), x)) + list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+LanguageCodes[x[4]][0], ConfigNothing(), x)) else: - self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+x[4], ConfigNothing(), x)) + list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+x[4], ConfigNothing(), x)) elif x[0] == 2: - types = [" UTF-8 text "," SSA / AAS "," .SRT file "] + types = (" UTF-8 text "," SSA / AAS "," .SRT file ") if x[4] == 'und': #undefined - self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d" % x[1], ConfigNothing(), x)) + list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d" % x[1], ConfigNothing(), x)) else: if LanguageCodes.has_key(x[4]): - self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles") + ' ' + LanguageCodes[x[4]][0], ConfigNothing(), x)) + list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles") + ' ' + LanguageCodes[x[4]][0], ConfigNothing(), x)) else: - self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d " % x[1] +x[4], ConfigNothing(), x)) + list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d " % x[1] +x[4], ConfigNothing(), x)) # return _("Disable subtitles") - self["config"].list = self.list - self["config"].l.setList(self.list) + self["config"].list = list + self["config"].l.setList(list) def __updatedInfo(self): self.fillList() @@ -95,7 +96,7 @@ class Subtitles(Screen, ConfigListScreen): ConfigListScreen.keyRight(self) def ok(self): - if len(self.list): + if self.list: cur = self["config"].getCurrent() self.enableSubtitle(cur[2]) self.close(1) diff --git a/lib/python/Screens/TaskView.py b/lib/python/Screens/TaskView.py index 69604279..1453c05f 100644 --- a/lib/python/Screens/TaskView.py +++ b/lib/python/Screens/TaskView.py @@ -80,7 +80,7 @@ class JobView(InfoBarNotifications, Screen, ConfigListScreen): else: self["job_task"].text = "" self["summary_job_task"].text = j.getStatustext() - if j.status in [j.FINISHED, j.FAILED]: + if j.status in (j.FINISHED, j.FAILED): self.performAfterEvent() self["backgroundable"].boolean = False if j.status == j.FINISHED: @@ -94,11 +94,11 @@ class JobView(InfoBarNotifications, Screen, ConfigListScreen): self.close(True) def ok(self): - if self.job.status in [self.job.FINISHED, self.job.FAILED]: + if self.job.status in (self.job.FINISHED, self.job.FAILED): self.close(False) def abort(self): - if self.job.status in [self.job.FINISHED, self.job.FAILED]: + if self.job.status in (self.job.FINISHED, self.job.FAILED): self.close(False) if self["cancelable"].boolean == True: self.job.cancel() diff --git a/lib/python/Screens/TimeDateInput.py b/lib/python/Screens/TimeDateInput.py index 7f940909..56ccae90 100644 --- a/lib/python/Screens/TimeDateInput.py +++ b/lib/python/Screens/TimeDateInput.py @@ -42,9 +42,10 @@ class TimeDateInput(Screen, ConfigListScreen): self.timeinput_time = conf_time def createSetup(self, configlist): - self.list = [] - self.list.append(getConfigListEntry(_("Date"), self.timeinput_date)) - self.list.append(getConfigListEntry(_("Time"), self.timeinput_time)) + self.list = [ + getConfigListEntry(_("Date"), self.timeinput_date), + getConfigListEntry(_("Time"), self.timeinput_time) + ] configlist.list = self.list configlist.l.setList(self.list) diff --git a/lib/python/Screens/TimerEdit.py b/lib/python/Screens/TimerEdit.py index 6499ef50..caaf8c95 100644 --- a/lib/python/Screens/TimerEdit.py +++ b/lib/python/Screens/TimerEdit.py @@ -171,14 +171,11 @@ class TimerEditList(Screen): self.key_blue_choice = self.EMPTY def fillTimerList(self): - del self.list[:] - - for timer in self.session.nav.RecordTimer.timer_list: - self.list.append((timer, False)) - - for timer in self.session.nav.RecordTimer.processed_timers: - self.list.append((timer, True)) - self.list.sort(cmp = lambda x, y: x[0].begin < y[0].begin) + list = self.list + del list[:] + list.extend([(timer, False) for timer in self.session.nav.RecordTimer.timer_list]) + list.extend([(timer, True) for timer in self.session.nav.RecordTimer.processed_timers]) + list.sort(cmp = lambda x, y: x[0].begin < y[0].begin) def showLog(self): cur=self["timerlist"].getCurrent() diff --git a/lib/python/Screens/TimerEntry.py b/lib/python/Screens/TimerEntry.py index 92a16af8..73b2175b 100644 --- a/lib/python/Screens/TimerEntry.py +++ b/lib/python/Screens/TimerEntry.py @@ -57,12 +57,12 @@ class TimerEntry(Screen, ConfigListScreen): AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] - weekday_table = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] + weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 - for x in range(0,7): + for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" @@ -74,7 +74,7 @@ class TimerEntry(Screen, ConfigListScreen): flags = self.timer.repeated repeated = "user" count = 0 - for x in range(0, 7): + for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x @@ -98,7 +98,7 @@ class TimerEntry(Screen, ConfigListScreen): self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] - self.timerentry_tagsset = ConfigSelection(choices = [len(self.timerentry_tags) == 0 and "None" or " ".join(self.timerentry_tags)]) + self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) @@ -117,7 +117,7 @@ class TimerEntry(Screen, ConfigListScreen): self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() - for x in range(0,7): + for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here @@ -197,14 +197,14 @@ class TimerEntry(Screen, ConfigListScreen): self.createSetup("config") def keyLeft(self): - if self["config"].getCurrent() in [self.channelEntry, self.tagsSet]: + if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): - if self["config"].getCurrent() in [self.channelEntry, self.tagsSet]: + if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyRight(self) @@ -236,7 +236,7 @@ class TimerEntry(Screen, ConfigListScreen): self.keyGo() def finishedChannelSelection(self, *args): - if len(args): + if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) @@ -281,18 +281,18 @@ class TimerEntry(Screen, ConfigListScreen): self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": - for x in range(0,7): + for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": - for x in range(0,5): + for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": - for x in range(0,7): + for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) @@ -367,7 +367,7 @@ class TimerEntry(Screen, ConfigListScreen): def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret - self.timerentry_tagsset.setChoices([len(ret) == 0 and "None" or " ".join(ret)]) + self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet) class TimerLog(Screen): @@ -410,9 +410,7 @@ class TimerLog(Screen): self.updateText() def fillLogList(self): - self.list = [ ] - for x in self.log_entries: - self.list.append((str(strftime("%Y-%m-%d %H-%M", localtime(x[0])) + " - " + x[2]), x)) + self.list = [(str(strftime("%Y-%m-%d %H-%M", localtime(x[0])) + " - " + x[2]), x) for x in self.log_entries] def clearLog(self): self.log_entries = [] @@ -444,7 +442,7 @@ class TimerLog(Screen): self.updateText() def updateText(self): - if len(self.list) > 0: + if self.list: self["logentry"].setText(str(self["loglist"].getCurrent()[1][2])) else: self["logentry"].setText("") diff --git a/lib/python/Screens/TimerSelection.py b/lib/python/Screens/TimerSelection.py index 7a1d9ecd..a97c7ba3 100644 --- a/lib/python/Screens/TimerSelection.py +++ b/lib/python/Screens/TimerSelection.py @@ -22,4 +22,3 @@ class TimerSelection(Screen): def selected(self): self.close(self["timerlist"].getCurrentIndex()) - \ No newline at end of file diff --git a/lib/python/Screens/VirtualKeyBoard.py b/lib/python/Screens/VirtualKeyBoard.py index 5dc1a090..9b676a5f 100755 --- a/lib/python/Screens/VirtualKeyBoard.py +++ b/lib/python/Screens/VirtualKeyBoard.py @@ -1,289 +1,291 @@ -# -*- coding: iso-8859-1 -*- -from Components.Language import language -from Components.ActionMap import ActionMap -from Components.Label import Label -from Components.Pixmap import Pixmap -from Components.MenuList import MenuList -from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest -from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER -from Screen import Screen -from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE -from Tools.LoadPixmap import LoadPixmap - -class VirtualKeyBoardList(MenuList): - def __init__(self, list, enableWrapAround=False): - MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent) - self.l.setFont(0, gFont("Regular", 22)) - self.l.setItemHeight(45) - -def VirtualKeyBoardEntryComponent(keys, selectedKey,shiftMode=False): - key_backspace = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_backspace.png")) - key_bg = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_bg.png")) - key_clr = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_clr.png")) - key_esc = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_esc.png")) - key_ok = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_ok.png")) - key_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_sel.png")) - key_shift = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift.png")) - key_shift_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift_sel.png")) - key_space = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_space.png")) - - res = [ (keys) ] - - x = 0 - count = 0 - if shiftMode: - shiftkey_png = key_shift_sel - else: - shiftkey_png = key_shift - for key in keys: - if key == "EXIT": - res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_esc)) - elif key == "BACKSPACE": - res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_backspace)) - elif key == "CLEAR": - res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_clr)) - elif key == "SHIFT": - res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=shiftkey_png)) - elif key == "SPACE": - res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_space)) - elif key == "OK": - res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_ok)) - #elif key == "<-": - # res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_left)) - #elif key == "->": - # res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_right)) - - else: - res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_bg)) - res.append(MultiContentEntryText(pos=(x, 0), size=(45, 45), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER)) - - if selectedKey == count: - res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_sel)) - - x += 45 - count += 1 - - return res - - -class VirtualKeyBoard(Screen): - - def __init__(self, session, title="", text=""): - Screen.__init__(self, session) - self.keys_list = [] - self.shiftkeys_list = [] - self.lang = language.getLanguage() - if self.lang == 'de_DE': - self.keys_list = [ - [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"], - [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ü", u"+"], - [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"], - [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"], - [u"SHIFT", u"SPACE", u"@", u"ß", u"OK"]] - - self.shiftkeys_list = [ - [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"], - [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ü", u"*"], - [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"], - [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"], - [u"SHIFT", u"SPACE", u"?", u"\\", u"OK"]] - - elif self.lang == 'es_ES': - #still missing keys (u"ùÙ") - self.keys_list = [ - [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"], - [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"], - [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ó", u"á", u"#"], - [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"], - [u"SHIFT", u"SPACE", u"@", u"£", u"à", u"é", u"è", u"í", u"ì", u"ñ", u"ò", u"OK"]] - - self.shiftkeys_list = [ - [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"], - [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ú", u"*"], - [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ó", u"Á", u"'"], - [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"], - [u"SHIFT", u"SPACE", u"?", u"\\", u"À", u"É", u"È", u"Í", u"Ì", u"Ñ", u"Ò", u"OK"]] - - elif self.lang in ['sv_SE', 'fi_FI']: - self.keys_list = [ - [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"], - [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"é", u"+"], - [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"], - [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"], - [u"SHIFT", u"SPACE", u"@", u"ß", u"å", u"OK"]] - - self.shiftkeys_list = [ - [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"], - [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"É", u"*"], - [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"], - [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"], - - [u"SHIFT", u"SPACE", u"?", u"\\", u"Å", u"OK"]] - else: - self.keys_list = [ - [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"], - [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"+", u"@"], - [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"#", u"\\"], - [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"], - [u"SHIFT", u"SPACE", u"OK"]] - - self.shiftkeys_list = [ - [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"], - [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"*"], - [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"'", u"?"], - [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"], - [u"SHIFT", u"SPACE", u"OK"]] - - self.shiftMode = False - self.text = text - self.selectedKey = 0 - - self["header"] = Label(title) - self["text"] = Label(self.text) - self["list"] = VirtualKeyBoardList([]) - - self["actions"] = ActionMap(["OkCancelActions", "WizardActions", "ColorActions"], - { - "ok": self.okClicked, - "cancel": self.exit, - "left": self.left, - "right": self.right, - "up": self.up, - "down": self.down, - "red": self.backClicked, - "green": self.ok - }, -2) - - self.onLayoutFinish.append(self.buildVirtualKeyBoard) - - def buildVirtualKeyBoard(self, selectedKey=0): - list = [] - - if self.shiftMode: - self.k_list = self.shiftkeys_list - for keys in self.k_list: - if selectedKey < 12 and selectedKey > -1: - list.append(VirtualKeyBoardEntryComponent(keys, selectedKey,True)) - else: - list.append(VirtualKeyBoardEntryComponent(keys, -1,True)) - selectedKey -= 12 - else: - self.k_list = self.keys_list - for keys in self.k_list: - if selectedKey < 12 and selectedKey > -1: - list.append(VirtualKeyBoardEntryComponent(keys, selectedKey)) - else: - list.append(VirtualKeyBoardEntryComponent(keys, -1)) - selectedKey -= 12 - - self["list"].setList(list) - - - def backClicked(self): - self.text = self["text"].getText()[:-1] - self["text"].setText(self.text) - - def okClicked(self): - if self.shiftMode: - list = self.shiftkeys_list - else: - list = self.keys_list - - selectedKey = self.selectedKey - - for x in list: - if selectedKey < 12: - text = x[selectedKey] - break - else: - selectedKey -= 12 - - text = text.encode("utf-8") - - if text == "EXIT": - self.close(None) - - elif text == "BACKSPACE": - self.text = self["text"].getText()[:-1] - self["text"].setText(self.text) - - elif text == "CLEAR": - self.text = "" - self["text"].setText(self.text) - - elif text == "SHIFT": - if self.shiftMode: - self.shiftMode = False - else: - self.shiftMode = True - - self.buildVirtualKeyBoard(self.selectedKey) - - elif text == "SPACE": - self.text += " " - self["text"].setText(self.text) - - elif text == "OK": - self.close(self["text"].getText()) - - else: - self.text = self["text"].getText() - self.text += text - self["text"].setText(self.text) - - def ok(self): - self.close(self["text"].getText()) - - def exit(self): - self.close(None) - - def left(self): - self.selectedKey -= 1 - - if self.selectedKey == -1: - self.selectedKey = 11 - elif self.selectedKey == 11: - self.selectedKey = 23 - elif self.selectedKey == 23: - self.selectedKey = 35 - elif self.selectedKey == 35: - self.selectedKey = 47 - elif self.selectedKey == 47: - self.selectedKey = 59 - - self.showActiveKey() - - def right(self): - self.selectedKey += 1 - - if self.selectedKey == 12: - self.selectedKey = 0 - elif self.selectedKey == 24: - self.selectedKey = 12 - elif self.selectedKey == 36: - self.selectedKey = 24 - elif self.selectedKey == 48: - self.selectedKey = 36 - elif self.selectedKey == 60: - self.selectedKey = 48 - - self.showActiveKey() - - def up(self): - self.selectedKey -= 12 - - if self.selectedKey < 0: - self.selectedKey += 60 - - self.showActiveKey() - - def down(self): - self.selectedKey += 12 - - if self.selectedKey > 59: - self.selectedKey -= 60 - - self.showActiveKey() - - def showActiveKey(self): - self.buildVirtualKeyBoard(self.selectedKey) +# -*- coding: iso-8859-1 -*- +from Components.Language import language +from Components.ActionMap import ActionMap +from Components.Label import Label +from Components.Pixmap import Pixmap +from Components.MenuList import MenuList +from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest +from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER +from Screen import Screen +from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE +from Tools.LoadPixmap import LoadPixmap + +class VirtualKeyBoardList(MenuList): + def __init__(self, list, enableWrapAround=False): + MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent) + self.l.setFont(0, gFont("Regular", 22)) + self.l.setItemHeight(45) + +def VirtualKeyBoardEntryComponent(keys, selectedKey,shiftMode=False): + key_backspace = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_backspace.png")) + key_bg = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_bg.png")) + key_clr = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_clr.png")) + key_esc = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_esc.png")) + key_ok = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_ok.png")) + key_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_sel.png")) + key_shift = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift.png")) + key_shift_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift_sel.png")) + key_space = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_space.png")) + + res = [ (keys) ] + + x = 0 + count = 0 + if shiftMode: + shiftkey_png = key_shift_sel + else: + shiftkey_png = key_shift + for key in keys: + if key == "EXIT": + res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_esc)) + elif key == "BACKSPACE": + res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_backspace)) + elif key == "CLEAR": + res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_clr)) + elif key == "SHIFT": + res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=shiftkey_png)) + elif key == "SPACE": + res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_space)) + elif key == "OK": + res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_ok)) + #elif key == "<-": + # res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_left)) + #elif key == "->": + # res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_right)) + + else: + res.extend(( + MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_bg), + MultiContentEntryText(pos=(x, 0), size=(45, 45), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER) + )) + + if selectedKey == count: + res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_sel)) + + x += 45 + count += 1 + + return res + + +class VirtualKeyBoard(Screen): + + def __init__(self, session, title="", text=""): + Screen.__init__(self, session) + self.keys_list = [] + self.shiftkeys_list = [] + self.lang = language.getLanguage() + if self.lang == 'de_DE': + self.keys_list = [ + [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"], + [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ü", u"+"], + [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"], + [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"], + [u"SHIFT", u"SPACE", u"@", u"ß", u"OK"]] + + self.shiftkeys_list = [ + [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"], + [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ü", u"*"], + [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"], + [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"], + [u"SHIFT", u"SPACE", u"?", u"\\", u"OK"]] + + elif self.lang == 'es_ES': + #still missing keys (u"ùÙ") + self.keys_list = [ + [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"], + [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"], + [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ó", u"á", u"#"], + [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"], + [u"SHIFT", u"SPACE", u"@", u"£", u"à", u"é", u"è", u"í", u"ì", u"ñ", u"ò", u"OK"]] + + self.shiftkeys_list = [ + [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"], + [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ú", u"*"], + [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ó", u"Á", u"'"], + [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"], + [u"SHIFT", u"SPACE", u"?", u"\\", u"À", u"É", u"È", u"Í", u"Ì", u"Ñ", u"Ò", u"OK"]] + + elif self.lang in ('sv_SE', 'fi_FI'): + self.keys_list = [ + [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"], + [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"é", u"+"], + [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"], + [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"], + [u"SHIFT", u"SPACE", u"@", u"ß", u"å", u"OK"]] + + self.shiftkeys_list = [ + [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"], + [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"É", u"*"], + [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"], + [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"], + + [u"SHIFT", u"SPACE", u"?", u"\\", u"Å", u"OK"]] + else: + self.keys_list = [ + [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"], + [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"+", u"@"], + [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"#", u"\\"], + [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"], + [u"SHIFT", u"SPACE", u"OK"]] + + self.shiftkeys_list = [ + [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"], + [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"*"], + [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"'", u"?"], + [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"], + [u"SHIFT", u"SPACE", u"OK"]] + + self.shiftMode = False + self.text = text + self.selectedKey = 0 + + self["header"] = Label(title) + self["text"] = Label(self.text) + self["list"] = VirtualKeyBoardList([]) + + self["actions"] = ActionMap(["OkCancelActions", "WizardActions", "ColorActions"], + { + "ok": self.okClicked, + "cancel": self.exit, + "left": self.left, + "right": self.right, + "up": self.up, + "down": self.down, + "red": self.backClicked, + "green": self.ok + }, -2) + + self.onLayoutFinish.append(self.buildVirtualKeyBoard) + + def buildVirtualKeyBoard(self, selectedKey=0): + list = [] + + if self.shiftMode: + self.k_list = self.shiftkeys_list + for keys in self.k_list: + if selectedKey < 12 and selectedKey > -1: + list.append(VirtualKeyBoardEntryComponent(keys, selectedKey,True)) + else: + list.append(VirtualKeyBoardEntryComponent(keys, -1,True)) + selectedKey -= 12 + else: + self.k_list = self.keys_list + for keys in self.k_list: + if selectedKey < 12 and selectedKey > -1: + list.append(VirtualKeyBoardEntryComponent(keys, selectedKey)) + else: + list.append(VirtualKeyBoardEntryComponent(keys, -1)) + selectedKey -= 12 + + self["list"].setList(list) + + + def backClicked(self): + self.text = self["text"].getText()[:-1] + self["text"].setText(self.text) + + def okClicked(self): + if self.shiftMode: + list = self.shiftkeys_list + else: + list = self.keys_list + + selectedKey = self.selectedKey + + for x in list: + if selectedKey < 12: + text = x[selectedKey] + break + else: + selectedKey -= 12 + + text = text.encode("utf-8") + + if text == "EXIT": + self.close(None) + + elif text == "BACKSPACE": + self.text = self["text"].getText()[:-1] + self["text"].setText(self.text) + + elif text == "CLEAR": + self.text = "" + self["text"].setText(self.text) + + elif text == "SHIFT": + if self.shiftMode: + self.shiftMode = False + else: + self.shiftMode = True + + self.buildVirtualKeyBoard(self.selectedKey) + + elif text == "SPACE": + self.text += " " + self["text"].setText(self.text) + + elif text == "OK": + self.close(self["text"].getText()) + + else: + self.text = self["text"].getText() + self.text += text + self["text"].setText(self.text) + + def ok(self): + self.close(self["text"].getText()) + + def exit(self): + self.close(None) + + def left(self): + self.selectedKey -= 1 + + if self.selectedKey == -1: + self.selectedKey = 11 + elif self.selectedKey == 11: + self.selectedKey = 23 + elif self.selectedKey == 23: + self.selectedKey = 35 + elif self.selectedKey == 35: + self.selectedKey = 47 + elif self.selectedKey == 47: + self.selectedKey = 59 + + self.showActiveKey() + + def right(self): + self.selectedKey += 1 + + if self.selectedKey == 12: + self.selectedKey = 0 + elif self.selectedKey == 24: + self.selectedKey = 12 + elif self.selectedKey == 36: + self.selectedKey = 24 + elif self.selectedKey == 48: + self.selectedKey = 36 + elif self.selectedKey == 60: + self.selectedKey = 48 + + self.showActiveKey() + + def up(self): + self.selectedKey -= 12 + + if self.selectedKey < 0: + self.selectedKey += 60 + + self.showActiveKey() + + def down(self): + self.selectedKey += 12 + + if self.selectedKey > 59: + self.selectedKey -= 60 + + self.showActiveKey() + + def showActiveKey(self): + self.buildVirtualKeyBoard(self.selectedKey) diff --git a/lib/python/Screens/Wizard.py b/lib/python/Screens/Wizard.py index 7d454f43..555110a4 100755 --- a/lib/python/Screens/Wizard.py +++ b/lib/python/Screens/Wizard.py @@ -604,10 +604,7 @@ class WizardManager: self.wizards.append((wizard, precondition, priority)) def getWizards(self): - list = [] - for x in self.wizards: - if x[1] == 1: # precondition - list.append((x[2], x[0])) - return list + # x[1] is precondition + return [(x[2], x[0]) for x in self.wizards if x[1] == 1] wizardManager = WizardManager() diff --git a/lib/python/Screens/WizardLanguage.py b/lib/python/Screens/WizardLanguage.py index ec9758d2..91fc80db 100644 --- a/lib/python/Screens/WizardLanguage.py +++ b/lib/python/Screens/WizardLanguage.py @@ -31,7 +31,3 @@ class WizardLanguage(Wizard): self.updateText(firstset = True) self.updateValues() self.updateLanguageDescription() - - - - \ No newline at end of file diff --git a/lib/python/Tools/NumericalTextInput.py b/lib/python/Tools/NumericalTextInput.py index c5576405..df6a5ea8 100644 --- a/lib/python/Tools/NumericalTextInput.py +++ b/lib/python/Tools/NumericalTextInput.py @@ -52,7 +52,7 @@ class NumericalTextInput: self.mapping.append (u"pqrs7PQRS") # 7 self.mapping.append (u"tuvúù8TUVÚÙ") # 8 self.mapping.append (u"wxyz9WXYZ") # 9 - if self.lang in ['sv_SE', 'fi_FI']: + if self.lang in ('sv_SE', 'fi_FI'): self.mapping.append (u".,?'+\"0-()@/:_$!") # 0 self.mapping.append (u" 1") # 1 self.mapping.append (u"abcåä2ABCÅÄ") # 2 diff --git a/mytest.py b/mytest.py index c335bf2d..efbc34bb 100755 --- a/mytest.py +++ b/mytest.py @@ -256,7 +256,7 @@ class Session: self.execEnd(last=False) def popCurrent(self): - if len(self.dialog_stack): + if self.dialog_stack: (self.current_dialog, do_show) = self.dialog_stack.pop() self.execBegin(first=False, do_show=do_show) else: @@ -275,7 +275,7 @@ class Session: return dlg def open(self, screen, *arguments, **kwargs): - if len(self.dialog_stack) and not self.in_exec: + if self.dialog_stack and not self.in_exec: raise RuntimeError("modal open are allowed only from a screen which is modal!") # ...unless it's the very first screen. @@ -417,10 +417,7 @@ def runScreenTest(): CiHandler.setSession(session) - screensToRun = [ ] - - for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD): - screensToRun.append(p.__call__) + screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ] profile("wizards") screensToRun += wizardManager.getWizards() @@ -444,7 +441,7 @@ def runScreenTest(): screen = screensToRun[0][1] - if len(screensToRun): + if screensToRun: session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen) else: session.open(screen) @@ -476,8 +473,8 @@ def runScreenTest(): ] wakeupList.sort() recordTimerWakeupAuto = False - if len(wakeupList): - startTime = wakeupList.pop(0) + if wakeupList: + startTime = wakeupList[0] if (startTime[0] - nowTime) < 330: # no time to switch box back on wptime = nowTime + 30 # so switch back on in 30 seconds else: diff --git a/skin.py b/skin.py index 6baf6b71..a37716f1 100644 --- a/skin.py +++ b/skin.py @@ -26,10 +26,10 @@ def dump(x, i=0): class SkinError(Exception): def __init__(self, message): - self.message = message + self.msg = message def __str__(self): - return "{%s}: %s" % (config.skin.primary_skin, self.message) + return "{%s}: %s" % (config.skin.primary_skin, self.msg) dom_skins = [ ] @@ -98,7 +98,7 @@ def collectAttributes(skinAttributes, node, skin_path_prefix=None, ignore=[]): attrib = a[0] value = a[1] - if attrib in ["pixmap", "pointer", "seek_pointer", "backgroundPixmap", "selectionPixmap"]: + if attrib in ("pixmap", "pointer", "seek_pointer", "backgroundPixmap", "selectionPixmap"): value = resolveFilename(SCOPE_SKIN_IMAGE, value, path_prefix=skin_path_prefix) if attrib not in ignore: @@ -131,7 +131,7 @@ def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1) guiObject.setFont(parseFont(value, scale)) elif attrib == 'zPosition': guiObject.setZPosition(int(value)) - elif attrib in ["pixmap", "backgroundPixmap", "selectionPixmap"]: + elif attrib in ("pixmap", "backgroundPixmap", "selectionPixmap"): ptr = loadPixmap(value, desktop) # this should already have been filename-resolved. if attrib == "pixmap": guiObject.setPixmap(ptr) diff --git a/timer.py b/timer.py index fd5bb5af..64df9c88 100644 --- a/timer.py +++ b/timer.py @@ -222,7 +222,7 @@ class Timer: min = int(time()) + self.MaxWaitTime # calculate next activation point - if len(self.timer_list): + if self.timer_list: w = self.timer_list[0].getNextActivation() if w < min: min = w @@ -278,5 +278,5 @@ class Timer: t = int(time()) + 1 # we keep on processing the first entry until it goes into the future. - while len(self.timer_list) and self.timer_list[0].getNextActivation() < t: + while self.timer_list and self.timer_list[0].getNextActivation() < t: self.doActivate(self.timer_list[0]) -- cgit v1.2.3 From f46b03d1dd4bf90975b0c946fc2720202832b836 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 25 Feb 2009 12:31:33 +0100 Subject: make SoftwareManager filescan description translatable --- lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index 1df061e2..3eefa47d 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -815,7 +815,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "Ipkg", - description = "Install software updates...", + description = _("Install software updates..."), openfnc = filescan_open, ) def UpgradeMain(session, **kwargs): -- cgit v1.2.3 From a9589a258f6173fc8af17d802def10d0d918bc16 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 27 Feb 2009 23:19:00 +0100 Subject: add possibility to change services in single service epg with bouquet +/- key --- lib/python/Screens/ChannelSelection.py | 23 +++++++++++++---- lib/python/Screens/EpgSelection.py | 24 +++++++++++++---- lib/python/Screens/InfoBarGenerics.py | 47 +++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 11 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index bae8f7de..0ff4042b 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -317,11 +317,24 @@ class ChannelSelectionEPG: def showEPGList(self): ref=self.getCurrentSelection() - ptr=eEPGCache.getInstance() - if ptr.startTimeQuery(ref) != -1: - self.session.open(EPGSelection, ref) - else: - print 'no epg for service', ref.toString() + if ref: + self.savedService = ref + self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB=self.changeServiceCB) + + def SingleServiceEPGClosed(self, ret=False): + self.setCurrentSelection(self.savedService) + + def changeServiceCB(self, direction, epg): + beg = self.getCurrentSelection() + while True: + if direction > 0: + self.moveDown() + else: + self.moveUp() + cur = self.getCurrentSelection() + if cur == beg or not (cur.flags & eServiceReference.isMarker): + break + epg.setService(ServiceReference(self.getCurrentSelection())) class ChannelSelectionEdit: def __init__(self): diff --git a/lib/python/Screens/EpgSelection.py b/lib/python/Screens/EpgSelection.py index ae96333e..49308994 100644 --- a/lib/python/Screens/EpgSelection.py +++ b/lib/python/Screens/EpgSelection.py @@ -25,12 +25,14 @@ class EPGSelection(Screen): ZAP = 1 - def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None): + def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None, serviceChangeCB=None): Screen.__init__(self, session) self.bouquetChangeCB = bouquetChangeCB + self.serviceChangeCB = serviceChangeCB self.ask_time = -1 #now self["key_red"] = Button("") self.closeRecursive = False + self.saved_title = None if isinstance(service, str) and eventid != None: self.type = EPG_TYPE_SIMILAR self["key_yellow"] = Button() @@ -81,19 +83,22 @@ class EPGSelection(Screen): "red": self.zapTo, "input_date_time": self.enterDateTime, "nextBouquet": self.nextBouquet, - "prevBouquet": self.prevBouquet + "prevBouquet": self.prevBouquet, }) self["actions"].csel = self - self.onLayoutFinish.append(self.onCreate) def nextBouquet(self): - if self.bouquetChangeCB: + if self.serviceChangeCB: + self.serviceChangeCB(1, self) + elif self.bouquetChangeCB: self.bouquetChangeCB(1, self) def prevBouquet(self): if self.bouquetChangeCB: self.bouquetChangeCB(-1, self) + elif self.serviceChangeCB: + self.serviceChangeCB(-1, self) def enterDateTime(self): if self.type == EPG_TYPE_MULTI: @@ -129,6 +134,10 @@ class EPGSelection(Screen): self.services = services self.onCreate() + def setService(self, service): + self.currentService = service + self.onCreate() + #just used in multipeg def onCreate(self): l = self["list"] @@ -137,7 +146,12 @@ class EPGSelection(Screen): l.fillMultiEPG(self.services, self.ask_time) l.moveToService(self.session.nav.getCurrentlyPlayingServiceReference()) elif self.type == EPG_TYPE_SINGLE: - l.fillSingleEPG(self.currentService) + service = self.currentService + if self.saved_title is None: + self.saved_title = self.instance.getTitle() + title = self.saved_title + ' - ' + service.getServiceName() + self.instance.setTitle(title) + l.fillSingleEPG(service) else: l.fillSimilarList(self.currentService, self.eventid) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index e39e028d..1594b3a5 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -391,6 +391,32 @@ class InfoBarSimpleEventView: epglist[1] = tmp setEvent(epglist[0]) +class SimpleServicelist: + def __init__(self, services): + self.services = services + self.length = len(services) + self.current = 0 + + def selectService(self, service): + self.current = 0 + while self.services[self.current].ref != service: + self.current += 1 + + def nextService(self): + if self.current+1 < self.length: + self.current += 1 + else: + self.current = 0 + + def prevService(self): + if self.current-1 > -1: + self.current -= 1 + else: + self.current = self.length - 1 + + def currentService(self): + return self.services[self.current] + class InfoBarEPG: """ EPG - Opens an EPG list when the showEPGList action fires """ def __init__(self): @@ -487,9 +513,28 @@ class InfoBarEPG: elif cnt == 1: self.openBouquetEPG(bouquets[0][1], withCallback) + def changeServiceCB(self, direction, epg): + if self.serviceSel: + if direction > 0: + self.serviceSel.nextService() + else: + self.serviceSel.prevService() + epg.setService(self.serviceSel.currentService()) + + def SingleServiceEPGClosed(self, ret=False): + self.serviceSel = None + def openSingleServiceEPG(self): ref=self.session.nav.getCurrentlyPlayingServiceReference() - self.session.open(EPGSelection, ref) + if ref: + if self.servicelist.getMutableList() is not None: # bouquet in channellist + current_path = self.servicelist.getRoot() + services = self.getBouquetServices(current_path) + self.serviceSel = SimpleServicelist(services) + self.serviceSel.selectService(ref) + self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = self.changeServiceCB) + else: + self.session.open(EPGSelection, ref) def showEventInfoPlugins(self): list = [(p.name, boundFunction(self.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EVENTINFO)] -- cgit v1.2.3 From 23d87e80ac74cea3df87ac89cef734509341fa98 Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 28 Feb 2009 10:23:47 +0100 Subject: use < > keys vor next / previous service in single service epg --- data/keymap.xml | 2 ++ lib/python/Screens/EpgSelection.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'lib/python') diff --git a/data/keymap.xml b/data/keymap.xml index 264afccf..0865e416 100644 --- a/data/keymap.xml +++ b/data/keymap.xml @@ -475,6 +475,8 @@ + + diff --git a/lib/python/Screens/EpgSelection.py b/lib/python/Screens/EpgSelection.py index 49308994..d09ed004 100644 --- a/lib/python/Screens/EpgSelection.py +++ b/lib/python/Screens/EpgSelection.py @@ -82,22 +82,28 @@ class EPGSelection(Screen): "info": self.infoKeyPressed, "red": self.zapTo, "input_date_time": self.enterDateTime, - "nextBouquet": self.nextBouquet, - "prevBouquet": self.prevBouquet, + "nextBouquet": self.nextBouquet, # just used in multi epg yet + "prevBouquet": self.prevBouquet, # just used in multi epg yet + "nextService": self.nextService, # just used in single epg yet + "prevService": self.prevService, # just used in single epg yet }) self["actions"].csel = self self.onLayoutFinish.append(self.onCreate) def nextBouquet(self): - if self.serviceChangeCB: - self.serviceChangeCB(1, self) - elif self.bouquetChangeCB: + if self.bouquetChangeCB: self.bouquetChangeCB(1, self) def prevBouquet(self): if self.bouquetChangeCB: self.bouquetChangeCB(-1, self) - elif self.serviceChangeCB: + + def nextService(self): + if self.serviceChangeCB: + self.serviceChangeCB(1, self) + + def prevService(self): + if self.serviceChangeCB: self.serviceChangeCB(-1, self) def enterDateTime(self): -- cgit v1.2.3 From e63586af0f2e8acf5a0972ae1993c039edcd901e Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 2 Mar 2009 17:17:06 +0100 Subject: replace EOF magic by a slightly more accurate PVR EOF. --- lib/base/filepush.cpp | 8 +++-- lib/python/Screens/InfoBarGenerics.py | 58 ++++------------------------------- 2 files changed, 12 insertions(+), 54 deletions(-) (limited to 'lib/python') diff --git a/lib/base/filepush.cpp b/lib/base/filepush.cpp index 1999707f..ed2a2185 100644 --- a/lib/base/filepush.cpp +++ b/lib/base/filepush.cpp @@ -189,9 +189,13 @@ void eFilePushThread::thread() if (m_send_pvr_commit && !already_empty) { eDebug("sending PVR commit"); + + struct pollfd pfd[1] = {m_fd_dest, POLLHUP}; + poll(pfd, 1, 10000); + sleep(5); /* HACK to allow ES buffer to drain */ already_empty = 1; - if (::ioctl(m_fd_dest, PVR_COMMIT) < 0 && errno == EINTR) - continue; +// if (::ioctl(m_fd_dest, PVR_COMMIT) < 0 && errno == EINTR) +// continue; eDebug("commit done"); /* well check again */ continue; diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index e39e028d..71e08327 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -623,11 +623,6 @@ class InfoBarSeek: iPlayableService.evEOF: self.__evEOF, iPlayableService.evSOF: self.__evSOF, }) - self.eofState = 0 - self.eofTimer = eTimer() - self.eofTimer.timeout.get().append(self.doEof) - self.eofInhibitTimer = eTimer() - self.eofInhibitTimer.timeout.get().append(self.inhibitEof) self.minSpeedBackward = useSeekBackHack and 16 or 0 @@ -763,9 +758,6 @@ class InfoBarSeek: def __serviceStarted(self): self.seekstate = self.SEEK_STATE_PLAY self.__seekableStatusChanged() - if self.eofState != 0: - self.eofTimer.stop() - self.eofState = 0 def setSeekState(self, state): service = self.session.nav.getCurrentService() @@ -827,16 +819,6 @@ class InfoBarSeek: seekable = self.getSeek() if seekable is None: return - prevstate = self.seekstate - if self.eofState == 1: - self.eofState = 2 - self.inhibitEof() - if self.seekstate == self.SEEK_STATE_EOF: - if prevstate == self.SEEK_STATE_PAUSE: - self.setSeekState(self.SEEK_STATE_PAUSE) - else: - self.setSeekState(self.SEEK_STATE_PLAY) - self.eofInhibitTimer.start(200, True) seekable.seekTo(pts) def doSeekRelative(self, pts): @@ -844,15 +826,12 @@ class InfoBarSeek: if seekable is None: return prevstate = self.seekstate - if self.eofState == 1: - self.eofState = 2 - self.inhibitEof() + if self.seekstate == self.SEEK_STATE_EOF: if prevstate == self.SEEK_STATE_PAUSE: self.setSeekState(self.SEEK_STATE_PAUSE) else: self.setSeekState(self.SEEK_STATE_PLAY) - self.eofInhibitTimer.start(200, True) seekable.seekRelative(pts<0 and -1 or 1, abs(pts)) if abs(pts) > 100 and config.usage.show_infobar_on_skip.value: self.showAfterSeek() @@ -964,44 +943,19 @@ class InfoBarSeek: return False def __evEOF(self): - if self.eofState == 0 and self.seekstate != self.SEEK_STATE_EOF: - self.eofState = 1 - time = self.calcRemainingTime() - if not time: - time = 3000 # Failed to calc, use default - elif time == 0: - time = 300 # Passed end, shortest wait - elif time > 15000: - self.eofState = -2 # Too long, block eof - time = 15000 - else: - time += 1000 # Add margin - self.eofTimer.start(time, True) - - def inhibitEof(self): - if self.eofState >= 1: - self.eofState = -self.eofState - self.eofTimer.stop() - self.doEof() - - def doEof(self): if self.seekstate == self.SEEK_STATE_EOF: return - if self.eofState == -2 or self.isStateBackward(self.seekstate): - self.eofState = 0 - return - # if we are seeking, we try to end up ~1s before the end, and pause there. - eofstate = self.eofState + # if we are seeking forward, we try to end up ~1s before the end, and pause there. seekstate = self.seekstate - self.eofState = 0 - if not self.seekstate == self.SEEK_STATE_PAUSE: + if self.seekstate != self.SEEK_STATE_PAUSE: self.setSeekState(self.SEEK_STATE_EOF) - if eofstate == -1 or not seekstate in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE): + + if seekstate not in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE): # if we are seeking seekable = self.getSeek() if seekable is not None: seekable.seekTo(-1) - if eofstate == 1 and seekstate == self.SEEK_STATE_PLAY: + if seekstate == self.SEEK_STATE_PLAY: # regular EOF self.doEofInternal(True) else: self.doEofInternal(False) -- cgit v1.2.3 From 8d2545bc513280abe52d9c0fc2b704de3729a11e Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 2 Mar 2009 17:28:35 +0100 Subject: listen to hotplug event when dvd is inserted or ejected and modify EXIT menu accordingly --- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 78 ++++++++++++++--------- 1 file changed, 48 insertions(+), 30 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index 6a8ffc6f..ce2e5938 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -14,6 +14,7 @@ from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase from Components.config import config from Tools.Directories import pathExists, fileExists from Components.Harddisk import harddiskmanager +from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier import servicedvd # load c++ part of dvd player plugin @@ -345,28 +346,15 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP }) self.onClose.append(self.__onClose) - self.physicalDVD = False - self.dvd_device = None + hotplugNotifier.append(self.hotplugCB) + if dvd_device: - self.dvd_device = dvd_device - self.physicalDVD = True + self.physicalDVD = True else: - devicepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) - if pathExists(devicepath): - from Components.Scanner import scanDevice - res = scanDevice(devicepath) - list = [ (r.description, r, res[r], self.session) for r in res ] - if list: - (desc, scanner, files, session) = list[0] - for file in files: - print file - if file.mimetype == "video/x-dvd": - self.dvd_device = devicepath - print "physical dvd found:", self.dvd_device - self.physicalDVD = True + self.scanHotplug() self.dvd_filelist = dvd_filelist - self.onFirstExecBegin.append(self.showFileBrowser) + self.onFirstExecBegin.append(self.opened) self.service = None self.in_menu = False @@ -513,6 +501,8 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP choices = [(_("Exit"), "exit"), (_("Continue playing"), "play")] if True or not self.physicalDVD: choices.insert(1,(_("Return to file browser"), "browser")) + if self.physicalDVD and not self.session.nav.getCurrentlyPlayingServiceReference().toString().endswith(harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD())): + choices.insert(0,(_("Play DVD"), "playPhysical" )) self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list = choices) def sendKey(self, key): @@ -581,23 +571,22 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP def keyCancel(self): self.askLeavePlayer() - def showFileBrowser(self): - if self.physicalDVD and len(self.dvd_filelist) == 0: - if self.dvd_device == harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()): - self.session.openWithCallback(self.DVDdriveCB, MessageBox, text=_("Do you want to play DVD in drive?"), timeout=5 ) - else: - self.DVDdriveCB(True) - elif len(self.dvd_filelist) == 1: + def opened(self): + if len(self.dvd_filelist) == 1: + # opened via autoplay self.FileBrowserClosed(self.dvd_filelist[0]) + elif self.physicalDVD: + # opened from menu with dvd in drive + self.session.openWithCallback(self.playPhysicalCB, MessageBox, text=_("Do you want to play DVD in drive?"), timeout=5 ) else: + # opened from menu without dvd in drive self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, self.dvd_filelist) - - def DVDdriveCB(self, answer): + + def playPhysicalCB(self, answer): if answer == True: - self.FileBrowserClosed(self.dvd_device) + self.FileBrowserClosed(harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD())) else: self.session.openWithCallback(self.FileBrowserClosed, FileBrowser) - self.physicalDVD = False def FileBrowserClosed(self, val): curref = self.session.nav.getCurrentlyPlayingServiceReference() @@ -627,13 +616,18 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP #else if self.service: self.service = None - self.showFileBrowser() + self.session.openWithCallback(self.FileBrowserClosed, FileBrowser) + if answer[1] == "playPhysical": + if self.service: + self.service = None + self.playPhysicalCB(True) else: pass def __onClose(self): self.restore_infobar_seek_config() self.session.nav.playService(self.oldService) + hotplugNotifier.remove(self.hotplugCB) def playLastCB(self, answer): # overwrite infobar cuesheet function print "playLastCB", answer, self.resume_point @@ -660,6 +654,30 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP def calcRemainingTime(self): return 0 + def hotplugCB(self, dev, media_state): + print "[hotplugCB]", dev, media_state + if dev == harddiskmanager.getCD(): + if media_state == "1": + self.scanHotplug() + else: + self.physicalDVD = False + + def scanHotplug(self): + devicepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) + if pathExists(devicepath): + from Components.Scanner import scanDevice + res = scanDevice(devicepath) + list = [ (r.description, r, res[r], self.session) for r in res ] + if list: + (desc, scanner, files, session) = list[0] + for file in files: + print file + if file.mimetype == "video/x-dvd": + print "physical dvd found:", devicepath + self.physicalDVD = True + return + self.physicalDVD = False + def main(session, **kwargs): session.open(DVDPlayer) -- cgit v1.2.3 From 661a33ebe19d4341a8f1657ad0f403a9a7ac0f6b Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 2 Mar 2009 17:34:15 +0100 Subject: media player cosmetical changes, thanks to kerni --- lib/python/Components/MediaPlayer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/python') 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() -- cgit v1.2.3 From 533dd652737ca702c0e9528ed06e8a17b9ec72c5 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Tue, 3 Mar 2009 00:44:19 +0100 Subject: first pickle, then save to avoid killing config file on sigint --- lib/python/Components/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 79e99b03..4cc40633 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -1614,8 +1614,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): -- cgit v1.2.3 From 1354d745469c0595f4c379edf543d5a613663e03 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 3 Mar 2009 11:50:35 +0100 Subject: fix selecting menu template and background image files, only allow start of burning process if at least one title is in the collection, otherwise hide menu entry and add yes-no-box before burning with RECORD key on rcu --- .../Plugins/Extensions/DVDBurn/ProjectSettings.py | 67 ++++++++++++---------- lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 15 +++-- 2 files changed, 47 insertions(+), 35 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py b/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py index e97961b4..a8888da3 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py +++ b/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py @@ -18,11 +18,12 @@ class FileBrowser(Screen, HelpableScreen): """ - def __init__(self, session, scope, settings): + def __init__(self, session, scope, configRef): Screen.__init__(self, session) HelpableScreen.__init__(self) self.scope = scope pattern = "" + self.configRef = configRef currDir = "/" if self.scope == "project": currDir = self.getDir() @@ -31,19 +32,19 @@ class FileBrowser(Screen, HelpableScreen): currDir = self.getDir() pattern = "(?i)^.*\.(ddvdm\.xml)" if self.scope == "menubg": - currDir = self.getDir(settings.menubg) + currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)" elif self.scope == "menuaudio": - currDir = self.getDir(settings.menuaudio) + currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(mp2|m2a|ac3)" elif self.scope == "vmgm": - currDir = self.getDir(settings.vmgm) + currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(mpg|mpeg)" elif self.scope == "font_face": - currDir = self.getDir(settings.font_face, resolveFilename(SCOPE_FONTS)) + currDir = self.getDir(configRef.getValue(), resolveFilename(SCOPE_FONTS)) pattern = "(?i)^.*\.(ttf)" elif self.scope == "isopath": - currDir = settings.isopath.getValue() + currDir = configRef.getValue() elif self.scope == "image": currDir = resolveFilename(SCOPE_HDD) pattern = "(?i)^.*\.(iso)" @@ -57,11 +58,9 @@ class FileBrowser(Screen, HelpableScreen): "cancel": self.exit }) - def getDir(self, key=None, defaultDir=None): - if key: - settingDir = key.getValue() - if len(settingDir) > 1: - return (settingDir.rstrip("/").rsplit("/",1))[0] + def getDir(self, currentVal=None, defaultDir=None): + if currentVal: + return (currentVal.rstrip("/").rsplit("/",1))[0] return defaultDir or (resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/") def ok(self): @@ -70,15 +69,15 @@ class FileBrowser(Screen, HelpableScreen): if self.scope == "image": path = self["filelist"].getCurrentDirectory() or "" if fileExists(path+"VIDEO_TS"): - self.close(path,self.scope) + self.close(path,self.scope,self.configRef) else: ret = self["filelist"].getCurrentDirectory() + '/' + self["filelist"].getFilename() - self.close(ret,self.scope) + self.close(ret,self.scope,self.configRef) def exit(self): if self.scope == "isopath": - self.close(self["filelist"].getCurrentDirectory(),self.scope) - self.close(None,False) + self.close(self["filelist"].getCurrentDirectory(),self.scope,self.configRef) + self.close(None,False,None) class ProjectSettings(Screen,ConfigListScreen): skin = """ @@ -113,13 +112,10 @@ class ProjectSettings(Screen,ConfigListScreen): infotext = "" self["info"] = StaticText(infotext) + self.keydict = {} self.settings = project.settings ConfigListScreen.__init__(self, []) self.initConfigList() - - self.keydict = {} - for key, val in self.settings.dict().iteritems(): - self.keydict[val] = key self["setupActions"] = ActionMap(["SetupActions", "ColorActions"], { @@ -167,6 +163,11 @@ class ProjectSettings(Screen,ConfigListScreen): self.list.append(getConfigListEntry(("DVD data format"), self.settings.dataformat)) self["config"].setList(self.list) + self.keydict = {} + for key, val in self.settings.dict().iteritems(): + self.keydict[val] = key + for key, val in self.project.menutemplate.settings.dict().iteritems(): + self.keydict[val] = key def keyLeft(self): ConfigListScreen.keyLeft(self) @@ -190,8 +191,9 @@ class ProjectSettings(Screen,ConfigListScreen): def ok(self): key = self.keydict[self["config"].getCurrent()[1]] - if key in self.project.filekeys: - self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, key, self.settings) + from DVDProject import ConfigFilename + if type(self["config"].getCurrent()[1]) == ConfigFilename: + self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, key, self["config"].getCurrent()[1]) def cancel(self): self.close(False) @@ -210,17 +212,20 @@ class ProjectSettings(Screen,ConfigListScreen): text = _("Save")+' '+_('Error') self.session.open(MessageBox,text,type = MessageBox.TYPE_ERROR) - def FileBrowserClosed(self, path, scope): + def FileBrowserClosed(self, path, scope, configRef): if scope == "menutemplate": - if not self.project.menutemplate.loadTemplate(path): - self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) - else: + if self.project.menutemplate.loadTemplate(path): print "[ProjectSettings] menu template loaded" - - if scope in self.project.filekeys: - self.settings.dict()[scope].setValue(path) - elif scope == "project": - if not self.project.loadProject(path): - self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) + configRef.setValue(path) + self.initConfigList() else: + self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) + elif scope == "project": + if self.project.loadProject(path): + configRef.setValue(path) self.initConfigList() + else: + self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) + elif scope: + configRef.setValue(path) + self.initConfigList() diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index 7e736f9f..fd4c7134 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -44,7 +44,7 @@ class TitleList(Screen, HelpableScreen): "titleProperties": (self.titleProperties, _("Properties of current title"), _("Title properties")), "removeCurrentTitle": (self.removeCurrentTitle, _("Remove currently selected title"), _("Remove title")), "settings": (self.settings, _("Collection settings"), _("Settings")), - "burnProject": (self.burnProject, _("Burn DVD"), _("Burn DVD")), + "burnProject": (self.askBurnProject, _("Burn DVD"), _("Burn DVD")), }) self["MovieSelectionActions"] = HelpableActionMap(self, "MovieSelectionActions", @@ -94,7 +94,8 @@ class TitleList(Screen, HelpableScreen): menu.append((_("DVD media toolbox"), self.toolbox)) menu.append((_("Preview menu"), self.previewMenu)) if self.project.settings.output.getValue() == "dvd": - menu.append((_("Burn DVD"), self.burnProject)) + if len(self["titles"].list): + menu.append((_("Burn DVD"), self.burnProject)) elif self.project.settings.output.getValue() == "iso": menu.append((_("Create DVD-ISO"), self.burnProject)) menu.append((_("Burn existing image to DVD"), self.selectImage)) @@ -196,7 +197,13 @@ class TitleList(Screen, HelpableScreen): self["error_label"].show() return False - def burnProject(self): + def askBurnProject(self): + if len(self["titles"].list): + self.session.openWithCallback(self.burnProject,MessageBox,text = _("Do you want to burn this collection to DVD medium?"), type = MessageBox.TYPE_YESNO) + + def burnProject(self, answer=True): + if not answer: + return if self.project.settings.authormode.getValue() == "data_ts": job = Process.DVDdataJob(self.project) job_manager.AddJob(job) @@ -208,7 +215,7 @@ class TitleList(Screen, HelpableScreen): job_manager.in_background = False self.session.openWithCallback(self.JobViewCB, JobView, job) - def burnISO(self, path, scope): + def burnISO(self, path, scope, configRef): if path: job = Process.DVDisoJob(self.project, path) job_manager.AddJob(job) -- cgit v1.2.3 From a5b628b1eb1c2ccdd68d7ea0f57bbb4a31c25c83 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Tue, 3 Mar 2009 18:57:46 +0100 Subject: - properly ignore transponders without values for tsid/onid in the diseqc tester - add some log file output for pids_failed case (real tsid/onid and expected tsid/onid) --- lib/dvb/db.cpp | 5 +++-- lib/python/Components/TuneTest.py | 4 ++-- lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/python') diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp index 110cedd8..e4d9ad22 100644 --- a/lib/dvb/db.cpp +++ b/lib/dvb/db.cpp @@ -839,7 +839,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje PyDict_SetItem(tp_dict, sat_pos, tplist); for (ElementConstIterator it(sat_elements.begin()); it != sat_elements.end(); ++it) { -// eDebug("\telement: %s", (*it)->name().c_str()); + //eDebug("\telement: %s", (*it)->name().c_str()); const AttributeList &tp_attributes = (*it)->getAttributeList(); AttributeConstIterator end = tp_attributes.end(); modulation = eDVBFrontendParametersSatellite::Modulation_QPSK; @@ -856,8 +856,8 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje for (AttributeConstIterator it(tp_attributes.begin()); it != end; ++it) { - //eDebug("\t\tattr: %s", at->name().c_str()); at = *it; + //eDebug("\t\tattr: %s", at->name().c_str()); name = at->name(); if (name == "modulation") dest = &modulation; else if (name == "system") dest = &system; @@ -872,6 +872,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje else if (name == "onid") dest = &onid; if (dest) { + //eDebug("\t\t\tvalue: %s", at->value().c_str()); tmp = strtol(at->value().c_str(), &end_ptr, 10); if (!*end_ptr) *dest = tmp; diff --git a/lib/python/Components/TuneTest.py b/lib/python/Components/TuneTest.py index 8e8644e3..e3b7d9e3 100644 --- a/lib/python/Components/TuneTest.py +++ b/lib/python/Components/TuneTest.py @@ -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 diff --git a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py index a4793949..bb4df74a 100644 --- a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py +++ b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py @@ -78,6 +78,14 @@ class ResultParser: text += " ==> " text += str(transponder[0]) text += "\n" + if reason == "pids_failed": + text += "(tsid, onid): " + text += str(transponder[3]['real']) + text += "(read from sat) != " + text += str(transponder[3]['expected']) + text += "(read from file)" + text += "\n" + text += "\n" if countsuccessful > 0: text += "\n" text += "Successfully tuned transponders' previous planes:\n" -- cgit v1.2.3 From 6912901710bd794bf67d1b9ffab9b3a90e4bf1dc Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 4 Mar 2009 11:49:13 +0100 Subject: fix possible crash --- lib/python/Screens/InfoBarGenerics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 20a239a2..64ed35f7 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -1525,7 +1525,7 @@ class InfoBarInstantRecord: print "after:\n", self.recording def setEndtime(self, entry): - if entry is not None: + if entry is not None and entry >= 0: self.selectedEntry = entry self.endtime=ConfigClock(default = self.recording[self.selectedEntry].end) dlg = self.session.openWithCallback(self.TimeDateInputClosed, TimeDateInput, self.endtime) @@ -1542,7 +1542,7 @@ class InfoBarInstantRecord: self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry]) def changeDuration(self, entry): - if entry is not None: + if entry is not None and entry >= 0: self.selectedEntry = entry self.session.openWithCallback(self.inputCallback, InputBox, title=_("How many minutes do you want to record?"), text="5", maxSize=False, type=Input.NUMBER) -- cgit v1.2.3 From 8ca7a05ca454eafdeb43cbbc68384af56dd9e153 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 5 Mar 2009 00:11:55 +0100 Subject: lib/python/Tools/DreamboxHardware.py: add function to set RTC Time --- lib/python/Tools/DreamboxHardware.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/python') diff --git a/lib/python/Tools/DreamboxHardware.py b/lib/python/Tools/DreamboxHardware.py index 5461f7b0..9e81bb47 100644 --- a/lib/python/Tools/DreamboxHardware.py +++ b/lib/python/Tools/DreamboxHardware.py @@ -23,6 +23,16 @@ def setFPWakeuptime(wutime): except IOError: print "setFPWakeupTime failed!" +def setRTCtime(wutime): + try: + open("/proc/stb/fp/rtc", "w").write(str(wutime)) + except IOError: + try: + fp = open("/dev/dbox/fp0") + ioctl(fp.fileno(), 0x101, pack('L', wutime)) # set wake up + except IOError: + print "setRTCtime failed!" + def getFPWakeuptime(): ret = 0 try: -- cgit v1.2.3 From 2575f3fca63db3f8804cc8257ce0e255424ab422 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 8 Mar 2009 14:26:33 +0100 Subject: fix typo --- lib/python/Components/TimerList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py index 1109860a..44a7eb4f 100644 --- a/lib/python/Components/TimerList.py +++ b/lib/python/Components/TimerList.py @@ -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): -- cgit v1.2.3 From e926fbc3973297be694469ce932cb40cea5356c7 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 10 Mar 2009 11:26:55 +0100 Subject: try to use current GUI language as initial dvd menu language --- lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index c2590af5..e35f2807 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -103,7 +103,10 @@ eServiceDVD::eServiceDVD(const char *filename): // create handle ddvd_set_dvd_path(m_ddvdconfig, filename); ddvd_set_ac3thru(m_ddvdconfig, 0); - ddvd_set_language(m_ddvdconfig, "de"); + + std::string ddvd_language; + if (!ePythonConfigQuery::getConfigValue("config.osd.language", ddvd_language)) + ddvd_set_language(m_ddvdconfig, (ddvd_language.substr(0,2)).c_str()); int fd = open("/proc/stb/video/aspect", O_RDONLY); if (fd > -1) -- cgit v1.2.3 From feaeba88fdfa0a51fec05a79e51e8111ffe0c4d0 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Wed, 11 Mar 2009 08:05:18 +0100 Subject: do nothing when green button is pressed in a record, to be consistent with UI --- lib/python/Screens/EventView.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/python') diff --git a/lib/python/Screens/EventView.py b/lib/python/Screens/EventView.py index c55d9527..c1ffb585 100644 --- a/lib/python/Screens/EventView.py +++ b/lib/python/Screens/EventView.py @@ -71,6 +71,8 @@ class EventViewBase: self.key_green_choice = self.ADD_TIMER def timerAdd(self): + if self.isRecording: + return event = self.event serviceref = self.currentService if event is None: -- cgit v1.2.3 From c5e9c66d00e481493bbc3f63f98e57ac68962ce0 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Wed, 11 Mar 2009 08:06:04 +0100 Subject: Patch by Moritz Venn: The current implementation of ConfigNumber.isChanged (the one inherited from ConfigElement) does not work properly as it will - at least for unsaved values - always returns True. This is obvious if you just take a look at the datatypes since value is an int and default is a string (because ConfigNumber is a modified ConfigText). To resolve this issue one can either compare self.tostring(self.value) or self.text to self.default but the former seems to be the more logical approach. The attached patch does override the method in ConfigNumber with the proposed fix. --- lib/python/Components/config.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/python') diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 4cc40633..24d39cba 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -1029,6 +1029,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") -- cgit v1.2.3 From 4531ea135c84d78d96d66a08b67f1f5e09475c55 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Wed, 11 Mar 2009 08:12:01 +0100 Subject: Patch by Moritz Venn: Allow to set an additional delay via config. Note that this requires driver support, which is not necessarily complete. --- data/setup.xml | 2 ++ lib/python/Components/AVSwitch.py | 5 ++++- lib/python/Plugins/SystemPlugins/Videomode/plugin.py | 4 ++++ lib/service/servicedvb.cpp | 14 ++++++++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) (limited to 'lib/python') diff --git a/data/setup.xml b/data/setup.xml index e2ab09b1..17301f23 100644 --- a/data/setup.xml +++ b/data/setup.xml @@ -13,6 +13,8 @@ config.av.tvsystem config.av.wss config.av.defaultac3 + config.av.generalAC3delay + config.av.generalPCMdelay config.av.downmix_ac3 config.av.vcrswitch 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/Plugins/SystemPlugins/Videomode/plugin.py b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py index 5a7dfd1b..6b6d5045 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py @@ -98,6 +98,10 @@ class VideoSetup(Screen, ConfigListScreen): self.list.append(getConfigListEntry(_("AC3 default"), config.av.defaultac3)) if SystemInfo["CanDownmixAC3"]: self.list.append(getConfigListEntry(_("AC3 downmix"), config.av.downmix_ac3)) + self.list.extend(( + getConfigListEntry(_("General AC3 Delay"), config.av.generalAC3delay), + getConfigListEntry(_("General PCM Delay"), config.av.generalPCMdelay) + )) if SystemInfo["CanChangeOsdAlpha"]: self.list.append(getConfigListEntry(_("OSD visibility"), config.av.osd_alpha)) diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 12b75f80..012493fa 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -2267,8 +2267,18 @@ void eDVBServicePlay::updateDecoder() } } } - m_decoder->setAC3Delay(ac3_delay == -1 ? 0 : ac3_delay); - m_decoder->setPCMDelay(pcm_delay == -1 ? 0 : pcm_delay); + + std::string config_delay; + int config_delay_int = 0; + if(ePythonConfigQuery::getConfigValue("config.av.generalAC3delay", config_delay) == 0) + config_delay_int = atoi(config_delay.c_str()); + m_decoder->setAC3Delay(ac3_delay == -1 ? config_delay_int : ac3_delay + config_delay_int); + + if(ePythonConfigQuery::getConfigValue("config.av.generalPCMdelay", config_delay) == 0) + config_delay_int = atoi(config_delay.c_str()); + else + config_delay_int = 0; + m_decoder->setPCMDelay(pcm_delay == -1 ? config_delay_int : pcm_delay + config_delay_int); m_decoder->setVideoPID(vpid, vpidtype); selectAudioStream(); -- cgit v1.2.3 From a2b81eb390ee9cfb892734251429a062a4fa77e4 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 15 Mar 2009 11:58:52 +0100 Subject: add "High bitrate support" choice in CI Setup (needs new drivers to work) --- data/skin_default.xml | 4 ++-- lib/dvb_ci/dvbci.cpp | 25 +++++++++++++++++++++++++ lib/dvb_ci/dvbci.h | 2 ++ lib/dvb_ci/dvbci_ui.cpp | 5 +++++ lib/dvb_ci/dvbci_ui.h | 2 ++ lib/python/Screens/Ci.py | 21 +++++++++++++++++++-- po/de.po | 3 +++ po/enigma2.pot | 4 ++++ 8 files changed, 62 insertions(+), 4 deletions(-) (limited to 'lib/python') diff --git a/data/skin_default.xml b/data/skin_default.xml index f99e1a76..ed3b8a23 100755 --- a/data/skin_default.xml +++ b/data/skin_default.xml @@ -172,9 +172,9 @@ self.instance.move(ePoint((720-wsizex)/2, (576-wsizey)/(count > 7 and 2 or 3) - + - + diff --git a/lib/dvb_ci/dvbci.cpp b/lib/dvb_ci/dvbci.cpp index 8fa1bca2..ce1f7d66 100644 --- a/lib/dvb_ci/dvbci.cpp +++ b/lib/dvb_ci/dvbci.cpp @@ -938,6 +938,14 @@ PyObject *eDVBCIInterfaces::readCICaIds(int slotid) return 0; } +int eDVBCIInterfaces::setCIClockRate(int slotid, int rate) +{ + eDVBCISlot *slot = getSlot(slotid); + if (slot) + return slot->setClockRate(rate); + return -1; +} + int eDVBCISlot::send(const unsigned char *data, size_t len) { int res=0; @@ -1323,4 +1331,21 @@ int eDVBCISlot::setSource(data_source source) return 0; } +int eDVBCISlot::setClockRate(int rate) +{ + char buf[64]; + snprintf(buf, 64, "/proc/stb/tsmux/ci%d_tsclk", slotid); + FILE *ci = fopen(buf, "wb"); + if (ci) + { + if (rate) + fprintf(ci, "high"); + else + fprintf(ci, "normal"); + fclose(ci); + return 0; + } + return -1; +} + eAutoInitP0 init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots"); diff --git a/lib/dvb_ci/dvbci.h b/lib/dvb_ci/dvbci.h index c11a1203..cdaaf904 100644 --- a/lib/dvb_ci/dvbci.h +++ b/lib/dvb_ci/dvbci.h @@ -94,6 +94,7 @@ public: void removeService(uint16_t program_number=0xFFFF); int getNumOfServices() { return running_services.size(); } int setSource(data_source source); + int setClockRate(int); }; struct CIPmtHandler @@ -146,6 +147,7 @@ public: int getMMIState(int slot); int sendCAPMT(int slot); int setInputSource(int tunerno, data_source source); + int setCIClockRate(int slot, int rate); #ifdef SWIG public: #endif diff --git a/lib/dvb_ci/dvbci_ui.cpp b/lib/dvb_ci/dvbci_ui.cpp index af613c43..b1bfdc25 100644 --- a/lib/dvb_ci/dvbci_ui.cpp +++ b/lib/dvb_ci/dvbci_ui.cpp @@ -71,5 +71,10 @@ int eDVBCI_UI::getMMIState(int slot) return eDVBCIInterfaces::getInstance()->getMMIState(slot); } +int eDVBCI_UI::setClockRate(int slot, int rate) +{ + return eDVBCIInterfaces::getInstance()->setCIClockRate(slot, rate); +} + //FIXME: correct "run/startlevel" eAutoInitP0 init_dvbciui(eAutoInitNumbers::rc, "DVB-CI UI"); diff --git a/lib/dvb_ci/dvbci_ui.h b/lib/dvb_ci/dvbci_ui.h index b53ab02d..65b0f95d 100644 --- a/lib/dvb_ci/dvbci_ui.h +++ b/lib/dvb_ci/dvbci_ui.h @@ -13,6 +13,7 @@ class eDVBCI_UI: public eMMI_UI #endif void stateChanged(int val) { ciStateChanged(val); } public: + enum { rateNormal, rateHigh }; PSignal1 ciStateChanged; #ifndef SWIG eDVBCI_UI(); @@ -26,6 +27,7 @@ public: int answerMenu(int slot, int answer); int answerEnq(int slot, char *val); int cancelEnq(int slot); + int setClockRate(int slot, int rate); }; #endif diff --git a/lib/python/Screens/Ci.py b/lib/python/Screens/Ci.py index a997f7fe..19f4d921 100644 --- a/lib/python/Screens/Ci.py +++ b/lib/python/Screens/Ci.py @@ -12,11 +12,21 @@ from enigma import eTimer, eDVBCI_UI, eDVBCIInterfaces MAX_NUM_CI = 4 +def setCIBitrate(configElement): + if configElement.value == "no": + eDVBCI_UI.getInstance().setClockRate(configElement.slotid, eDVBCI_UI.rateNormal) + else: + eDVBCI_UI.getInstance().setClockRate(configElement.slotid, eDVBCI_UI.rateHigh) + def InitCiConfig(): config.ci = ConfigSubList() for slot in range(MAX_NUM_CI): config.ci.append(ConfigSubsection()) config.ci[slot].canDescrambleMultipleServices = ConfigSelection(choices = [("auto", _("Auto")), ("no", _("No")), ("yes", _("Yes"))], default = "auto") + if SystemInfo["CommonInterfaceSupportsHighBitrates"]: + config.ci[slot].canHandleHighBitrates = ConfigSelection(choices = [("no", _("No")), ("yes", _("Yes"))], default = "no") + config.ci[slot].canHandleHighBitrates.slotid = slot + config.ci[slot].canHandleHighBitrates.addNotifier(setCIBitrate) class MMIDialog(Screen): def __init__(self, session, slotid, action, handler = eDVBCI_UI.getInstance(), wait_text = _("wait for ci...") ): @@ -226,7 +236,13 @@ class CiMessageHandler: self.ci = { } self.dlgs = { } eDVBCI_UI.getInstance().ciStateChanged.get().append(self.ciStateChanged) - SystemInfo["CommonInterface"]= eDVBCIInterfaces.getInstance().getNumOfSlots() > 0 + SystemInfo["CommonInterface"] = eDVBCIInterfaces.getInstance().getNumOfSlots() > 0 + try: + file = open("/proc/stb/tsmux/ci0_tsclk", "r") + file.close() + SystemInfo["CommonInterfaceSupportsHighBitrates"] = True + except: + SystemInfo["CommonInterfaceSupportsHighBitrates"] = False def setSession(self, session): self.session = session @@ -285,7 +301,7 @@ class CiSelection(Screen): def selectionChanged(self): cur_idx = self["entries"].getCurrentIndex() - self["text"].setText(_("Slot %d")%((cur_idx / 4)+1)) + self["text"].setText(_("Slot %d")%((cur_idx / 5)+1)) def keyConfigEntry(self, key): try: @@ -315,6 +331,7 @@ class CiSelection(Screen): self.list.append( (appname, ConfigNothing(), 2, slot) ) self.list.append(getConfigListEntry(_("Multiple service support"), config.ci[slot].canDescrambleMultipleServices)) + self.list.append(getConfigListEntry(_("High bitrate support"), config.ci[slot].canHandleHighBitrates)) def updateState(self, slot): state = eDVBCI_UI.getInstance().getState(slot) diff --git a/po/de.po b/po/de.po index 6fc82571..acf7d8a8 100644 --- a/po/de.po +++ b/po/de.po @@ -1541,6 +1541,9 @@ msgstr "Hierarchieinformationen" msgid "Hierarchy mode" msgstr "Hierarchiemodus" +msgid "High bitrate support" +msgstr "Kann hohe Datenraten verarbeiten" + msgid "Horizontal" msgstr "" diff --git a/po/enigma2.pot b/po/enigma2.pot index 0e63744e..e8cc8314 100644 --- a/po/enigma2.pot +++ b/po/enigma2.pot @@ -1828,6 +1828,10 @@ msgstr "" msgid "Hierarchy mode" msgstr "" +#: ../lib/python/Screens/Ci.py:334 +msgid "High bitrate support" +msgstr "" + #: ../lib/python/Tools/Transponder.py:31 msgid "Horizontal" msgstr "" -- cgit v1.2.3 From dd6be013ecf46092c8a26fdd922307a922ab8b0a Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 16 Mar 2009 15:56:06 +0100 Subject: Ci.py: fix crash since yesterday change without new drivers --- lib/python/Screens/Ci.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Screens/Ci.py b/lib/python/Screens/Ci.py index 19f4d921..0fb0feeb 100644 --- a/lib/python/Screens/Ci.py +++ b/lib/python/Screens/Ci.py @@ -331,7 +331,8 @@ class CiSelection(Screen): self.list.append( (appname, ConfigNothing(), 2, slot) ) self.list.append(getConfigListEntry(_("Multiple service support"), config.ci[slot].canDescrambleMultipleServices)) - self.list.append(getConfigListEntry(_("High bitrate support"), config.ci[slot].canHandleHighBitrates)) + if SystemInfo["CommonInterfaceSupportsHighBitrates"]: + self.list.append(getConfigListEntry(_("High bitrate support"), config.ci[slot].canHandleHighBitrates)) def updateState(self, slot): state = eDVBCI_UI.getInstance().getState(slot) -- cgit v1.2.3 From 0c04d5e3c5d06f04638d172fa1c9a57cad32d28a Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 17 Mar 2009 20:16:48 +0100 Subject: Mediaplayer/plugin.py: dont show mediaplayer gui after seek --- lib/python/Plugins/Extensions/MediaPlayer/plugin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index e26c65d4..e8504ff0 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -148,7 +148,6 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.player.show() return NumberActionMap.action(self, contexts, action) - self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", { "ok": (self.ok, _("add file to playlist")), @@ -386,7 +385,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.updateCurrentInfo() def showAfterSeek(self): - self.show() + pass def showAfterCuesheetOperation(self): self.show() -- cgit v1.2.3 From 5cbdedf2e348c489c6fdd26d7dc7e4ebeaa052ba Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 17 Mar 2009 22:19:58 +0100 Subject: Add plugin to assign service / providers / caids to Common Interface Modules --- configure.ac | 1 + .../CommonInterfaceAssignment/LICENSE | 12 + .../CommonInterfaceAssignment/Makefile.am | 6 + .../CommonInterfaceAssignment/__init__.py | 0 .../CommonInterfaceAssignment/plugin.py | 630 +++++++++++++++++++++ lib/python/Plugins/SystemPlugins/Makefile.am | 4 +- 6 files changed, 652 insertions(+), 1 deletion(-) create mode 100644 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/LICENSE create mode 100644 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/Makefile.am create mode 100644 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/__init__.py create mode 100644 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/plugin.py (limited to 'lib/python') diff --git a/configure.ac b/configure.ac index 49bf6d2d..cb0ace7f 100755 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,7 @@ lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/Makefile lib/python/Plugins/SystemPlugins/Videomode/Makefile lib/python/Plugins/SystemPlugins/VideoTune/Makefile lib/python/Plugins/SystemPlugins/DiseqcTester/Makefile +lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/Makefile lib/python/Plugins/DemoPlugins/Makefile lib/python/Plugins/DemoPlugins/TestPlugin/Makefile lib/python/Plugins/Extensions/Makefile diff --git a/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/LICENSE b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/LICENSE new file mode 100644 index 00000000..99700593 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/LICENSE @@ -0,0 +1,12 @@ +This plugin is licensed under the Creative Commons +Attribution-NonCommercial-ShareAlike 3.0 Unported +License. To view a copy of this license, visit +http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative +Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. + +Alternatively, this plugin may be distributed and executed on hardware which +is licensed by Dream Multimedia GmbH. + +This plugin is NOT free software. It is open source, you are allowed to +modify it (if you keep the license), but it may not be commercially +distributed other than under the conditions noted above. diff --git a/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/Makefile.am b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/Makefile.am new file mode 100644 index 00000000..562b1491 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/Makefile.am @@ -0,0 +1,6 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/CommonInterfaceAssignment + +install_PYTHON = \ + __init__.py \ + plugin.py + diff --git a/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/__init__.py b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/plugin.py b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/plugin.py new file mode 100644 index 00000000..4c8167d4 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/plugin.py @@ -0,0 +1,630 @@ +from Screens.Screen import Screen +from Screens.ChannelSelection import * +from Components.ActionMap import HelpableActionMap, ActionMap, NumberActionMap +from Components.Sources.List import List +from Components.Sources.StaticText import StaticText +from Components.config import ConfigNothing +from Components.ConfigList import ConfigList +from Components.Label import Label +from Components.SelectionList import SelectionList +from Components.MenuList import MenuList +from ServiceReference import ServiceReference +from Plugins.Plugin import PluginDescriptor +from xml.etree.cElementTree import parse as ci_parse +from Tools.XMLTools import elementsWithTag, mergeText, stringToXML +from enigma import eDVBCI_UI, eDVBCIInterfaces + +from os import system, path as os_path + +class CIselectMainMenu(Screen): + skin = """ + + + + + + + + """ + + def __init__(self, session, args = 0): + self.skin = CIselectMainMenu.skin + Screen.__init__(self, session) + + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Config")) + + self["actions"] = ActionMap(["ColorActions","SetupActions"], + { + "green": self.greenPressed, + "red": self.redPressed, + "yellow": self.yellowPressed, + "ok": self.greenPressed, + "cancel": self.cancel + }, -1) + + NUM_CI=eDVBCIInterfaces.getInstance().getNumOfSlots() + + print "[CI_Wizzard] FOUND %d CI Slots " % NUM_CI + + self.dlg = None + self.state = { } + self.list = [ ] + if NUM_CI > 0: + for slot in range(NUM_CI): + state = eDVBCI_UI.getInstance().getState(slot) + if state == 0: + appname = _("Slot %d") %(slot+1) + " - " + _("no module") + elif state == 1: + appname = _("Slot %d") %(slot+1) + " - " + _("init modules") + elif state == 2: + appname = _("Slot %d") %(slot+1) + " - " + eDVBCI_UI.getInstance().getAppName(slot) + self.list.append( (appname, ConfigNothing(), 0, slot) ) + else: + self.list.append( (_("no CI slots found") , ConfigNothing(), 1, -1) ) + + menuList = ConfigList(self.list) + menuList.list = self.list + menuList.l.setList(self.list) + self["CiList"] = menuList + + def greenPressed(self): + cur = self["CiList"].getCurrent() + if cur and len(cur) > 2: + action = cur[2] + slot = cur[3] + if action == 1: + print "[CI_Wizzard] there is no CI Slot in your receiver" + else: + print "[CI_Wizzard] selected CI Slot : %d" % slot + if config.usage.setup_level.index > 1: # advanced + self.session.open(CIconfigMenu, slot) + else: + self.session.open(easyCIconfigMenu, slot) + + def yellowPressed(self): + NUM_CI=eDVBCIInterfaces.getInstance().getNumOfSlots() + print "[CI_Check] FOUND %d CI Slots " % NUM_CI + if NUM_CI > 0: + for ci in range(NUM_CI): + print eDVBCIInterfaces.getInstance().getDescrambleRules(ci) +# else: +# print "no ci found" + + def redPressed(self): + print "[CI_Config] RED BUTTON not implemented yet - only use self.cancel()" + self.cancel() + + def cancel(self): + self.close() + +class CIconfigMenu(Screen): + skin = """ + + + + + + + + + + + + + + + """ + + def __init__(self, session, ci_slot="9"): + self.skin = CIconfigMenu.skin + Screen.__init__(self, session) + self.ci_slot=ci_slot + self.filename="/etc/enigma2/ci"+str(self.ci_slot)+".xml" + + self["key_red"] = StaticText(_("delete")) + self["key_green"] = StaticText(_("add Service")) + self["key_yellow"] = StaticText(_("add Provider")) + self["key_blue"] = StaticText(_("select CAId")) + self["CAidList.desc"] = Label(_("assigned CAIds")) + self["ServiceList.desc"] = Label(_("assigned Services/Provider")) + + self["actions"] = ActionMap(["ColorActions","SetupActions"], + { + "green": self.greenPressed, + "red": self.redPressed, + "yellow": self.yellowPressed, + "blue": self.bluePressed, + "ok": self.okPressed, + "cancel": self.cancel + }, -1) + + print "[CI_Wizzard_Config] Configuring CI Slots : %d " % self.ci_slot + + i=0 + self.caidlist=[] + print eDVBCIInterfaces.getInstance().readCICaIds(self.ci_slot) + for caid in eDVBCIInterfaces.getInstance().readCICaIds(self.ci_slot): + i+=1 + self.caidlist.append((str(hex(int(caid))),str(caid),i)) + + print "[CI_Wizzard_Config_CI%d] read following CAIds from CI: %s" %(self.ci_slot, self.caidlist) + self.selectedcaid =[] + self.servicelist = [] + self.caids=_("no CAId selected") + self["CAidList"] = Label(self.caids) + + serviceList = ConfigList(self.servicelist) + serviceList.list = self.servicelist + serviceList.l.setList(self.servicelist) + self["ServiceList"] = serviceList + + self.loadXML() + # if config mode !=advanced autoselect any caid + if config.usage.setup_level.index <= 1: # advanced + self.selectedcaid=self.caidlist + + def redPressed(self): + self.delete() + + def greenPressed(self): + self.session.openWithCallback( self.finishedChannelSelection, myChannelSelection, None) + + def yellowPressed(self): + self.session.openWithCallback( self.finishedProviderSelection, myProviderSelection, None) + + def bluePressed(self): + self.session.openWithCallback(self.finishedCAidSelection, CAidSelect, self.caidlist, self.selectedcaid) + + def okPressed(self): + print "[CI_Config_CI%d] OK BUTTON not implemented yet" %self.ci_slot + + def cancel(self): + self.saveXML() + activate_all(self) + self.close() + + def delete(self): + cur = self["ServiceList"].getCurrent() + if cur and len(cur) > 2: + self.servicelist.remove(cur) + self["ServiceList"].l.setList(self.servicelist) + + def finishedChannelSelection(self, *args): + if len(args): + ref=args[0] + service_ref = ServiceReference(ref) + service_name = service_ref.getServiceName() + if find_in_list(self.servicelist, service_name, 0)==False: + split_ref=service_ref.ref.toString().split(":") + if split_ref[0] == "1": #== dvb service und nicht muell von None + self.servicelist.append( (service_name , ConfigNothing(), 0, service_ref.ref.toString()) ) + self["ServiceList"].l.setList(self.servicelist) + + def finishedProviderSelection(self, *args): + if len(args)>1: # bei nix selected kommt nur 1 arg zurueck (==None) + name=args[0] + dvbnamespace=args[1] + if find_in_list(self.servicelist, name, 0)==False: + self.servicelist.append( (name , ConfigNothing(), 1, dvbnamespace) ) + self["ServiceList"].l.setList(self.servicelist) + + def finishedCAidSelection(self, *args): + if len(args): + self.selectedcaid=args[0] + self.caids="" + for item in self.selectedcaid: + if len(self.caids): + self.caids+= ", " + item[0] + else: + self.caids=item[0] + else: + self.selectedcaid=[] + self.caids=_("no CAId selected") + self["CAidList"].setText(self.caids) + + def saveXML(self): + try: + fp = file(self.filename, 'w') + fp.write("\n") + fp.write("\n") + fp.write("\t\n") + fp.write("\t\t%s\n" % self.ci_slot) + for item in self.selectedcaid: + if len(self.selectedcaid): + fp.write("\t\t\n" % item[0]) + for item in self.servicelist: + if len(self.servicelist): + if item[2]==1: + fp.write("\t\t\n" % (item[0], item[3])) + else: + fp.write("\t\t\n" % (item[0], item[3])) + fp.write("\t\n") + fp.write("\n") + fp.close() + except: + print "[CI_Config_CI%d] xml not written" %self.ci_slot + os.unlink(self.filename) + + def loadXML(self): + if not os_path.exists(self.filename): + return + + def getValue(definitions, default): + ret = "" + Len = len(definitions) + return Len > 0 and definitions[Len-1].text or default + + try: + tree = ci_parse(self.filename).getroot() + self.read_services=[] + self.read_providers=[] + self.usingcaid=[] + self.ci_config=[] +# for ci in tree.findall("ci"): + for slot in tree.findall("slot"): + read_slot = getValue(slot.findall("id"), False).encode("UTF-8") + print "ci " + read_slot + + i=0 + for caid in slot.findall("caid"): + read_caid = caid.get("id").encode("UTF-8") + self.selectedcaid.append((str(read_caid),str(read_caid),i)) + self.usingcaid.append(long(read_caid,16)) + i+=1 + + for service in slot.findall("service"): + read_service_name = service.get("name").encode("UTF-8") + read_service_ref = service.get("ref").encode("UTF-8") + self.read_services.append (read_service_ref) + + for provider in slot.findall("provider"): + read_provider_name = provider.get("name").encode("UTF-8") + read_provider_dvbname = provider.get("dvbnamespace").encode("UTF-8") + self.read_providers.append((read_provider_name,read_provider_dvbname)) + + self.ci_config.append((int(read_slot), (self.read_services, self.read_providers, self.usingcaid))) + except: + print "[CI_Config_CI%d] error parsing xml..." %self.ci_slot + + for item in self.read_services: + if len(item): + self.finishedChannelSelection(item) + + for item in self.read_providers: + if len(item): + self.finishedProviderSelection(item[0],item[1]) + + print self.ci_config + self.finishedCAidSelection(self.selectedcaid) + self["ServiceList"].l.setList(self.servicelist) + +class easyCIconfigMenu(CIconfigMenu): + skin = """ + + + + + + + + + + + """ + + def __init__(self, session, ci_slot="9"): + ci=ci_slot + CIconfigMenu.__init__(self, session, ci_slot) + self.skin = easyCIconfigMenu.skin + + self["actions"] = ActionMap(["ColorActions","SetupActions"], + { + "green": self.greenPressed, + "red": self.redPressed, + "yellow": self.yellowPressed, + "blue": self.bluePressed, + "ok": self.okPressed, + "cancel": self.cancel + }, -1) + + def bluePressed(self): + print "do nothing" + +class CAidSelect(Screen): + skin = """ + + + + + + + + """ + + def __init__(self, session, list, selected_caids): + self.skin = CAidSelect.skin + Screen.__init__(self, session) + + self.list = SelectionList() + self["list"] = self.list + + for listindex in range(len(list)): + if find_in_list(selected_caids,list[listindex][0],0): + self.list.addSelection(list[listindex][0], list[listindex][1], listindex, True) + else: + self.list.addSelection(list[listindex][0], list[listindex][1], listindex, False) + + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Save")) + + self["actions"] = ActionMap(["ColorActions","SetupActions"], + { + "ok": self.list.toggleSelection, + "cancel": self.cancel, + "green": self.greenPressed, + "red": self.cancel + }, -1) + + def greenPressed(self): + list = self.list.getSelectionsList() + print list + self.close(list) + + def cancel(self): + self.close() + +class myProviderSelection(ChannelSelectionBase): + skin = """ + + + + + + + + + + + """ + + def __init__(self, session, title): + ChannelSelectionBase.__init__(self, session) + self.onShown.append(self.__onExecCallback) + + self["actions"] = ActionMap(["OkCancelActions", "ChannelSelectBaseActions"], + { + "showFavourites": self.doNothing, + "showAllServices": self.doNothing, + "showProviders": self.doNothing, + "showSatellites": self.doNothing, + "cancel": self.cancel, + "ok": self.channelSelected, + }) + self["key_red"] = StaticText(_("")) + self["key_green"] = StaticText(_("")) + self["key_yellow"] = StaticText(_("")) + self["key_blue"] = StaticText(_("")) + + def doNothing(self): + print "nothing to do..." + + def __onExecCallback(self): + self.showSatellites() + + def channelSelected(self): # just return selected service + ref = self.getCurrentSelection() + splited_ref=ref.toString().split(":") + if ref.flags == 7 and splited_ref[6] != "0": + self.dvbnamespace=splited_ref[6] + self.enterPath(ref) + else: + self.close(ref.getName(), self.dvbnamespace) + + def showSatellites(self): + if not self.pathChangeDisabled: + refstr = '%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types) + if not self.preEnterPath(refstr): + ref = eServiceReference(refstr) + justSet=False + prev = None + + if self.isBasePathEqual(ref): + if self.isPrevPathEqual(ref): + justSet=True + prev = self.pathUp(justSet) + else: + currentRoot = self.getRoot() + if currentRoot is None or currentRoot != ref: + justSet=True + self.clearPath() + self.enterPath(ref, True) + if justSet: + serviceHandler = eServiceCenter.getInstance() + servicelist = serviceHandler.list(ref) + if not servicelist is None: + while True: + service = servicelist.getNext() + if not service.valid(): #check if end of list + break + unsigned_orbpos = service.getUnsignedData(4) >> 16 + orbpos = service.getData(4) >> 16 + if orbpos < 0: + orbpos += 3600 + if service.getPath().find("FROM PROVIDER") != -1: + service_type = _("Providers") + try: + # why we need this cast? + service_name = str(nimmanager.getSatDescription(orbpos)) + except: + if unsigned_orbpos == 0xFFFF: #Cable + service_name = _("Cable") + elif unsigned_orbpos == 0xEEEE: #Terrestrial + service_name = _("Terrestrial") + else: + if orbpos > 1800: # west + orbpos = 3600 - orbpos + h = _("W") + else: + h = _("E") + service_name = ("%d.%d" + h) % (orbpos / 10, orbpos % 10) + service.setName("%s - %s" % (service_name, service_type)) + self.servicelist.addService(service) + self.servicelist.finishFill() + if prev is not None: + self.setCurrentSelection(prev) + + def cancel(self): + self.close(None) + +class myChannelSelection(ChannelSelectionBase): + skin = """ + + + + + + + + + + + """ + + def __init__(self, session, title): + ChannelSelectionBase.__init__(self, session) + self.onShown.append(self.__onExecCallback) + service = self.session.nav.getCurrentService() + if service: + info = service.info() + if info: + refstr = info.getInfoString(iServiceInformation.sServiceref) + self.servicelist.setPlayableIgnoreService(eServiceReference(refstr)) + + self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions", "ChannelSelectBaseActions"], + { + "showProviders": self.doNothing, + "showSatellites": self.doNothing, + "cancel": self.cancel, + "ok": self.channelSelected, + "keyRadio": self.setModeRadio, + "keyTV": self.setModeTv + }) + + self["key_green"] = StaticText(_("")) + self["key_yellow"] = StaticText(_("")) + + def __onExecCallback(self): + self.setModeTv() + + def doNothing(self): + print "nothing to do..." + + def channelSelected(self): # just return selected service + ref = self.getCurrentSelection() + if (ref.flags & 7) == 7: + self.enterPath(ref) + elif not (ref.flags & eServiceReference.isMarker): + ref = self.getCurrentSelection() + self.close(ref) + + def setModeTv(self): + self.setTvMode() + self.showFavourites() + + def setModeRadio(self): + self.setRadioMode() + self.showFavourites() + + def cancel(self): + self.close(None) + +def activate_all(session): + NUM_CI=eDVBCIInterfaces.getInstance().getNumOfSlots() + print "[CI_Activate] FOUND %d CI Slots " % NUM_CI + if NUM_CI > 0: + ci_config=[] + def getValue(definitions, default): + # Initialize Output + ret = "" + # How many definitions are present + Len = len(definitions) + return Len > 0 and definitions[Len-1].text or default + + for ci in range(NUM_CI): + filename="/etc/enigma2/ci"+str(ci)+".xml" + + if not os_path.exists(filename): + print "[CI_Activate_Config_CI%d] no config file found" %ci + + try: + tree = ci_parse(filename).getroot() + read_services=[] + read_providers=[] + usingcaid=[] + for slot in tree.findall("slot"): + read_slot = getValue(slot.findall("id"), False).encode("UTF-8") + + for caid in slot.findall("caid"): + read_caid = caid.get("id").encode("UTF-8") + usingcaid.append(long(read_caid,16)) + + for service in slot.findall("service"): + read_service_ref = service.get("ref").encode("UTF-8") + read_services.append (read_service_ref) + + for provider in slot.findall("provider"): + read_provider_name = provider.get("name").encode("UTF-8") + read_provider_dvbname = provider.get("dvbnamespace").encode("UTF-8") + read_providers.append((read_provider_name,long(read_provider_dvbname,16))) + + ci_config.append((int(read_slot), (read_services, read_providers, usingcaid))) + except: + print "[CI_Activate_Config_CI%d] error parsing xml..." %ci + + for item in ci_config: + print "[CI_Activate] activate CI%d with following settings:" %item[0] + print item[0] + print item[1] + try: + eDVBCIInterfaces.getInstance().setDescrambleRules(item[0],item[1]) + except: + print "[CI_Activate_Config_CI%d] error setting DescrambleRules..." %item[0] + +def find_in_list(list, search, listpos=0): + for item in list: + if item[listpos]==search: + return True + return False + +global_session = None + +def sessionstart(reason, session): + global global_session + global_session = session + +def autostart(reason, **kwargs): + global global_session + if reason == 0: + print "[CI_Assignment] activating ci configs:" + activate_all(global_session) + elif reason == 1: + global_session = None + +def main(session, **kwargs): + session.open(CIselectMainMenu) + +def menu(menuid, **kwargs): + if menuid == "setup" and eDVBCIInterfaces.getInstance().getNumOfSlots(): + return [(_("Common Interface Assignment"), main, "ci_assign", 11)] + return [ ] + +def Plugins(**kwargs): + if config.usage.setup_level.index > 1: + return [PluginDescriptor( where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart ), + PluginDescriptor( where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart ), + PluginDescriptor( name = "CommonInterfaceAssignment", description = _("a gui to assign services/providers/caids to common interface modules"), where = PluginDescriptor.WHERE_MENU, fnc = menu )] + else: + return [PluginDescriptor( where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart ), + PluginDescriptor( where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart ), + PluginDescriptor( name = "CommonInterfaceAssignment", description = _("a gui to assign services/providers to common interface modules"), where = PluginDescriptor.WHERE_MENU, fnc = menu )] diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am index 10151f2c..634c7f42 100755 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -1 +1,3 @@ -SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug DefaultServicesScanner NFIFlash DiseqcTester +SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \ + SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug \ + DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment -- cgit v1.2.3 From bb7132afee4baa2e40be84adc38088f47ad25e86 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Thu, 19 Mar 2009 01:08:00 +0100 Subject: make ChoiceBox skinnable --- lib/python/Screens/ChoiceBox.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Screens/ChoiceBox.py b/lib/python/Screens/ChoiceBox.py index 4739b7e1..f33ab0ee 100644 --- a/lib/python/Screens/ChoiceBox.py +++ b/lib/python/Screens/ChoiceBox.py @@ -5,8 +5,10 @@ from Components.ChoiceList import ChoiceEntryComponent, ChoiceList from Components.Sources.StaticText import StaticText class ChoiceBox(Screen): - def __init__(self, session, title = "", list = [], keys = None, selection = 0): + def __init__(self, session, title = "", list = [], keys = None, selection = 0, skin_name = []): Screen.__init__(self, session) + + self.skinName = ["ChoiceBox"] + skin_name self["text"] = Label(title) self.list = [] -- cgit v1.2.3 From 711ea79c32a1190d7d0d5867b83cd61d20c9fb64 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Thu, 19 Mar 2009 01:08:17 +0100 Subject: sort plugins by name, give some ChoiceBoxes individual names --- lib/python/Screens/InfoBarGenerics.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 64ed35f7..8cb2569b 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -541,7 +541,7 @@ class InfoBarEPG: if list: list.append((_("show single service EPG..."), self.openSingleServiceEPG)) - self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = list) + self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = list, skin_name = "EPGExtensionsList") else: self.openSingleServiceEPG() @@ -1277,7 +1277,7 @@ class InfoBarExtensions: list.extend([(x[0](), x) for x in extensionsList]) keys += [""] * len(extensionsList) - self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys) + self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys, skin_name = "ExtensionsList") def extensionCallback(self, answer): if answer is not None: @@ -1295,7 +1295,9 @@ class InfoBarPlugins: return name def getPluginList(self): - return [((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU)] + list = [((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None, p.name) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU)] + list.sort(key = lambda e: e[2]) # sort by name + return list def runPlugin(self, plugin): if isinstance(self, InfoBarChannelSelection): @@ -1642,7 +1644,7 @@ class InfoBarAudioSelection: tlist = [((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n selection += 2 - self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys) + self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys, skin_name = "AudioTrackSelection") else: del self.audioTracks @@ -1666,7 +1668,7 @@ class InfoBarAudioSelection: keys = ["red", "green", "yellow"] selection = self.audioChannel.getCurrentChannel() tlist = ((_("left"), 0), (_("stereo"), 1), (_("right"), 2)) - self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys) + self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys, skin_name ="AudioModeSelection") else: del self.audioChannel if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > audio[1]: @@ -1767,7 +1769,7 @@ class InfoBarSubserviceSelection: keys = ["red", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n selection += 2 - self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = selection, keys = keys) + self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = selection, keys = keys, skin_name = "SubserviceSelection") def subserviceSelected(self, service): del self.bouquets -- cgit v1.2.3 From 53ce0ea2f42372971a357e5d0b455ae5cd2a3ca9 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 23 Mar 2009 00:31:40 +0100 Subject: allow strings to be used for skin_name --- lib/python/Screens/ChoiceBox.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Screens/ChoiceBox.py b/lib/python/Screens/ChoiceBox.py index f33ab0ee..7c8b1427 100644 --- a/lib/python/Screens/ChoiceBox.py +++ b/lib/python/Screens/ChoiceBox.py @@ -7,8 +7,10 @@ from Components.Sources.StaticText import StaticText class ChoiceBox(Screen): def __init__(self, session, title = "", list = [], keys = None, selection = 0, skin_name = []): Screen.__init__(self, session) - - self.skinName = ["ChoiceBox"] + skin_name + + if isinstance(skin_name, str): + skin_name = [skin_name] + self.skinName = skin_name + ["ChoiceBox"] self["text"] = Label(title) self.list = [] -- cgit v1.2.3 From 0c7eeca673a4b1bda346b472badabcb67f8c2908 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 23 Mar 2009 00:32:10 +0100 Subject: handle empty bouquets --- lib/python/Components/EpgList.py | 4 ++++ lib/python/Screens/InfoBarGenerics.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'lib/python') 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/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 8cb2569b..9b5f62c6 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -398,23 +398,32 @@ class SimpleServicelist: self.current = 0 def selectService(self, service): - self.current = 0 - while self.services[self.current].ref != service: - self.current += 1 + if not self.length: + self.current = -1 + else: + self.current = 0 + while self.services[self.current].ref != service: + self.current += 1 def nextService(self): + if not self.length: + return if self.current+1 < self.length: self.current += 1 else: self.current = 0 def prevService(self): + if not self.length: + return if self.current-1 > -1: self.current -= 1 else: self.current = self.length - 1 def currentService(self): + if not self.length: + return None return self.services[self.current] class InfoBarEPG: -- cgit v1.2.3 From 4ee4872e58477d2ffbc0c279a49408ee84176f0a Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 23 Mar 2009 13:19:35 +0100 Subject: config.py: remove unneeded notifier call --- lib/python/Components/config.py | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 24d39cba..c810e14b 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -281,7 +281,6 @@ class ConfigSelection(ConfigElement): self._descr = None self.default = self._value = self.last_value = default - self.changed() def setChoices(self, choices, default = None): self.choices = choicesList(choices) -- cgit v1.2.3 From 472d0fb82d59a7d7ffaa3e7041e0024c7ace0115 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 23 Mar 2009 13:21:18 +0100 Subject: NimManager.py: create some config entries just when needed .. to speedup enigma2 start --- lib/python/Components/NimManager.py | 406 ++++++++++++++++++++---------------- 1 file changed, 224 insertions(+), 182 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 48778571..6222afea 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -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) @@ -856,7 +856,7 @@ def InitSecParams(): config.sec.delay_after_last_diseqc_command = x x = ConfigInteger(default=50, limits = (0, 9999)) - x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value)) + x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value), initial_call = False) config.sec.delay_after_toneburst = x x = ConfigInteger(default=20, limits = (0, 9999)) @@ -926,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() @@ -986,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)] @@ -1077,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) @@ -1116,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 = { -- cgit v1.2.3 From f9259c898537d2c5f5722b9c6d8a9217ee5799ae Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 23 Mar 2009 13:25:00 +0100 Subject: improve /sys/block/*/stat parsing --- lib/python/Components/Harddisk.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 8664f79a..37905b7d 100755 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -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() -- cgit v1.2.3 From b9f48c64a16e501cc2d5bf28a9ab89aceb51c10c Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 23 Mar 2009 14:43:20 +0100 Subject: NimManager.py: small revert --- lib/python/Components/NimManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 6222afea..aa915937 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -856,7 +856,7 @@ def InitSecParams(): config.sec.delay_after_last_diseqc_command = x x = ConfigInteger(default=50, limits = (0, 9999)) - x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value), initial_call = False) + x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value)) config.sec.delay_after_toneburst = x x = ConfigInteger(default=20, limits = (0, 9999)) -- cgit v1.2.3 From 519da68556638c7502a4f679f859e6032e258421 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 23 Mar 2009 21:35:06 +0100 Subject: fix crash on aborting during CheckDiskspaceTask --- lib/python/Plugins/Extensions/DVDBurn/Process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/DVDBurn/Process.py b/lib/python/Plugins/Extensions/DVDBurn/Process.py index d0c9d3c6..6d9a4491 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/Process.py +++ b/lib/python/Plugins/Extensions/DVDBurn/Process.py @@ -372,11 +372,11 @@ class CheckDiskspaceTask(Task): self.finish(aborted = True) def run(self, callback): + self.callback = callback failed_preconditions = self.checkPreconditions(True) + self.checkPreconditions(False) if len(failed_preconditions): callback(self, failed_preconditions) return - self.callback = callback Task.processFinished(self, 0) class PreviewTask(Task): -- cgit v1.2.3 From 4634815c0fd9219332472707f6fcbdfd5d5b7821 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 23 Mar 2009 22:52:15 +0100 Subject: fix broken code when a hotplug partition was removed --- lib/python/Components/Harddisk.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 37905b7d..ad6c1a3b 100755 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -455,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 -- cgit v1.2.3 From e0f1f56d4acc89b75a67ece4109bb17cc0d1e6d9 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 25 Mar 2009 22:31:35 +0100 Subject: InfoBarGenerics.py: fix crash when press yellow in info screen on subservices --- lib/python/Screens/InfoBarGenerics.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 9b5f62c6..8221fca7 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -400,10 +400,14 @@ class SimpleServicelist: def selectService(self, service): if not self.length: self.current = -1 + return False else: self.current = 0 while self.services[self.current].ref != service: self.current += 1 + if self.current >= self.length: + return False + return True def nextService(self): if not self.length: @@ -422,7 +426,7 @@ class SimpleServicelist: self.current = self.length - 1 def currentService(self): - if not self.length: + if not self.length or self.current >= self.length: return None return self.services[self.current] @@ -540,8 +544,10 @@ class InfoBarEPG: current_path = self.servicelist.getRoot() services = self.getBouquetServices(current_path) self.serviceSel = SimpleServicelist(services) - self.serviceSel.selectService(ref) - self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = self.changeServiceCB) + if self.serviceSel.selectService(ref): + self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = self.changeServiceCB) + else: + self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref) else: self.session.open(EPGSelection, ref) @@ -553,7 +559,7 @@ class InfoBarEPG: self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = list, skin_name = "EPGExtensionsList") else: self.openSingleServiceEPG() - + def runPlugin(self, plugin): plugin(session = self.session, servicelist = self.servicelist) -- cgit v1.2.3 From afa81d4ccdcdc2bd76ca5483485c17e5ea68acc0 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 26 Mar 2009 09:22:46 +0100 Subject: TimerEntry.py: dont ask to select subservice when just one subservice is available --- lib/python/Screens/TimerEntry.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Screens/TimerEntry.py b/lib/python/Screens/TimerEntry.py index 73b2175b..edd19685 100644 --- a/lib/python/Screens/TimerEntry.py +++ b/lib/python/Screens/TimerEntry.py @@ -310,9 +310,9 @@ class TimerEntry(Screen, ConfigListScreen): if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) - if event is not None: + if event: n = event.getNumOfLinkageServices() - if n > 0: + if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceReference() parent = self.timer.service_ref.ref @@ -324,7 +324,9 @@ class TimerEntry(Screen, ConfigListScreen): tlist.append((i.getName(), i)) self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list = tlist, selection = selection) return - + elif n > 0: + parent = self.timer.service_ref.ref + self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) -- cgit v1.2.3