def doAction(self, action): self.standbyblocked = 1 if action == "shutdown": self.shutdown() elif action == "show_menu": print "Show shutdown Menu" root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == "shutdown": self.session.infobar = self menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, x) menu_screen.setTitle(_("Standby / restart")) return elif action == "standby": self.standby() elif action == "powertimerStandby": val = 3 self.setSleepTimer(val) elif action == "powertimerDeepStandby": val = 4 self.setSleepTimer(val) elif action == "sleeptimer": self.openSleepTimer()
def showSetup(self): from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == "setup": self.session.infobar = self self.session.open(MainMenu, x) return
def showSetup(self): from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall('menu'): y = x.find('id') if y is not None: id = y.get('val') if id and id == 'setup': self.session.infobar = self self.session.open(MainMenu, x) return return
def actionConfirmed(self, action, retval): if retval: entry = ACTIONLIST[action] if entry['type'] == 'code': if entry['args']: exec entry['args'] in globals(), locals() elif entry['type'] == 'screen': screen = entry.get('screen') if screen: module = entry.get('module') if module: exec 'from ' + module + ' import ' + screen in globals(), locals() self.session.open(*eval(screen + ', ' + entry['args'])) elif entry['type'] == 'setup': from Screens.Setup import Setup self.session.open(Setup, entry.get('target', '')) elif entry['type'] in ('menu', 'menuitem'): from Screens.Menu import MainMenu, mdom def findMenuOrItem(node, val, findwhat): result = None for x in node: if x.tag == 'menu': result = findMenuOrItem(x, val, findwhat) elif findwhat == 'menu' and x.tag == 'id' and x.get('val') == val: result = node elif findwhat == 'menuitem' and x.tag == 'item' and x.get('entryID') == val: result = x if not result is None: break return result root = mdom.getroot() node = findMenuOrItem(root, entry.get('target', ''), entry['type']) if entry['type'] == 'menu': self.session.open(MainMenu, node or root) elif not node is None: execstr = openstr = '' for x in node: if x.tag == 'screen': module = x.get("module") openstr = x.get("screen", module) + ", " + (x.text or "") execstr = module and "from Screens." + module + " import *" or "" elif x.tag == 'code': execstr = x.text elif x.tag == 'setup': execstr = "from Screens.Setup import Setup" openstr = "Setup, " + x.get('id') if execstr or openstr: break if execstr: exec execstr in globals(), locals() if openstr: self.session.open(*eval(openstr))
def doAction(self, selected): if selected: selected = selected.split("/") if selected[0] == "Module": try: exec "from " + selected[1] + " import *" exec "self.session.open(" + ",".join(selected[2:]) + ")" except: print "[mytest] error during executing module %s, screen %s" % (selected[1], selected[2]) elif selected[0] == "Menu": from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == selected[1]: self.session.open(MainMenu, x)
def powerlong(self): if Screens.Standby.inTryQuitMainloop or (self.session.current_dialog and not self.session.current_dialog.ALLOW_SUSPEND): return self.standbyblocked = 1 action = config.usage.on_long_powerpress.value if action == "shutdown": self.shutdown() elif action == "show_menu": print "Show shutdown Menu" root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == "shutdown": self.session.infobar = self menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, x) menu_screen.setTitle(_("Standby / Restart")) return
def doAction(self, selected, longkey=False): if self.longkeyPressed: self.longkeyPressed = False elif selected and self.session.infobar: if longkey: self.longkeyPressed = True selected = selected.split("/") if selected[0] == "Module": try: exec "from " + selected[1] + " import *" exec "self.session.open(" + ",".join(selected[2:]) + ")" except: print "[mytest] error during executing module %s, screen %s" % (selected[1], selected[2]) elif selected[0] == "Menu": from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == selected[1]: menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, x) return
def doAction(self, action): self.standbyblocked = 1 if action == "shutdown": self.shutdown() elif action == "show_menu": print "Show shutdown Menu" root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == "shutdown": self.session.infobar = self menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, x) menu_screen.setTitle(_("Standby / restart")) return elif action == "standby": try: config.hdmicec.control_tv_standby_skipnow.setValue(False) except: pass # no HdmiCec self.standby() elif action == "standby_noTVshutdown": try: config.hdmicec.control_tv_standby_skipnow.setValue(True) except: pass # no HdmiCec self.standby() elif action == "powertimerStandby": val = 3 self.setSleepTimer(val) elif action == "powertimerDeepStandby": val = 4 self.setSleepTimer(val) elif action == "sleeptimer": self.openSleepTimer()
def doAction(self, action): self.standbyblocked = 1 if action == "shutdown": self.shutdown() elif action == "show_menu": print "Show shutdown Menu" root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == "shutdown": self.session.infobar = self menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, x) menu_screen.setTitle(_("Standby / Restart")) return elif action == "standby": self.standby() elif action == "restart": self.restart() elif action == "restart_gui": self.restart_gui() elif action =="nothing": print "PowerButton pressed --> no function configured"
def execButtonSetup(self, selected): if selected: selected = selected[1].split("/") if selected[0] == "Plugins": twinPlugins = [] twinPaths = {} pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames: if plugin.path[24:] in twinPaths: twinPaths[plugin.path[24:]] += 1 else: twinPaths[plugin.path[24:]] = 1 if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU]) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path: if plugin.path[24:] in twinPaths: twinPaths[plugin.path[24:]] += 1 else: twinPaths[plugin.path[24:]] = 1 if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) elif selected[0] == "MenuPlugin": for plugin in plugins.getPluginsForMenu(selected[1]): if plugin[2] == selected[2]: self.runPlugin(plugin[1]) return elif selected[0] == "Infobar": if hasattr(self, selected[1]): exec "self." + ".".join(selected[1:]) + "()" else: return 0 elif selected[0] == "Module": try: exec "from " + selected[1] + " import *" exec "self.session.open(" + ",".join(selected[2:]) + ")" except: print "[ButtonSetup] error during executing module %s, screen %s" % (selected[1], selected[2]) elif selected[0] == "Setup": exec "from Screens.Setup import *" exec "self.session.open(Setup, \"" + selected[1] + "\")" elif selected[0].startswith("Zap"): if selected[0] == "ZapPanic": self.servicelist.history = [] self.pipShown() and self.showPiP() self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:]))) self.servicelist.zap(enable_pipzap = True) if hasattr(self, "lastservice"): self.lastservice = eServiceReference("/".join(selected[1:])) self.close() else: self.show() from Screens.MovieSelection import defaultMoviePath moviepath = defaultMoviePath() if moviepath: config.movielist.last_videodir.value = moviepath elif selected[0] == "Menu": from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == selected[1]: menu_screen = self.session.open(MainMenu, x) break
def execHotkey(self, selected): if selected: selected = selected[1].split("/") if selected[0] == "Plugins": twinPlugins = [] twinPaths = {} pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames: if twinPaths.has_key(plugin.path[24:]): twinPaths[plugin.path[24:]] += 1 else: twinPaths[plugin.path[24:]] = 1 if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU]) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path: if twinPaths.has_key(plugin.path[24:]): twinPaths[plugin.path[24:]] += 1 else: twinPaths[plugin.path[24:]] = 1 if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) elif selected[0] == "MenuPlugin": for plugin in plugins.getPluginsForMenu(selected[1]): if plugin[2] == selected[2]: self.runPlugin(plugin[1]) return elif selected[0] == "Infobar": if hasattr(self, selected[1]): exec "self." + ".".join(selected[1:]) + "()" else: return 0 elif selected[0] == "Module": try: exec "from " + selected[1] + " import *" exec "self.session.open(" + ",".join(selected[2:]) + ")" except: print "[Hotkey] error during executing module %s, screen %s" % (selected[1], selected[2]) elif selected[0] == "Setup": exec "from Screens.Setup import *" exec "self.session.open(Setup, \"" + selected[1] + "\")" elif selected[0].startswith("Zap"): if selected[0] == "ZapPanic": self.servicelist.history = [] self.pipShown() and self.showPiP() self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:]))) self.servicelist.zap(enable_pipzap = True) if hasattr(self, "lastservice"): self.lastservice = eServiceReference("/".join(selected[1:])) self.close() else: self.show() from Screens.MovieSelection import defaultMoviePath moviepath = defaultMoviePath() if moviepath: config.movielist.last_videodir.value = moviepath elif selected[0] == "PPanel": ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml" if os.path.isfile(ppanelFileName) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'): from Plugins.Extensions.PPanel.ppanel import PPanel self.session.open(PPanel, name=selected[1] + ' PPanel', node=None, filename=ppanelFileName, deletenode=None) elif selected[0] == "Shellscript": command = '/usr/script/' + selected[1] + ".sh" if os.path.isfile(command) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'): from Plugins.Extensions.PPanel.ppanel import Execute self.session.open(Execute, selected[1] + " shellscript", None, command) elif selected[0] == "Menu": from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == selected[1]: menu_screen = self.session.open(MainMenu, x) break
def main(session, *args, **kwargs): session.open(SortableMenu, mdom.getroot())
def execHotkey(self, selected): if selected: selected = selected[1].split("/") if selected[0] == "Plugins": twinPlugins = [] twinPaths = {} pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames: if plugin.path[24:] in twinPaths: twinPaths[plugin.path[24:]] += 1 else: twinPaths[plugin.path[24:]] = 1 if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU]) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path: if plugin.path[24:] in twinPaths: twinPaths[plugin.path[24:]] += 1 else: twinPaths[plugin.path[24:]] = 1 if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) elif selected[0] == "MenuPlugin": for plugin in plugins.getPluginsForMenu(selected[1]): if plugin[2] == selected[2]: self.runPlugin(plugin[1]) return elif selected[0] == "Infobar": if hasattr(self, selected[1]): exec "self." + ".".join(selected[1:]) + "()" else: return 0 elif selected[0] == "Module": try: exec "from " + selected[1] + " import *" exec "self.session.open(" + ",".join(selected[2:]) + ")" except: print "[Hotkey] error during executing module %s, screen %s" % (selected[1], selected[2]) elif selected[0] == "Setup": exec "from Screens.Setup import *" exec "self.session.open(Setup, \"" + selected[1] + "\")" elif selected[0].startswith("Zap"): if selected[0] == "ZapPanic": self.servicelist.history = [] self.pipShown() and self.showPiP() self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:]))) self.servicelist.zap(enable_pipzap = True) if hasattr(self, "lastservice"): self.lastservice = eServiceReference("/".join(selected[1:])) self.close() else: self.show() from Screens.MovieSelection import defaultMoviePath moviepath = defaultMoviePath() if moviepath: config.movielist.last_videodir.value = moviepath elif selected[0] == "PPanel": ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml" if os.path.isfile(ppanelFileName) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'): from Plugins.Extensions.PPanel.ppanel import PPanel self.session.open(PPanel, name=selected[1] + ' PPanel', node=None, filename=ppanelFileName, deletenode=None) elif selected[0] == "Shellscript": command = '/usr/script/' + selected[1] + ".sh" if os.path.isfile(command) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'): from Plugins.Extensions.PPanel.ppanel import Execute self.session.open(Execute, selected[1] + " shellscript", None, command) elif selected[0] == "Menu": from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == selected[1]: menu_screen = self.session.open(MainMenu, x) break
def execButtonSetup(self, selected): if selected: selected = selected[1].split("/") if selected[0] == "Plugins": twinPlugins = [] twinPaths = {} pluginlist = plugins.getPlugins( PluginDescriptor.WHERE_EVENTINFO) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames: if twinPaths.has_key( plugin.path[plugin.path.rfind("Plugins"):]): twinPaths[plugin.path[plugin.path.rfind("Plugins" ):]] += 1 else: twinPaths[ plugin.path[plugin.path.rfind("Plugins"):]] = 1 if plugin.path[ plugin.path.rfind("Plugins"):] + "/" + str( twinPaths[plugin.path[plugin.path.rfind( "Plugins"):]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) pluginlist = plugins.getPlugins([ PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU ]) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path: if twinPaths.has_key( plugin.path[plugin.path.rfind("Plugins"):]): twinPaths[plugin.path[plugin.path.rfind("Plugins" ):]] += 1 else: twinPaths[ plugin.path[plugin.path.rfind("Plugins"):]] = 1 if plugin.path[ plugin.path.rfind("Plugins"):] + "/" + str( twinPaths[plugin.path[plugin.path.rfind( "Plugins"):]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) elif selected[0] == "MenuPlugin": for plugin in plugins.getPluginsForMenu(selected[1]): if plugin[2] == selected[2]: self.runPlugin(plugin[1]) return elif selected[0] == "Infobar": if hasattr(self, selected[1]): exec "self." + ".".join(selected[1:]) + "()" else: return 0 elif selected[0] == "Module": try: exec "from " + selected[1] + " import *" exec "self.session.open(" + ",".join(selected[2:]) + ")" except Exception as e: print "[ButtonSetup] error during executing module %s, screen %s, %s" % ( selected[1], selected[2], e) import traceback traceback.print_exc() elif selected[0] == "Setup": exec "from Screens.Setup import *" exec "self.session.open(Setup, \"" + selected[1] + "\")" elif selected[0].startswith("Zap"): if selected[0] == "ZapPanic": self.servicelist.history = [] self.pipShown() and self.showPiP() self.servicelist.servicelist.setCurrent( eServiceReference("/".join(selected[1:]))) self.servicelist.zap(enable_pipzap=True) if hasattr(self, "lastservice"): self.lastservice = eServiceReference("/".join( selected[1:])) self.close() else: self.show() from Screens.MovieSelection import defaultMoviePath moviepath = defaultMoviePath() if moviepath: config.movielist.last_videodir.value = moviepath elif selected[0] == "Script": command = '/usr/script/' + selected[1] + ".sh" from Screens.Console import Console exec "self.session.open(Console,_(selected[1]),[command])" elif selected[0] == "Menu": from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == selected[1]: menu_screen = self.session.open(MainMenu, x) break
def execHotkey(self, selected): if selected: selected = selected[1].split("/") if selected[0] == "Plugins": twinPlugins = [] twinPaths = {} pluginlist = plugins.getPlugins( PluginDescriptor.WHERE_EVENTINFO) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames: if plugin.path[24:] in twinPaths: twinPaths[plugin.path[24:]] += 1 else: twinPaths[plugin.path[24:]] = 1 if plugin.path[24:] + "/" + str(twinPaths[ plugin.path[24:]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) pluginlist = plugins.getPlugins([ PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU ]) pluginlist.sort(key=lambda p: p.name) for plugin in pluginlist: if plugin.name not in twinPlugins and plugin.path: if plugin.path[24:] in twinPaths: twinPaths[plugin.path[24:]] += 1 else: twinPaths[plugin.path[24:]] = 1 if plugin.path[24:] + "/" + str(twinPaths[ plugin.path[24:]]) == "/".join(selected): self.runPlugin(plugin) return twinPlugins.append(plugin.name) elif selected[0] == "MenuPlugin": for plugin in plugins.getPluginsForMenu(selected[1]): if plugin[2] == selected[2]: self.runPlugin(plugin[1]) return elif selected[0] == "Infobar": if hasattr(self, selected[1]): exec "self." + ".".join(selected[1:]) + "()" else: return 0 elif selected[0] == "Module": try: exec "from %s import %s" % (selected[1], selected[2]) exec "self.session.open(%s)" % ",".join(selected[2:]) except Exception as e: print "[Hotkey] error during executing module %s, screen %s, %s" % ( selected[1], selected[2], e) import traceback traceback.print_exc() elif selected[0] == "SoftcamSetup" and SystemInfo[ "HasSoftcamInstalled"]: from Screens.SoftcamSetup import SoftcamSetup self.session.open(SoftcamSetup) elif selected[0] == "Setup": from Screens.Setup import Setup exec "self.session.open(Setup, \"%s\")" % selected[1] elif selected[0].startswith("Zap"): if selected[0] == "ZapPanic": self.servicelist.history = [] self.pipShown() and self.showPiP() self.servicelist.servicelist.setCurrent( eServiceReference("/".join(selected[1:]))) self.servicelist.zap(enable_pipzap=True) if hasattr(self, "lastservice"): self.lastservice = eServiceReference("/".join( selected[1:])) self.close() else: self.show() from Screens.MovieSelection import defaultMoviePath moviepath = defaultMoviePath() if moviepath: config.movielist.last_videodir.value = moviepath elif selected[0] == "PPanel": ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml" if os.path.isfile(ppanelFileName) and os.path.isdir( resolveFilename(SCOPE_PLUGINS, 'Extensions/PPanel')): from Plugins.Extensions.PPanel.ppanel import PPanel self.session.open(PPanel, name=selected[1] + ' PPanel', node=None, filename=ppanelFileName, deletenode=None) elif selected[0] == "Shellscript": command = '/usr/script/' + selected[1] + ".sh" if os.path.isfile(command): if ".hidden." in command: from enigma import eConsoleAppContainer eConsoleAppContainer().execute(command) else: from Screens.Console import Console self.session.open( Console, selected[1] + " shellscript", command, closeOnSuccess=selected[1].startswith('!'), showStartStopText=False) elif selected[0] == "Menu": from Screens.Menu import MainMenu, mdom root = mdom.getroot() for x in root.findall("menu"): y = x.find("id") if y is not None: id = y.get("val") if id and id == selected[1]: menu_screen = self.session.open(MainMenu, x) break