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) if title: title = _(title) if len(title) < 55 and title.find('\n') == -1: Screen.setTitle(self, title) elif title.find('\n') != -1: temptext = title.split('\n') if len(temptext[0]) < 55: 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, "shiftUp": self.additionalMoveUp, "shiftDown": 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(path, 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() ]): if "Downloaded Images" not in self.imagesList: self.imagesList["Downloaded Images"] = {} self.imagesList["Downloaded Images"][file] = { 'link': file, 'name': file.split(os.sep)[-1] } except: pass if not self.imagesList: box = GetBoxName() for version in reversed(sorted(imagecat)): newversion = _("Image Version %s") % version the_page = "" url = '%s/%s/images/%s' % (feedurl, version, box) try: req = urllib2.Request(url) response = urllib2.urlopen(req) except urllib2.URLError as e: print "URL ERROR: %s\n%s" % (e, url) continue try: the_page = response.read() except urllib2.HTTPError as e: print "HTTP download ERROR: %s" % e.code continue lines = the_page.split('\n') tt = len(box) countimage = [] for line in lines: if line.find('<a href="o') > -1: t = line.find('<a href="o') e = line.find('zip"') countimage.append(line[t + 9:e + 3]) if len(countimage) >= 1: self.imagesList[newversion] = {} for image in countimage: self.imagesList[newversion][image] = {} self.imagesList[newversion][image]["name"] = image self.imagesList[newversion][image][ "link"] = '%s/%s/images/%s/%s' % (feedurl, version, box, image) 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 []): if not (SystemInfo['HasMMC'] and "/mmc" in media) and os.path.isdir(media): getImages(media, [ os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and box in x ]) if "images" in os.listdir(media): media = os.path.join(media, "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 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())): 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, 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 = eval("config.misc.hotkey." + key[0][1]) self.expanded = [] self.selected = [] for x in self.config.value.split(','): if x.startswith("ZapPanic"): self.selected.append( ChoiceEntryComponent( '', ((_("Panic to") + " " + ServiceReference( eServiceReference(x.split( "/", 1)[1]).toString()).getServiceName()), x))) elif x.startswith("Zap"): self.selected.append( ChoiceEntryComponent( '', ((_("Zap to") + " " + ServiceReference( eServiceReference(x.split( "/", 1)[1]).toString()).getServiceName()), x))) else: 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, "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, title="", list=[], keys=None, selection=0, skin_name=[], extEntry=None): Screen.__init__(self, session) if isinstance(skin_name, str): skin_name = [skin_name] self.skinName = skin_name + ["ChoiceBox"] if title: title = _(title) # [iq try: if skin_name[0] == "ExtensionsList": from Components.Network import iNetwork from Components.config import ConfigIP, NoSave self.local_ip = NoSave( ConfigIP( default=iNetwork.getAdapterAttribute("eth0", "ip"))) if self.local_ip.getText() is not None: self["text"] = Label("IP: getting...\n" + "Local IP: " + self.local_ip.getText()) else: self["text"] = Label("IP: getting...\n" + "Local IP: getting...") else: if len(title) < 55: Screen.setTitle(self, title) self["text"] = Label("") else: self["text"] = Label(title) except: # iq] if len(title) < 55: Screen.setTitle(self, title) self["text"] = Label("") else: self["text"] = Label(title) self.list = [] self.extEntry = extEntry # [iq] self.summarylist = [] if keys is None: self.__keys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ] + (len(list) - 10) * [""] else: self.__keys = keys + (len(list) - len(keys)) * [""] self.keymap = {} pos = 0 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["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"], self["actions"] = NumberActionMap( [ "WizardActions", "InputActions", "ColorActions", "DirectionActions", "InfobarChannelSelection" ], { "ok": self.go, "back": self.cancel, "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, "up": self.up, "down": self.down, # [iq "openSatellites": self.extEntryReady, "menu": self.extEntryGo, # iq] }, -1) # [iq self.extEntryExecuted = -1 try: if skin_name[0] == "ExtensionsList": self.StaticIPTimer = enigma.eTimer() self.StaticIPTimer.callback.append(self.iptimeout) self.iptimeout() except: pass
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( urlopen( Request('%s/%s' % (feedurl, box), headers={'User-Agent': 'Mozilla/5.0'})))) 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(list(self.imagesList.keys()))): if catagorie in self.expanded: _list.append( ChoiceEntryComponent('expanded', ((str(catagorie)), "Expander"))) for image in reversed( sorted(list(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 list(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 getImagesList(self): def getImages(path, files): for file in [ x for x in files if x.endswith('.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_device_model() if not self.imagesList: if not self.jsonlist: try: self.jsonlist = json.load( urllib2.urlopen( 'https://openpli.org/download/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, [ "%s/%s" % (media, x) for x in os.listdir(media) if x.endswith('.zip') and model in x ]) if "downloaded_images" in os.listdir(media): media = "%s/downloaded_images" % media if os.path.isdir(media) and not os.path.islink( media) and not os.path.ismount(media): getImages(media, [ "%s/%s" % (media, x) for x in os.listdir(media) if x.endswith('.zip') and model in x ]) 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())): if not SystemInfo["canMultiBoot"] or image.endswith( '_multiboot.zip'): list.append( ChoiceEntryComponent('verticalline', ((str( self.imagesList[catagorie][image]['name'] )), str( self.imagesList[catagorie][image]['link'])))) else: for image in self.imagesList[catagorie].keys(): if not SystemInfo["canMultiBoot"] or image.endswith( '_multiboot.zip'): 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 = ''): self.setTitle(_('Choice Box')) if not list: list = [] if not skin_name: skin_name = [] Screen.__init__(self, session) if isinstance(skin_name, str): skin_name = [skin_name] self.skinName = skin_name + ['ChoiceBox'] 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 title: title = _(title) if len(title) < 55 and title.find('\n') == -1: Screen.setTitle(self, title) elif title.find('\n') != -1: temptext = title.split('\n') if len(temptext[0]) < 55: Screen.setTitle(self, temptext[0]) count = 2 labeltext = '' while len(temptext) >= count: if labeltext: labeltext += '\n' labeltext = labeltext + temptext[count - 1] count += 1 print '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'] + (len(list) - 10) * [''] else: self.__keys = keys + (len(list) - len(keys)) * [''] self.keymap = {} pos = 0 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['list'] = ChoiceList(list=self.list, selection=selection) self['summary_list'] = StaticText() self['summary_selection'] = StaticText() self.updateSummary(selection) self['actions'] = NumberActionMap(['WizardActions', 'InputActions', 'ColorActions'], {'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, 'up': self.up, 'down': self.down, 'left': self.left, 'right': self.right}, -1) self['cancelaction'] = NumberActionMap(['WizardActions', 'InputActions', 'ColorActions'], {'back': self.cancel}, -1) self.onShown.append(self.onshow) return
def __init__(self, session, title="", list=[], keys=None, selection=0, skin_name=[], text=""): Screen.__init__(self, session) if isinstance(skin_name, str): skin_name = [skin_name] self.skinName = skin_name + ["ChoiceBox"] self["text"] = Label() if title: title = _(title) if len(title) < 55 and title.find('\n') == -1: Screen.setTitle(self, title) elif title.find('\n') != -1: temptext = title.split('\n') if len(temptext[0]) < 55: Screen.setTitle(self, temptext[0]) count = 2 labeltext = "" while len(temptext) >= count: if labeltext: labeltext = labeltext + '\n' labeltext = labeltext + temptext[count - 1] count += 1 print '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" ] + (len(list) - 10) * [""] else: self.__keys = keys + (len(list) - len(keys)) * [""] self.keymap = {} pos = 0 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["list"] = ChoiceList(list=self.list, selection=selection) self["summary_list"] = StaticText() self["summary_selection"] = StaticText() self.updateSummary(selection) self["actions"] = NumberActionMap( ["WizardActions", "InputActions", "ColorActions"], { "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, "up": self.up, "down": self.down, "left": self.left, "right": self.right }, -1) self["cancelaction"] = NumberActionMap( ["WizardActions", "InputActions", "ColorActions"], { "back": self.cancel, }, -1)
def __init__(self, session, menu_path=""): Screen.__init__(self, session) self.skinName = "MultiBoot" screentitle = _("Multiboot image manager") self.menu_path = menu_path if config.usage.show_menupath.value == 'large': self.menu_path += screentitle title = self.menu_path self["menu_path_compressed"] = StaticText("") self.menu_path += ' / ' elif config.usage.show_menupath.value == 'small': title = screentitle condtext = "" if self.menu_path and not self.menu_path.endswith(' / '): condtext = self.menu_path + " >" elif self.menu_path: condtext = self.menu_path[:-3] + " >" self["menu_path_compressed"] = StaticText(condtext) self.menu_path += screentitle + ' / ' else: title = screentitle self["menu_path_compressed"] = StaticText("") Screen.setTitle(self, title) self.title = screentitle if SystemInfo["HasHiSi"] and not pathExists('/dev/sda1'): self["key_red"] = StaticText(_("Cancel")) self["labe14"] = StaticText(_("Press Init to format SDcard.")) self["labe15"] = StaticText(_(" ")) self["key_green"] = StaticText(_("Init SDcard")) self["config"] = ChoiceList( list=[ChoiceEntryComponent('', ((_(" ")), "Queued"))]) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "red": boundFunction(self.close, None), "green": self.format, "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) else: 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["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, "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 newChannelContextMenu__init__(self, session, csel): baseChannelContextMenu__init__(self, session, csel) self["menu"].enableWrapAround = True if config.BouquetProtect.enabled.value == 'none': return if csel.bouquet_mark_edit != 0 or csel.movemode: return idx = max(0, len(self["menu"].list)-1) current = csel.getCurrentSelection() current_root = csel.getRoot() if not (current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1): inBouquet = csel.getMutableList() is not None if not (current.flags & (eServiceReference.isMarker|eServiceReference.isDirectory)): if inBouquet and config.BouquetProtect.enabled.value in ('bouq'): if not csel.hidden_shown: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("unlock protected services"), self.menuShowAllHiddenBouquetServices))) self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("add to bouquets protection"), boundFunction(self.menuHideCurrentService, True)))) else: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("lock protected services"), self.menuShowAllHiddenBouquetServices))) if current.toString() in getHiddenList(): self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("remove from bouquets protection"), boundFunction(self.menuHideCurrentService, False)))) else: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("add to bouquets protection"), boundFunction(self.menuHideCurrentService, True)))) elif not inBouquet and config.BouquetProtect.unwanted.enalbed.value: if current_root and current_root.getPath().find("flags == 2") != -1: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("restore all hidden services"), boundFunction(self.menuHideUnwantedServices, False)))) self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("restore hidden service"), boundFunction(self.menuHideUnwantedService, False)))) else: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("hide as unwanted service"), boundFunction(self.menuHideUnwantedService, True)))) else: if config.BouquetProtect.unwanted.enalbed.value: if not inBouquet and current.getPath().find("PROVIDERS") == -1: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("hide all as unwanted services"), boundFunction(self.menuHideUnwantedServices, True)))) else: if not csel.hidden_shown: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("unlock protected services"), self.menuShowAllHiddenBouquetServices))) self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("add to bouquets protection"), boundFunction(self.menuHideCurrentBouquet, True)))) else: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("lock protected services"), self.menuShowAllHiddenBouquetServices))) if current.toString() in getHiddenList(): self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("remove from bouquets protection"), boundFunction(self.menuHideCurrentBouquet, False)))) else: self["menu"].list.insert(idx, ChoiceEntryComponent(text = (_("add to bouquets protection"), boundFunction(self.menuHideCurrentBouquet, True))))
def __init__(self, session, title="", list=[], keys=None, selection=0, skin_name=[]): Screen.__init__(self, session) if isinstance(skin_name, str): skin_name = [skin_name] self.skinName = skin_name + ["ChoiceBox"] if title: title = _(title) if len(title) < 55 and title.find('\n') == -1: Screen.setTitle(self, title) self["text"] = Label("") else: self["text"] = Label(title) self.list = [] self.summarylist = [] if keys is None: self.__keys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ] + (len(list) - 10) * [""] else: self.__keys = keys + (len(list) - len(keys)) * [""] self.keymap = {} pos = 0 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["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" ], { "ok": self.go, "back": self.cancel, "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, "up": self.up, "down": self.down }, -1)
def __init__(self, session, menu_path=""): Screen.__init__(self, session) Screen.setTitle(self, _("MultiBoot Image Manager")) if SystemInfo["HasSDmmc"] and not pathExists('/dev/sda4'): self["key_red"] = StaticText(_("Cancel")) self["description"] = StaticText(_("Press Init to format SDcard.")) self["options"] = StaticText("") self["key_yellow"] = StaticText(_("Init SDcard")) self["config"] = ChoiceList( list=[ChoiceEntryComponent('', ((""), "Queued"))]) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "red": boundFunction(self.close, None), "yellow": self.format, "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) else: self["key_red"] = StaticText(_("Cancel")) self["description"] = StaticText( _("Use the cursor keys to select an installed image and then Erase button." )) self["options"] = StaticText( _("Note: slot list does not show current image or empty slots." )) self["key_green"] = StaticText(_("Erase")) if SystemInfo["HasSDmmc"]: self["key_yellow"] = StaticText(_("Init SDcard")) else: 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": self.format, "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.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(_('Quick button 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(','): if x.startswith('ZapPanic'): self.selected.append( ChoiceEntryComponent( '', (_('Panic to') + ' ' + ServiceReference( eServiceReference(x.split( '/', 1)[1]).toString()).getServiceName(), x))) elif x.startswith('Zap'): self.selected.append( ChoiceEntryComponent( '', (_('Zap to') + ' ' + ServiceReference( eServiceReference(x.split( '/', 1)[1]).toString()).getServiceName(), x))) else: 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, '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 getImagesList(self): def getImages(path, 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 'backup' in file.split(os.sep)[-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(urlopen('%s/%s' % (feedurl, box)))) #if config.usage.alternative_imagefeed.value: # self.jsonlist.update(dict(json.load(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 []): if not (BoxInfo.getItem('HasMMC') and "/mmc" in media) and os.path.isdir(media): getImages(media, [ os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and box in x ]) for folder in [ "images", "downloaded_images", "imagebackups" ]: if folder in os.listdir(media): subfolder = os.path.join(media, folder) if os.path.isdir(subfolder) and not os.path.islink( subfolder) and not os.path.ismount( subfolder): getImages(subfolder, [ os.path.join(subfolder, x) for x in os.listdir(subfolder) if os.path.splitext(x)[1] == ".zip" and box in x ]) for dir in [ dir for dir in [ os.path.join(subfolder, dir) for dir in os.listdir(subfolder) ] 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(list(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 list(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=[], keys=None, selection=0, skin_name=[], reorderConfig="", windowTitle=None): Screen.__init__(self, session) if isinstance(skin_name, str): skin_name = [skin_name] self.skinName = skin_name + ["ChoiceBox"] self.reorderConfig = reorderConfig self["autoresize"] = Label("") # do not remove, used for autoResize() self["description"] = Label() self["text"] = Label(title) self.list = [] self.summarylist = [] if keys is None: self.__keys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ] + (len(list) - 14) * ["dummy"] else: self.__keys = keys + (len(list) - len(keys)) * ["dummy"] 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: if x: 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["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, "back": self.cancel, "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, "up": self.up, "down": self.down, "moveUp": self.additionalMoveUp, "moveDown": self.additionalMoveDown, "menu": self.setDefaultChoiceList, "rightUp": self.rightUp, "leftUp": self.leftUp }, -1) self.setTitle(windowTitle or _("Select"))
def __init__(self, session, key, args=None): Screen.__init__(self, session) self.key = key getHotkeyFunctions() self.setTitle(_("Hotkey Setup") + " " + key[0][0]) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Save")) self["key_yellow"] = StaticText("") self["h_prev"] = Pixmap() self["h_next"] = Pixmap() self["description"] = Label() self.mode = "list" self.config = getattr(config.misc.hotkey, key[0][1]) self.expanded = [] self.selected = [] for x in self.config.value.split(','): if x.startswith("ZapPanic"): self.selected.append( ChoiceEntryComponent( '', ((_("Panic to") + " " + ServiceReference( eServiceReference(x.split( "/", 1)[1]).toString()).getServiceName()), x))) elif x.startswith("Zap"): self.selected.append( ChoiceEntryComponent( '', ((_("Zap to") + " " + ServiceReference( eServiceReference(x.split( "/", 1)[1]).toString()).getServiceName()), x))) else: function = next( (function for function in hotkey.functions if function[1] == x), None) if function: self.selected.append( ChoiceEntryComponent('', ((function[0]), function[1]))) text = _( "Press 'OK' for attach next function or 'CH+/-' for edit attached." ) if len(self.selected) else _("Press 'OK' for attach function.") self.prevselected = self.selected[:] if self.prevselected: self["key_yellow"].setText(_("Edit selection")) self["choosen"] = ChoiceList(list=self.selected, selection=0) self["list"] = ChoiceList(list=self.getFunctionList(), selection=0) self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions" ], { "ok": self.keyOk, "cancel": self.cancel, "red": self.cancel, "green": self.save, "yellow": self.toggleMode, "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, "menu": boundFunction(self.close, True), }, -1) self.description(text) self.showPrevNext() self.onLayoutFinish.append(self.__layoutFinished)
def getImagesList(self): def getImages(path, files): for file in [ x for x in files if os.path.splitext(x)[1] == ".zip" and box in x or ( "openpli" in x and boxname in x) ]: try: if checkimagefiles([ x.split(os.sep)[-1] for x in zipfile.ZipFile(file).namelist() ]): imagetyp = _("Downloaded Images") if 'backup' in file.split(os.sep)[-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][:-4] } except: pass if not self.imagesList: box = GetBoxName() boxname = getMachineProcModel().lower() try: import socket socket.getaddrinfo(feedserver, None) for version in sorted(imagecat): newversion = _( "Images %s" ) % version #Oficial, Descargadas, Full backup the_page = "" url = '%s/Alliance/getfirm.php?box=%s' % (feedurl, box) try: req = urllib2.Request(url) response = urllib2.urlopen(req) except urllib2.URLError as e: print "URL ERROR: %s\n%s" % (e, url) continue try: the_page = response.read() except urllib2.HTTPError as e: print "HTTP download ERROR: %s" % e.code continue lines = the_page.split('\n') try: l = lines[0] self.feedurl = l.split("<a href='")[1].split( "openspa-")[0] except: self["info"].setText("BOX: [" + box + "]\n" + _( "No images found for this device. More info in openspa.info" )) list.append("(" + _("No images found for") + " " + box + ")") countimage = [] for line in lines: if line.find(".zip") > -1 and not "recovery" in line: try: self.feedurl = line.split( "<a href='")[1].split("openspa-")[0] except: pass name = line.split(">")[1].split("<")[0] name = name.replace(" (", " ").replace( " - ", " - ").replace(")", "").replace(".zip", " ->") #self.urllist[name]=line.split("<a href='")[1].split("openspa-")[0] countimage.append(name.split(' ->')[0]) if len(countimage) >= 1: self.imagesList[newversion] = {} for image in countimage: self.imagesList[newversion][image] = {} self.imagesList[newversion][image]["name"] = image self.imagesList[newversion][image][ "link"] = '%s%s.zip' % (self.feedurl, image) except socket.error as e: print "FEEDSERVER ERROR: %s" % e 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 []): if os.path.isdir(media): getImages(media, [ os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and box in x or ( "openpli" in x and boxname in x) ]) if "images" in os.listdir(media): media = os.path.join(media, "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 box in x or ("openpli" in x and boxname 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 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)
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() ]): if "Downloaded Images" not in self.imagesList: self.imagesList["Downloaded Images"] = {} self.imagesList["Downloaded Images"][file] = { 'link': file, 'name': file.split(os.sep)[-1] } except: pass model = getBoxType() if not self.imagesList: if not self.jsonlist: try: self.jsonlist = dict( json.load( urllib2.urlopen( 'https://openvision.tech/download/json/%s' % model))) if config.usage.alternative_imagefeed.value: self.jsonlist.update( dict( json.load( urllib2.urlopen( '%s%s' % (config.usage.alternative_imagefeed. value, model))))) 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 []): if not (SystemInfo['HasMMC'] and "/mmc" in media) and os.path.isdir(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=''): if not list: list = [] if not skin_name: skin_name = [] Screen.__init__(self, session) 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 title: title = _(title) if len(title) < 55 and title.find('\n') == -1: Screen.setTitle(self, title) elif title.find('\n') != -1: temptext = title.split('\n') if len(temptext[0]) < 55: Screen.setTitle(self, temptext[0]) count = 2 labeltext = '' while len(temptext) >= count: if labeltext: labeltext += '\n' labeltext = labeltext + temptext[count - 1] count += 1 print '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' ] + (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['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, 'up': self.up, 'down': self.down, 'left': self.left, 'right': self.right, 'shiftUp': self.additionalMoveUp, 'shiftDown': self.additionalMoveDown, 'menu': self.setDefaultChoiceList }, -1) self['cancelaction'] = NumberActionMap( ['WizardActions', 'InputActions', 'ColorActions'], {'back': self.cancel}, -1) self.onShown.append(self.onshow) return