def __init__(self, session): Screen.__init__(self, session) self.session = session self.selection = 0 self.imagesList = {} self.setIndex = 0 self.expanded = [] config.plugins.softwaremanager.restoremode = ConfigSelection([ ("turbo", _("turbo")), ("fast", _("fast")), ("slow", _("slow")), ], "turbo") Screen.setTitle(self, _("Flash On the Fly")) self["key_red"] = Button("Cancel") self["key_green"] = Button() self["key_yellow"] = Button() self["key_blue"] = Button() self["description"] = StaticText() self["list"] = ChoiceList(list=[ ChoiceEntryComponent('', ( (_("Retrieving image list - Please wait...")), "Waiter")) ]) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "ok": self.keyOk, "cancel": boundFunction(self.close, None), "red": boundFunction(self.close, None), "green": self.keyOk, "yellow": self.keyDelete, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self.delay = eTimer() self.delay.callback.append(self.getImagesList) self.delay.start(0, True)
def __init__(self, session, key, args=None): Screen.__init__(self, session) self.skinName = "ButtonSetupSelect" self['description'] = Label( _('Select the desired function and click on "OK" to assign it. Use "CH+/-" to toggle between the lists. Select an assigned function and click on "OK" to de-assign it. Use "Next/Previous" to change the order of the assigned functions.' )) self.session = session self.key = key self.setTitle(_("Hotkey Setup for") + ": " + key[0][0]) self["key_red"] = Button(_("Cancel")) self["key_green"] = Button(_("Save")) self.mode = "list" self.ButtonSetupFunctions = getButtonSetupFunctions() self.config = eval("config.misc.ButtonSetup." + key[0][1]) self.expanded = [] self.selected = [] for x in self.config.value.split(','): function = list(function for function in self.ButtonSetupFunctions if function[1] == x) if function: self.selected.append( ChoiceEntryComponent('', ((function[0][0]), function[0][1]))) self.prevselected = self.selected[:] self["choosen"] = ChoiceList(list=self.selected, selection=0) self["list"] = ChoiceList(list=self.getFunctionList(), selection=0) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions" ], { "ok": self.keyOk, "cancel": self.cancel, "red": self.cancel, "green": self.save, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "pageUp": self.toggleMode, "pageDown": self.toggleMode, "shiftUp": self.moveUp, "shiftDown": self.moveDown, }, -1) self.onShown.append(self.enableKeyMap) self.onClose.append(self.disableKeyMap) self.onLayoutFinish.append(self.__layoutFinished)
def SPChannelContextMenu__init__(self, session, csel): from Components.ChoiceList import ChoiceEntryComponent from Screens.ChannelSelection import MODE_TV from Tools.BoundFunction import boundFunction from enigma import eServiceReference ChannelContextMenu__init__(self, session, csel) current = csel.getCurrentSelection() current_sel_path = current.getPath() current_sel_flags = current.flags if csel.mode == MODE_TV and not ( current_sel_path or current_sel_flags & (eServiceReference.isDirectory | eServiceReference.isMarker)): from Plugins.Extensions.SeriesPlugin.plugin import SHOWINFO self["menu"].list.insert( 0, ChoiceEntryComponent( text=(SHOWINFO, boundFunction(self.SPchannelShowSeriesInfo))))
def keyDelete(self): currentSelected = self["list"].l.getCurrentSelection()[0][1] if not ("://" in currentSelected or currentSelected in ["Expander", "Waiter"]): os.remove(currentSelected) currentSelected = ".".join([currentSelected[:-4], "unzipped"]) if os.path.isdir(currentSelected): import shutil shutil.rmtree(currentSelected) self.setIndex = self["list"].getSelectedIndex() self.imagesList = [] self["list"].setList([ ChoiceEntryComponent( '', ((_("Refreshing image list - Please wait...")), "Waiter")) ]) self.delay.start(0, True)
def getFunctions(self): key = self["list"].getCurrent()[0][1] if key: selected = [] # for button in eval("config.misc.ButtonSetup." + key + ".value.split(',')"): for button in [ x.strip() for x in getattr(config.misc.ButtonSetup, key).value.split(",") ]: function = list(function for function in self.ButtonSetupFunctions if function[1] == button) if function: selected.append( ChoiceEntryComponent( "dummy", ((function[0][0]), function[0][1]))) self["choosen"].setList(selected)
def EPGRefreshChannelContextMenu__init__(self, session, csel): baseChannelContextMenu__init__(self, session, csel) if csel.mode == MODE_TV: current = csel.getCurrentSelection() current_root = csel.getRoot() current_sel_path = current.getPath() current_sel_flags = current.flags inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK inBouquet = csel.getMutableList() is not None isPlayable = not (current_sel_flags & (eServiceReference.isMarker|eServiceReference.isDirectory)) if csel.bouquet_mark_edit == OFF and not csel.movemode and current and current.valid(): if isPlayable: profile = config.plugins.epgrefresh.add_to_refresh.value if profile == "2" or profile == "3": callFunction = self.addtoEPGRefresh self["menu"].list.insert(2, ChoiceEntryComponent(text = (_("add service to EPGRefresh"), boundFunction(callFunction,1)))) else: pass
def setDefaultChoiceListCallback(self, answer): if answer: inputKeys = self.initialKeys + (len(self.initialList) - len(self.initialKeys)) * ["dummy"] pos = 0 list = [] for item in self.initialList: if item: list.append( ChoiceEntryComponent(key=str(inputKeys[pos]), text=item)) pos += 1 self.list = list self["list"].setList(list) self.configType.value = "" self.configType.save() self["resetActions"].setEnabled(False) self["key_text"].setText("")
def __init__(self, session, menu_path="", args=None): Screen.__init__(self, session) screentitle = _("Button setup") if config.usage.show_menupath.value == 'large': menu_path += screentitle title = menu_path self["menu_path_compressed"] = StaticText("") elif config.usage.show_menupath.value == 'small': title = screentitle self["menu_path_compressed"] = StaticText( menu_path + " >" if not menu_path.endswith(' / ') else menu_path[:-3] + " >" or "") else: title = screentitle self["menu_path_compressed"] = StaticText("") Screen.setTitle(self, title) self['description'] = Label( _('Click on your remote on the button you want to change')) self.session = session self.setTitle(_("Hotkey Setup")) self["key_red"] = Button(_("Exit")) self.list = [] self.ButtonSetupKeys = getButtonSetupKeys() self.ButtonSetupFunctions = getButtonSetupFunctions() for x in self.ButtonSetupKeys: self.list.append(ChoiceEntryComponent('', (_(x[0]), x[1]))) self["list"] = ChoiceList( list=self.list[:config.misc.ButtonSetup.additional_keys. value and len(self.ButtonSetupKeys) or 10], selection=0) self["choosen"] = ChoiceList(list=[]) self.getFunctions() self["actions"] = ActionMap(["OkCancelActions"], { "cancel": self.close, }, -1) self["ButtonSetupButtonActions"] = ButtonSetupActionMap( ["ButtonSetupActions"], dict((x[1], self.ButtonSetupGlobal) for x in self.ButtonSetupKeys)) self.longkeyPressed = False self.onLayoutFinish.append(self.__layoutFinished) self.onExecBegin.append(self.getFunctions) self.onShown.append(self.disableKeyMap) self.onClose.append(self.enableKeyMap)
def __init__(self, session): Screen.__init__(self, session) self.session = session self.selection = 0 self.jsonlist = {} self.imagesList = {} self.setIndex = 0 self.expanded = [] self.customDirs = ["images", "backup", "backups", "full_backups"] Screen.setTitle(self, _("Flash On the Fly")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText() self["key_yellow"] = StaticText() self["key_blue"] = StaticText() self["description"] = StaticText() self["list"] = ChoiceList(list=[ ChoiceEntryComponent('', ( (_("Retrieving image list - Please wait...")), "Waiter")) ]) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "ok": self.keyOk, "cancel": boundFunction(self.close, None), "red": boundFunction(self.close, None), "green": self.keyOk, "yellow": self.keyDelete, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self.delay = eTimer() self.delay.callback.append(self.getImagesList) self.delay.start(0, True)
def __init__(self, session, *args): Screen.__init__(self, session) self.skinName = "MultiBoot" screentitle = _("Multiboot Image Restart") self["key_red"] = StaticText(_("Cancel")) self["labe14"] = StaticText( _("Use the cursor keys to select an installed image and then Reboot button." )) self["labe15"] = StaticText(_(" ")) self["key_green"] = StaticText(_("Reboot")) if SystemInfo["canMode12"]: self["labe15"] = StaticText( _("Mode 1 suppports Kodi, PiP may not work.\nMode 12 supports PiP, Kodi may not work." )) self["config"] = ChoiceList(list=[ ChoiceEntryComponent('', ( (_("Retrieving image slots - Please wait...")), "Queued")) ]) imagedict = [] self.getImageList = None self.title = screentitle self.startit() self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "red": boundFunction(self.close, None), "green": self.reboot, "ok": self.reboot, "cancel": boundFunction(self.close, None), "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session, key, args=None): Screen.__init__(self, session) self.key = key # self.skinName = "ButtonSetupSelect" self.setTitle("%s: %s" % (_("Hotkey Settings"), key[0][0])) self["description"] = Label( _("Select the desired function and click on 'OK' to assign it. Use 'CH+/-' to toggle between the lists. Select an assigned function and click on 'OK' to deassign it. Use 'NEXT/PREVIOUS' to change the order of the assigned functions." )) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Save")) self.mode = "list" self.ButtonSetupFunctions = getButtonSetupFunctions() # self.config = eval("config.misc.ButtonSetup." + key[0][1]) self.config = getattr(config.misc.ButtonSetup, key[0][1]) self.expanded = [] self.selected = [] for button in self.config.value.split(","): function = list(function for function in self.ButtonSetupFunctions if function[1] == button) if function: self.selected.append( ChoiceEntryComponent("dummy", ((function[0][0]), function[0][1]))) self.prevSelected = self.selected[:] self["choosen"] = ChoiceList(list=self.selected, selection=0) self["list"] = ChoiceList(list=self.getFunctionList(), selection=0) self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions"], { # No help available, HELP is a changeable button! "ok": self.keyOk, "cancel": self.cancel, "red": self.cancel, "green": self.save, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "pageUp": self.toggleMode, "pageDown": self.toggleMode, "moveUp": self.moveUp, "moveDown": self.moveDown, }, prio=-1) self.onShown.append(self.enableKeyMap) self.onClose.append(self.disableKeyMap) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session): Screen.__init__(self, session) self.skinName = "MultiBoot" self.setTitle(_("Multiboot image manager")) self.title = screentitle self["key_red"] = StaticText(_("Cancel")) self["labe14"] = StaticText( _("Use the cursor keys to select an installed image and then Erase button." )) self["labe15"] = StaticText( _("Note: slot list does not show current image or empty slots.")) self["key_green"] = StaticText(_("Erase")) self["key_yellow"] = StaticText("") self["config"] = ChoiceList(list=[ ChoiceEntryComponent('', ( (_("Retrieving image slots - Please wait...")), "Queued")) ]) imagedict = [] self.getImageList = None self.startit() self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "red": boundFunction(self.close, None), "green": self.erase, "yellow": boundFunction(self.close, None), "ok": self.erase, "cancel": boundFunction(self.close, None), "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session, key, args=None): Screen.__init__(self, session) self['description'] = Label(_('Select the desired function and click on OK to assign it. Use CH+/- to toggle between the lists. Select an assigned function and click on OK to de-assign it.')) self.skinName = "ButtonSetupSelect" self.session = session self.key = key self.setTitle(_("Hotkey Setup") + " " + key[0][0]) self["key_red"] = Button(_("Cancel")) self["key_green"] = Button(_("Save")) self.mode = "list" self.hotkeyFunctions = getHotkeyFunctions() self.config = getattr(config.misc.hotkey, key[0][1]) self.expanded = [] self.selected = [] for x in self.config.value.split(','): function = next((function for function in self.hotkeyFunctions if function[1] == x), None) if function: self.selected.append(ChoiceEntryComponent('', ((function[0]), function[1]))) self.prevselected = self.selected[:] self["choosen"] = ChoiceList(list=self.selected, selection=0) self["list"] = ChoiceList(list=self.getFunctionList(), selection=0) self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions"], { "ok": self.keyOk, "cancel": self.cancel, "red": self.cancel, "green": self.save, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "pageUp": self.toggleMode, "pageDown": self.toggleMode, "moveUp": self.moveUp, "moveDown": self.moveDown }, -1) self.onLayoutFinish.append(self.__layoutFinished)
def __init__(self, session, args=None): Screen.__init__(self, session) self.session = session self.setTitle(_("Hotkey Setup")) self["key_red"] = Button(_("Exit")) self["key_green"] = Button(_("Toggle Extra Keys")) self.list = [] self.hotkeys = getHotkeys() self.hotkeyFunctions = getHotkeyFunctions() for x in self.hotkeys: self.list.append(ChoiceEntryComponent('', (x[0], x[1]))) self["list"] = ChoiceList( list=self.list[:config.misc.hotkey.additional_keys. value and len(self.hotkeys) or 12], selection=0) self["choosen"] = ChoiceList(list=[]) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "MenuActions" ], { "ok": self.keyOk, "cancel": self.close, "red": self.close, "green": self.toggleAdditionalKeys, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self["NumberActions"] = NumberActionMap(["NumberActions"], {"0": self.keyNumberGlobal}) self["HotkeyButtonActions"] = hotkeyActionMap( ["HotkeyActions"], dict((x[1], self.hotkeyGlobal) for x in self.hotkeys)) self.longkeyPressed = False self.onLayoutFinish.append(self.__layoutFinished) self.onExecBegin.append(self.getFunctions)
def __init__(self, session, *args): Screen.__init__(self, session) self.session = session self.jsonlist = {} self.imagesList = {} self.setIndex = 0 self.expanded = [] self.setTitle(_("Multiboot image selector")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText() self["key_yellow"] = StaticText() self["key_blue"] = StaticText() self["description"] = StaticText() self["list"] = ChoiceList(list=[ ChoiceEntryComponent('', ( (_("Retrieving image list - Please wait...")), "Waiter")) ]) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "ok": self.keyOk, "cancel": boundFunction(self.close, None), "red": boundFunction(self.close, None), "green": self.keyOk, "yellow": self.keyDelete, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self.callLater(self.getImagesList)
def __init__(self, session, key, args=None): Screen.__init__(self, session) self.skinName = "HotkeySetupSelect" self.session = session self.key = key self.setTitle(_("Button setup for") + ": " + key[0][0]) self["key_red"] = Button(_("Cancel")) self["key_green"] = Button(_("Save")) self.mode = "list" self.hotkeyFunctions = getHotkeyFunctions() self.config = eval("config.misc.hotkey." + key[0][1]) self.expanded = [] self.selected = [] for x in self.config.value.split(','): function = list(function for function in self.hotkeyFunctions if function[1] == x) if function: self.selected.append( ChoiceEntryComponent('', ((function[0][0]), function[0][1]))) self.prevselected = self.selected[:] self["choosen"] = ChoiceList(list=self.selected, selection=0) self["list"] = ChoiceList(list=self.getFunctionList(), selection=0) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions" ], { "ok": self.keyOk, "cancel": self.cancel, "red": self.cancel, "green": self.save, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "pageUp": self.toggleMode, "pageDown": self.toggleMode }, -1) self.onLayoutFinish.append(self.__layoutFinished)
def __init__(self, session, *args): Screen.__init__(self, session) self.skinName = "ChoiceBox" self.session = session self.imagesList = None self.expanded = [] self.setTitle(_("Select Multiboot")) self["key_red"] = Button(_("Cancel")) self["key_green"] = Button(_("Reboot")) self["list"] = ChoiceList(list=[ ChoiceEntryComponent('', ( (_("Retreiving image slots - Please wait...")), "Waiter")) ]) self["h_red"] = Pixmap() self["h_green"] = Pixmap() self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "ok": self.keyOk, "cancel": boundFunction(self.close, None), "red": boundFunction(self.close, None), "green": self.keyOk, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self.delay = eTimer() self.delay.callback.append(self.getImagesList) self.delay.start(0, True)
def __init__(self, session, *args): Screen.__init__(self, session) screentitle = _("Multiboot Image Selector") self["key_red"] = StaticText(_("Cancel")) if not SystemInfo["HasSDmmc"] or SystemInfo["HasSDmmc"] and pathExists('/dev/%s4' %(SystemInfo["canMultiBoot"][2])): self["description"] = StaticText(_("Use the cursor keys to select an installed image and then Reboot button.")) else: self["description"] = StaticText(_("SDcard is not initialised for multiboot - Exit and use MultiBoot Image Manager to initialise")) self["options"] = StaticText(_(" ")) self["key_green"] = StaticText(_("Reboot")) if SystemInfo["canMode12"]: self["options"] = StaticText(_("Mode 1 suppports Kodi, PiP may not work.\nMode 12 supports PiP, Kodi may not work.")) self["config"] = ChoiceList(list=[ChoiceEntryComponent('',((_("Retrieving image slots - Please wait...")), "Queued"))]) imagedict = [] self.mtdboot = "%s1" % SystemInfo["canMultiBoot"][2] if SystemInfo["canMultiBoot"][2] == "sda": self.mtdboot = "%s3" %getMachineMtdRoot()[0:8] self.getImageList = None self.title = screentitle if not SystemInfo["HasSDmmc"] or SystemInfo["HasSDmmc"] and pathExists('/dev/%s4' %(SystemInfo["canMultiBoot"][2])): self.startit() self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions"], { "red": boundFunction(self.close, None), "green": self.reboot, "ok": self.reboot, "cancel": boundFunction(self.close, None), "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self.onLayoutFinish.append(self.layoutFinished)
def keyDelete(self): currentSelected = self["list"].l.getCurrentSelection()[0][1] if not ("://" in currentSelected or currentSelected in ["Expander", "Waiter"]): try: os.remove(currentSelected) currentSelected = ".".join([currentSelected[:-4], "unzipped"]) if os.path.isdir(currentSelected): shutil.rmtree(currentSelected) self.setIndex = self["list"].getSelectedIndex() self.imagesList = [] self["list"].setList([ ChoiceEntryComponent( '', ((_("Refreshing image list - Please wait...")), "Waiter")) ]) self.delay.start(0, True) except: self.session.open(MessageBox, _("Cannot delete downloaded image"), MessageBox.TYPE_ERROR, timeout=3)
def AutoTimerChannelContextMenu__init__(self, session, csel): baseChannelContextMenu__init__(self, session, csel) if csel.mode == MODE_TV: current = csel.getCurrentSelection() current_root = csel.getRoot() current_sel_path = current.getPath() current_sel_flags = current.flags inBouquetRootList = current_root and current_root.getPath().find( 'FROM BOUQUET "bouquets.') != -1 #FIXME HACK inBouquet = csel.getMutableList() is not None isPlayable = not ( current_sel_flags & (eServiceReference.isMarker | eServiceReference.isDirectory)) if csel.bouquet_mark_edit == OFF and not csel.movemode: if isPlayable: if config.plugins.autotimer.add_to_channelselection.value: callFunction = self.addtoAutoTimer self["menu"].list.insert( 3, ChoiceEntryComponent( text=(_("create AutoTimer for current event"), boundFunction(callFunction, 1))))
def __init__(self, session): Screen.__init__(self, session) self.setTitle(_("Button Setup")) self['description'] = Label(_('On your remote, click on the button you want to change')) self.session = session self.list = [] self.ButtonSetupFunctions = getButtonSetupFunctions() for x in ButtonSetupKeys: self.list.append(ChoiceEntryComponent('',(_(x[0]), x[1]))) self["list"] = ChoiceList(list=self.list[:config.misc.ButtonSetup.additional_keys.value and len(ButtonSetupKeys) or 10], selection = 0) self["choosen"] = ChoiceList(list=[]) self.getFunctions() self["actions"] = ActionMap(["OkCancelActions"], { "cancel": self.close, }, -1) self["ButtonSetupButtonActions"] = ButtonSetupActionMap(["ButtonSetupActions"], dict((x[1], self.ButtonSetupGlobal) for x in ButtonSetupKeys)) self.longkeyPressed = False self.onLayoutFinish.append(self.__layoutFinished) self.onExecBegin.append(self.getFunctions) self.onShown.append(self.disableKeyMap) self.onClose.append(self.enableKeyMap)
def getImagesList(self): list = [] imagesList = getImagelist() mode = getCurrentImageMode() or 0 self.deletedImagesExists = False if imagesList: for index, x in enumerate(sorted(imagesList.keys())): if imagesList[x]["imagename"] == _("Deleted image"): self.deletedImagesExists = True elif imagesList[x]["imagename"] != _("Empty slot"): if SystemInfo["canMode12"]: list.insert( index, ChoiceEntryComponent( '', ((_("slot%s - %s mode 1 (current image)") if x == self.currentimageslot and mode != 12 else _("slot%s - %s mode 1")) % (x, imagesList[x]['imagename']), (x, 1)))) list.append( ChoiceEntryComponent( '', ((_("slot%s - %s mode 12 (current image)") if x == self.currentimageslot and mode == 12 else _("slot%s - %s mode 12")) % (x, imagesList[x]['imagename']), (x, 12)))) else: list.append( ChoiceEntryComponent( '', ((_("slot%s - %s (current image)") if x == self.currentimageslot and mode != 12 else _("slot%s - %s")) % (x, imagesList[x]['imagename']), (x, 1)))) if os.path.isfile(os.path.join(self.tmp_dir, "STARTUP_RECOVERY")): list.append( ChoiceEntryComponent( '', ((_("Boot to Recovery menu")), "Recovery"))) if os.path.isfile(os.path.join(self.tmp_dir, "STARTUP_ANDROID")): list.append( ChoiceEntryComponent( '', ((_("Boot to Android image")), "Android"))) if not list: list.append( ChoiceEntryComponent('', ((_("No images found")), "Waiter"))) self["list"].setList(list) self.selectionChanged()
def __init__(self, session, *args): Screen.__init__(self, session) self.skinName = "SelectImage" self.session = session self.imagesList = None self.expanded = [] self.setTitle(_("Select Multiboot")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Reboot")) self["description"] = StaticText( _("Use the cursor keys to select an installed image and then press Reboot button." )) self["list"] = ChoiceList(list=[ ChoiceEntryComponent('', ( (_("Retrieving image slots - Please wait...")), "Waiter")) ]) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "ok": self.keyOk, "cancel": self.cancel, "red": self.cancel, "green": self.keyOk, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.cancel, True), }, -1) self.callLater(self.getBootOptions)
def __init__(self, session, contexts, list): Screen.__init__(self, session) actions = { "ok": self.goOk, "cancel": self.goCancel, } menu = [] if ["OkCancelActions"] not in contexts: contexts = ["OkCancelActions"] + contexts for item in list: button = item[0] text = item[1] if callable(text): text = text() if text: action = item[2] if len(item) > 2 else button if button and button not in ("expandable", "expanded", "verticalline", "bullet"): actions[button] = boundFunction(self.close, button) menu.append(ChoiceEntryComponent(button, (text, action))) self["actions"] = ActionMap(contexts, actions) self["menu"] = ChoiceList(menu)
def __init__(self, session, args=0): Screen.__init__(self, session) self.title = _("Image Backup") self["key_red"] = StaticText(_("Cancel")) self["description"] = StaticText( _("Use the cursor keys to select an installed image and then Start button." )) self["options"] = StaticText(_(" ")) self["key_green"] = StaticText(_("Start")) self["config"] = ChoiceList(list=[ ChoiceEntryComponent('', ( (_("Retrieving image slots - Please wait...")), "Queued")) ]) imagedict = [] self.getImageList = None self.startit() self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "red": boundFunction(self.close, None), "green": self.start, "ok": self.start, "cancel": boundFunction(self.close, None), "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, "upRepeated": self.keyUp, "downRepeated": self.keyDown, "leftRepeated": self.keyLeft, "rightRepeated": self.keyRight, "menu": boundFunction(self.close, True), }, -1) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session, args=None): Screen.__init__(self, session) self['description'] = Label( _('Click on your remote on the button you want to change, then click on OK' )) self.session = session self.setTitle(_("Hotkey Setup") + " - Version " + updateversion) self["key_red"] = Button(_("Exit")) self["key_green"] = Button(_("Toggle Extra Keys")) self.list = [] self.hotkeys = getHotkeys() self.hotkeyFunctions = getHotkeyFunctions() for x in self.hotkeys: self.list.append(ChoiceEntryComponent('', (x[0], x[1]))) self["list"] = ChoiceList( list=self.list[:config.misc.hotkey.additional_keys. value and len(self.hotkeys) or 16], selection=0) self["choosen"] = ChoiceList(list=[]) self["actions"] = ActionMap( ["OkCancelActions", "ColorActions", "DirectionActions"], { "ok": self.keyOk, "cancel": self.close, "red": self.close, "green": self.toggleAdditionalKeys, "up": self.keyUp, "down": self.keyDown, "left": self.keyLeft, "right": self.keyRight, }, -1) self["HotkeyButtonActions"] = hotkeyActionMap( ["HotkeyActions"], dict((x[1], self.hotkeyGlobal) for x in self.hotkeys)) self.longkeyPressed = False self.onLayoutFinish.append(self.__layoutFinished) self.onExecBegin.append(self.getFunctions)
def getImagelistCallback(self, imagesdict): list = [] currentimageslot = GetCurrentImage() mode = GetCurrentImageMode() or 0 if imagesdict: for index, x in enumerate(sorted(imagesdict.keys())): if imagesdict[x]["imagename"] != _("Empty slot"): if SystemInfo["canMode12"]: list.insert(index, ChoiceEntryComponent('',((_("slot%s - %s mode 1 (current image)") if x == currentimageslot and mode != 12 else _("slot%s - %s mode 1")) % (x, imagesdict[x]['imagename']), x))) list.append(ChoiceEntryComponent('',((_("slot%s - %s mode 12 (current image)") if x == currentimageslot and mode == 12 else _("slot%s - %s mode 12")) % (x, imagesdict[x]['imagename']), x + 12))) else: list.append(ChoiceEntryComponent('',((_("slot%s - %s (current image)") if x == currentimageslot and mode != 12 else _("slot%s - %s")) % (x, imagesdict[x]['imagename']), x))) if os.path.isfile("/tmp/startupmount/STARTUP_RECOVERY"): list.append(ChoiceEntryComponent('',((_("Boot to Recovery menu")), "Recovery"))) if os.path.isfile("/tmp/startupmount/STARTUP_ANDROID"): list.append(ChoiceEntryComponent('',((_("Boot to Android image")), "Android"))) if not list: list.append(ChoiceEntryComponent('',((_("No images found")), "Waiter"))) self["list"].setList(list)
def getImagesList(self): def getImages(path, files): for file in [ x for x in files if os.path.splitext(x)[1] == ".zip" and model in x ]: try: if checkimagefiles([ x.split(os.sep)[-1] for x in zipfile.ZipFile(file).namelist() ]): medium = path.split(os.sep)[-1] if medium not in self.imagesList: self.imagesList[medium] = {} self.imagesList[medium][file] = { 'link': file, 'name': file.split(os.sep)[-1] } except: pass model = HardwareInfo().get_machine_name() if not self.imagesList: if not self.jsonlist: try: self.jsonlist = json.load( urllib2.urlopen( 'http://downloads.openpli.org/json/%s' % model)) except: pass self.imagesList = dict(self.jsonlist) if self.jsonlist else {} for media in getNonNetworkMediaMounts(): if not (SystemInfo['HasMMC'] and "/mmc" in media): getImages(media, [ os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and model in x ]) if "downloaded_images" in os.listdir(media): media = os.path.join(media, "downloaded_images") if os.path.isdir(media) and not os.path.islink( media) and not os.path.ismount(media): getImages(media, [ os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and model in x ]) for dir in [ dir for dir in [ os.path.join(media, dir) for dir in os.listdir(media) ] if os.path.isdir(dir) and os.path.splitext(dir)[1] == ".unzipped" ]: shutil.rmtree(dir) list = [] for catagorie in reversed(sorted(self.imagesList.keys())): if catagorie in self.expanded: list.append( ChoiceEntryComponent('expanded', ((str(catagorie)), "Expander"))) for image in reversed(sorted( self.imagesList[catagorie].keys())): list.append( ChoiceEntryComponent( 'verticalline', ((str(self.imagesList[catagorie][image]['name'])), str(self.imagesList[catagorie][image]['link'])))) else: for image in self.imagesList[catagorie].keys(): list.append( ChoiceEntryComponent('expandable', ((str(catagorie)), "Expander"))) break if list: self["list"].setList(list) if self.setIndex: self["list"].moveToIndex( self.setIndex if self.setIndex < len(list) else len(list) - 1) if self["list"].l.getCurrentSelection()[0][1] == "Expander": self.setIndex -= 1 if self.setIndex: self["list"].moveToIndex(self.setIndex if self.setIndex < len(list) else len(list) - 1) self.setIndex = 0 self.selectionChanged() else: self.session.openWithCallback( self.close, MessageBox, _("Cannot find images - please try later"), type=MessageBox.TYPE_ERROR, timeout=3)
def __init__(self, session, title="", list=None, keys=None, selection=0, skin_name=None, text="", reorderConfig="", var="", menu_path="", windowTitle=None, allow_cancel=True, titlebartext=_("Choice Box")): if not windowTitle: #for compatibility windowTitle = titlebartext if not list: list = [] if not skin_name: skin_name = [] Screen.__init__(self, session) self.allow_cancel = allow_cancel if isinstance(skin_name, str): skin_name = [skin_name] self.skinName = skin_name + ["ChoiceBox"] self.reorderConfig = reorderConfig self["text"] = Label() self.var = "" if skin_name and 'SoftwareUpdateChoices' in skin_name and var and var in ( 'unstable', 'updating', 'stable', 'unknown'): self.var = var self['feedStatusMSG'] = Label() self['tl_off'] = Pixmap() self['tl_red'] = Pixmap() self['tl_yellow'] = Pixmap() self['tl_green'] = Pixmap() if skin_name and 'SoftwareUpdateChoices' in skin_name: self["menu_path_compressed"] = StaticText(menu_path) title_max = 55 if 'MetrixHD/' in config.skin.primary_skin.value: title_max += 10 if title: title = _(title) if len(title) < title_max and title.find('\n') == -1: Screen.setTitle(self, title) elif title.find('\n') != -1: temptext = title.split('\n') if len(temptext[0]) < title_max: Screen.setTitle(self, temptext[0]) count = 2 labeltext = "" while len(temptext) >= count: if labeltext: labeltext += '\n' labeltext = labeltext + temptext[count - 1] count += 1 print '[Choicebox] count', count self["text"].setText(labeltext) else: self["text"] = Label(title) else: self["text"] = Label(title) elif text: self["text"] = Label(_(text)) self.list = [] self.summarylist = [] if keys is None: self.__keys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue", "text" ] + (len(list) - 14) * [""] else: self.__keys = keys + (len(list) - len(keys)) * [""] self.keymap = {} pos = 0 if self.reorderConfig: self.config_type = eval("config.misc.pluginlist." + self.reorderConfig) if self.config_type.value: prev_list = zip(list, self.__keys) new_list = [] for x in self.config_type.value.split(","): for entry in prev_list: if entry[0][0] == x: new_list.append(entry) prev_list.remove(entry) list = zip(*(new_list + prev_list)) list, self.__keys = list[0], list[1] number = 1 new_keys = [] for x in self.__keys: if (not x or x.isdigit()) and number <= 10: new_keys.append(str(number % 10)) number += 1 else: new_keys.append(not x.isdigit() and x or "") self.__keys = new_keys for x in list: strpos = str(self.__keys[pos]) self.list.append(ChoiceEntryComponent(key=strpos, text=x)) if self.__keys[pos] != "": self.keymap[self.__keys[pos]] = list[pos] self.summarylist.append((self.__keys[pos], x[0])) pos += 1 self["windowtitle"] = Label(_(windowTitle)) self["list"] = ChoiceList(list=self.list, selection=selection) self["summary_list"] = StaticText() self["summary_selection"] = StaticText() self.updateSummary(selection) self["actions"] = NumberActionMap( [ "WizardActions", "InputActions", "ColorActions", "DirectionActions", "MenuActions" ], { "ok": self.go, "1": self.keyNumberGlobal, "2": self.keyNumberGlobal, "3": self.keyNumberGlobal, "4": self.keyNumberGlobal, "5": self.keyNumberGlobal, "6": self.keyNumberGlobal, "7": self.keyNumberGlobal, "8": self.keyNumberGlobal, "9": self.keyNumberGlobal, "0": self.keyNumberGlobal, "red": self.keyRed, "green": self.keyGreen, "yellow": self.keyYellow, "blue": self.keyBlue, "text": self.keyText, "up": self.up, "down": self.down, "left": self.left, "right": self.right, "moveUp": self.additionalMoveUp, "moveDown": self.additionalMoveDown, "menu": self.setDefaultChoiceList, "back": lambda: 0, # drop through to self["cancelaction"] }, prio=-2) self["cancelaction"] = ActionMap(["WizardActions"], { "back": self.cancel, }, prio=-1) self.onShown.append(self.onshow)
def getImagesList(self): def getImages(files): for file in [ x for x in files if os.path.splitext(x)[1] == ".zip" and box in x ]: try: if checkimagefiles([ x.split(os.sep)[-1] for x in zipfile.ZipFile(file).namelist() ]): imagetyp = _("Downloaded Images") if (file.find("backup") != -1): imagetyp = _("Fullbackup Images") if imagetyp not in self.imagesList: self.imagesList[imagetyp] = {} self.imagesList[imagetyp][file] = { 'link': file, 'name': file.split(os.sep)[-1] } except: pass if not self.imagesList: box = GetBoxName() if not self.jsonlist: try: self.jsonlist = dict( json.load(urllib2.urlopen('%s/%s' % (feedurl, box)))) #if config.usage.alternative_imagefeed.value: # self.jsonlist.update(dict(json.load(urllib2.urlopen('%s%s' % (config.usage.alternative_imagefeed.value, box))))) except: pass self.imagesList = dict(self.jsonlist) for media in ['/media/%s' % x for x in os.listdir('/media')] + ([ '/media/net/%s' % x for x in os.listdir('/media/net') ] if os.path.isdir('/media/net') else []): mediaRoot = media if not (SystemInfo['HasMMC'] and "/mmc" in media) and os.path.isdir(media): for customDir in self.customDirs: media = mediaRoot getImages([ os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and box in x ]) if customDir in os.listdir(media): media = os.path.join(media, customDir) if os.path.isdir(media) and not os.path.islink( media) and not os.path.ismount(media): getImages([ os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and box in x ]) for dir in [ dir for dir in [ os.path.join(media, dir) for dir in os.listdir(media) ] if os.path.isdir(dir) and os.path.splitext(dir)[1] == ".unzipped" ]: shutil.rmtree(dir) list = [] for catagorie in reversed(sorted(self.imagesList.keys())): if catagorie in self.expanded: list.append( ChoiceEntryComponent('expanded', ((str(catagorie)), "Expander"))) for image in reversed( sorted(self.imagesList[catagorie].keys(), key=lambda x: x.split(os.sep)[-1])): list.append( ChoiceEntryComponent( 'verticalline', ((str(self.imagesList[catagorie][image]['name'])), str(self.imagesList[catagorie][image]['link'])))) else: for image in self.imagesList[catagorie].keys(): list.append( ChoiceEntryComponent('expandable', ((str(catagorie)), "Expander"))) break if list: self["list"].setList(list) if self.setIndex: self["list"].moveToIndex( self.setIndex if self.setIndex < len(list) else len(list) - 1) if self["list"].l.getCurrentSelection()[0][1] == "Expander": self.setIndex -= 1 if self.setIndex: self["list"].moveToIndex(self.setIndex if self.setIndex < len(list) else len(list) - 1) self.setIndex = 0 self.selectionChanged() else: self.session.openWithCallback( self.close, MessageBox, _("Cannot find images - please try later"), type=MessageBox.TYPE_ERROR, timeout=3)