def loadEmuList(self): emu = [] crd = [] emu.append('None') crd.append('None') self.emu_list = {} self.crd_list = {} self.emu_list['None'] = 'None' self.crd_list['None'] = 'None' emufilelist = FileList('/usr/emuscript', matchingPattern='_em.*') srvfilelist = FileList('/usr/emuscript', matchingPattern='_cs.*') for x in emufilelist.getFileList(): if x[0][1] != True: emuName = t.readEmuName(x[0][0][:-6]) emu.append(emuName) self.emu_list[emuName] = x[0][0][:-6] softcam = ConfigSelection(default=t.readEmuName(t.readEmuActive()), choices=emu) for x in srvfilelist.getFileList(): if x[0][1] != True: srvName = t.readSrvName(x[0][0][:-6]) crd.append(srvName) self.crd_list[srvName] = x[0][0][:-6] cardserver = ConfigSelection(default=t.readSrvName(t.readSrvActive()), choices=crd) del self.list[:] self.list.append(getConfigListEntry(_('SoftCams (%s) :') % str(len(emu) - 1), softcam)) self.list.append(getConfigListEntry(_('CardServers (%s) :') % str(len(crd) - 1), cardserver)) self.list.append(getConfigListEntry(_('About ItalySat'), ConfigNothing())) self['config'].list = self.list self['config'].l.setList(self.list)
class YouTubeDirBrowser(Screen): def __init__(self, session, downloadDir): Screen.__init__(self, session) self.skinName = ['YouTubeDirBrowser', 'FileBrowser'] self['key_red'] = StaticText(_('Cancel')) self['key_green'] = StaticText(_('Use')) if not os.path.exists(downloadDir): downloadDir = '/' self.filelist = FileList(downloadDir, showFiles = False) self['filelist'] = self.filelist self['FilelistActions'] = ActionMap(['SetupActions', 'ColorActions'], { 'cancel': self.cancel, 'red': self.cancel, 'ok': self.ok, 'green': self.use }, -2) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(_('Please select the download directory')) def ok(self): if self.filelist.canDescent(): self.filelist.descent() def use(self): currentDir = self['filelist'].getCurrentDirectory() dirName = self['filelist'].getFilename() if currentDir is None or \ (self.filelist.canDescent() and dirName and len(dirName) > len(currentDir)): self.close(dirName) def cancel(self): self.close(False)
def loadEmuList(self): emu = [] crd = [] emu.append("None") crd.append("None") self.emu_list = {} self.crd_list = {} self.emu_list["None"] = "None" self.crd_list["None"] = "None" emufilelist = FileList("/usr/script", matchingPattern = "_em.*") srvfilelist = FileList("/usr/script", matchingPattern = "_cs.*") for x in emufilelist.getFileList(): if x[0][1] != True: emuName = t.readEmuName(x[0][0][:-6]) emu.append(emuName) self.emu_list[emuName] = x[0][0][:-6] softcam = ConfigSelection(default = t.readEmuName(t.readEmuActive()), choices = emu) for x in srvfilelist.getFileList(): if x[0][1] != True: srvName = t.readSrvName(x[0][0][:-6]) crd.append(srvName) self.crd_list[srvName] = x[0][0][:-6] cardserver = ConfigSelection(default = t.readSrvName(t.readSrvActive()), choices = crd) del self.list[:] self.list.append(getConfigListEntry(_('SoftCam (%s) :') % str(len(emu)-1), softcam)) self.list.append(getConfigListEntry(_('CardServer (%s) :') % str(len(crd)-1), cardserver)) self['config'].list = self.list self['config'].l.setList(self.list)
def openPicturePlayerSlideDir(self, option): if option is None: return from Plugins.Extensions.PicturePlayer.ui import Pic_Full_View from Components.FileList import FileList path = option[1] + "/" filelist = FileList(path, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)") self.session.open(Pic_Full_View, filelist.getFileList(), 0, filelist.getCurrentDirectory())
def __init__(self, type): MediaBrowserList.__init__(self, type) if self._type == MediaCore.TYPE_AUDIO: self.filter = MediaBrowserFileList.filter_audio elif self._type == MediaCore.TYPE_VIDEO: self.filter = MediaBrowserFileList.filter_video else: self.filter = MediaBrowserFileList.filter_media defaultDir = None FileList.__init__(self, defaultDir, matchingPattern=self.filter, useServiceRef=True)
def updateList(self): del self.list[:] filelist = FileList("/usr/script", matchingPattern = "_user.sh") for x in filelist.getFileList(): if x[0][1] != True: scriptName = t.getScriptName(x[0][0][:-8]) res = [x[0][0][:-8]] res.append(MultiContentEntryText(pos=(0, 0), size=(340, 25), font=0, text=scriptName)) self.list.append(res) if len(self.list) == 0: res = ["None"] res.append(MultiContentEntryText(pos=(0, 0), size=(340, 25), font=0, text=_("No Users Script Found!"))) self.list.append(res) self['list'].l.setList(self.list)
class EMCFileBrowser(Screen, HelpableScreen): skin = """ <screen name="EMCFilebrowser" position="center,center" size="560,435" title="EMC Filebrowser"> <widget name="filelist" position="5,5" size="550,370" /> <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/img/line_blue_playlist1.png" position="25,386" size="330,2" alphatest="on" /> <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/img/line_blue_playlist2.png" position="200,386" size="330,2" alphatest="on" /> <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/img/key-red_line.png" position="50,420" size="150,2" alphatest="on" /> <widget name="cancel" position="55,393" size="140,30" valign="center" halign="center" zPosition="1" font="Regular;19" transparent="1" backgroundColor="red" /> <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/img/key-green_line.png" position="355,420" size="150,2" alphatest="on" /> <widget name="open" position="360,393" size="140,30" valign="center" halign="center" zPosition="1" font="Regular;19" transparent="1" backgroundColor="green" /> </screen>""" def __init__(self, session, currDir): Screen.__init__(self, session) self.skinName = ["EMCFileBrowser"] HelpableScreen.__init__(self) self["cancel"] = Button(_("Cancel")) self["open"] = Button(_("Open")) self.filelist = FileList(currDir, showFiles=True, matchingPattern=".(e2pls|m3u)") self["filelist"] = self.filelist self.lastDir = currDir self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "ok": self.ok, "cancel": self.exit }) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(_("EMC Filebrowser")) self.filelist.descent() def ok(self): if self.filelist.canDescent(): self.filelist.descent() else: self.use() def use(self): path = "" if self["filelist"].getFilename() is not None: fname = self["filelist"].getFilename() dirname = self["filelist"].getCurrentDirectory() path = dirname + fname self.close(path) def exit(self): self.close(False)
def addFolderToPlaylist(self, folder, recursive=True): if folder == '/': Log.w("refusing to operate on /") return False filelist = FileList(folder, matchingPattern=self._list.filter, useServiceRef=True, showMountpoints=False, isTop=True) for x in filelist.getFileList(): if x[0][1] == True: #isDir if recursive: if x[0][0] != folder: self.addFolderToPlaylist(x[0][0]) else: self.addToPlaylist(x[0][0]) return True
def copyDirectory(self, directory, recursive=True): print "copyDirectory", directory if directory == '/': print "refusing to operate on /" return filelist = FileList(directory, useServiceRef=True, showMountpoints=False, isTop=True) for x in filelist.getFileList(): if x[0][1]: # isDir if recursive: if x[0][0] != directory: self.copyDirectory(x[0][0]) elif filelist.getServiceRef() and filelist.getServiceRef().type == 4097: self.playlist.addFile(x[0][0]) self.playlist.updateList()
def __init__(self, session, currDir, title="Directory browser", selectFiles=False): print ("DirectorySelectorWidget.__init__ -------------------------------") Screen.__init__(self, session) self["key_red"] = Label(_("Cancel")) # self["key_yellow"] = Label(_("Refresh")) self["key_blue"] = Label(_("New directory")) self["key_green"] = Label(_("Apply")) self["curr_dir"] = Label(_(" ")) self.filelist = FileList(directory=currDir, matchingPattern="", showFiles=selectFiles) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "yellow": self.refresh, "blue": self.newDir, "ok": self.ok, "cancel": self.exit, }, ) self.title = title self.returnFile = selectFiles self.onLayoutFinish.append(self.layoutFinished) self.onClose.append(self.__onClose)
def __init__(self, session): Screen.__init__(self, session) Screen.setTitle(self, _("Select extra packages folder")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Save")) defaultDir = config.backupmanager.backuplocation.value self.filelist = FileList(defaultDir, showFiles=True, matchingPattern='^.*.(ipk)') self["checkList"] = self.filelist self["actions"] = ActionMap(["DirectionActions", "OkCancelActions", "ShortcutActions", "MenuActions"], { "cancel": self.exit, "red": self.exit, "green": self.saveSelection, "ok": self.okClicked, "left": self.left, "right": self.right, "down": self.down, "up": self.up, "menu": self.exit, }, -1) if not self.selectionChanged in self["checkList"].onSelectionChanged: self["checkList"].onSelectionChanged.append(self.selectionChanged) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session): Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions"], { "cancel": self.KeyExit, "red": self.KeyExit, "green": self.KeyGreen, "yellow": self.KeyYellow, "blue": self.KeyBlue, "ok": self.KeyOk }, -1) self["key_red"] = StaticText(_("Close")) self["key_green"] = StaticText(_("Thumbnails")) self["key_yellow"] = StaticText("") self["key_blue"] = StaticText(_("Setup")) self["label"] = StaticText("") self["thn"] = Pixmap() currDir = config.pic.lastDir.value if not pathExists(currDir): currDir = "/" self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)") self["filelist"] = self.filelist self["filelist"].onSelectionChanged.append(self.selectionChanged) self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.picload = ePicLoad() self.picload.PictureData.get().append(self.showPic) self.onLayoutFinish.append(self.setConf)
def copyDirectory(self, directory, recursive=True): print "copyDirectory", directory if directory == '/': print "refusing to operate on /" return filelist = FileList(directory, useServiceRef=True, showMountpoints=False, isTop=True) #filelist = FileList(directory, matchingPattern = "(?i)^.*\.(mp2|mp3|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|mkv|mp4|m4a|dat|m2ts|wma)", useServiceRef = True, showMountpoints = False, isTop = True) for x in filelist.getFileList(): if x[0][1] == True: #isDir if recursive: if x[0][0] != directory: self.copyDirectory(x[0][0]) else: self.playlist.addFile(x[0][0]) self.playlist.updateList()
def __init__(self, session, currDir, title="Directory browser"): print("DirectorySelectorWidget.__init__ -------------------------------") Screen.__init__(self, session) # for the skin: first try MediaPlayerDirectoryBrowser, then FileBrowser, this allows individual skinning # self.skinName = ["MediaPlayerDirectoryBrowser", "FileBrowser" ] self["key_red"] = Label(_("Cancel")) # self["key_yellow"] = Label(_("Refresh")) self["key_blue"] = Label(_("New directory")) self["key_green"] = Label(_("Select")) self["curr_dir"] = Label(_(" ")) self.filelist = FileList(directory=currDir, matchingPattern="", showFiles=False) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "yellow": self.refresh, "blue": self.newDir, "ok": self.ok, "cancel": self.exit, }, ) self.title = title self.onLayoutFinish.append(self.layoutFinished) self.onClose.append(self.__onClose)
def __init__(self, session, showDirectories=True, showFiles=True, showMountpoints=True, matchingPattern=None, useServiceRef=False, inhibitDirs=False, inhibitMounts=False, isTop=False, enableWrapAround=False, additionalExtensions=None, closeOnSelection=False): Screen.__init__(self, session) self.skinName = "FileBrowser_Generic" defaultDir = None # TODO Fix / Config value self._closeOnSelection = closeOnSelection self._filelist = FileList(defaultDir, showDirectories=showDirectories, showFiles=showFiles, showMountpoints=showMountpoints, matchingPattern=matchingPattern, useServiceRef=useServiceRef, inhibitDirs=inhibitDirs, inhibitMounts=inhibitMounts, isTop=isTop, enableWrapAround=enableWrapAround, additionalExtensions=additionalExtensions) self["filelist"] = self._filelist self["status"] = MultiColorLabel("") self["key_green"] = Button(_("Add")) self["green"] = Pixmap() self["actions"] = ActionMap(["ListboxActions", "OkCancelActions", "ColorActions"], { "ok" : self.ok, "cancel" : self.close, "moveUp" : self.moveUp, "moveDown" : self.moveDown, "pageUp" : self.pageUp, "pageDown" : self.pageDown, "green" : self.selectCurrent, }); self.onShown.append(self._onShown)
def __init__(self, session, curdir, matchingPattern=None): try: sz_w = getDesktop(0).size().width() except: sz_w = 720 if sz_w >= 1280: self.skin = skinflashhd else: self.skin = skinflashsd Screen.__init__(self, session) self["Title"].setText(_("Select the folder with backup")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText("") self["key_yellow"] = StaticText("") self["curdir"] = StaticText(_("current: %s")%(curdir or '')) self.founds = False self.filelist = FileList(curdir, matchingPattern=matchingPattern, enableWrapAround=True) self.filelist.onSelectionChanged.append(self.__selChanged) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], { "green": self.keyGreen, "red": self.keyRed, "yellow": self.keyYellow, "ok": self.keyOk, "cancel": self.keyRed }) self.onLayoutFinish.append(self.__layoutFinished)
def getFileList(self, param): if param["path"] == "playlist": mp = self.tryOpenMP() # TODO: Fix dummy return if unable to load mp if mp is None: return (("empty", True, "playlist"),) if mp.playlist: return [(serviceRef.getPath(), False, "playlist") for serviceRef in mp.playlist.getServiceRefList()] else: return (("empty", True, "playlist"),) # try to extract current pattern from media player and use it over our hardcoded one as default try: matchingPattern = mp.filelist.matchingPattern except Exception: matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|mov|m2ts)" #MediaPlayer-Match useServiceRef = False if param["types"] == "audio": matchingPattern = "(?i)^.*\.(mp3|ogg|wav|wave|m3u|pls|e2pls)" useServiceRef = True elif param["types"] == "video": matchingPattern = "(?i)^.*\.(ts|avi|mpeg|m3u|pls|e2pls|mpg|vob)" useServiceRef = True elif param["types"] == "any": matchingPattern = ".*" elif param["types"]: matchingPattern = param["types"] path = param["path"] if path is not None: if path.lower() == "filesystems": path = None elif not os_path.isdir(path): # TODO: returning something is better than just dying but is this return sane? return ((None, True, path),) filelist = FileList(path, showDirectories=True, showFiles=True, matchingPattern=matchingPattern, useServiceRef=useServiceRef, isTop=False) list = filelist.getFileList() if useServiceRef is True: returnList = [ (x[0][0].toString(), x[0][1], path) if x[0][1] is False else (x[0][0], x[0][1], path) for x in list ] else: returnList = [ (param["path"] + x[0][0], x[0][1], path) if x[0][1] is False else (x[0][0], x[0][1], path) for x in list ] return returnList
def getFileList(self, param): print "getFileList:", param if param["path"] == "playlist": # TODO: Fix dummy return if unable to load mp if not self.tryOpenMP(): return (("empty", "True", "playlist"),) mp = self.session.mediaplayer if mp.playlist: return [(serviceRef.toString(), "True", "playlist") for serviceRef in mp.playlist.getServiceRefList()] else: return (("empty", "True", "playlist"),) returnList = [] matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob)" #MediaPlayer-Match useServiceRef = False if param["types"] == "audio": matchingPattern = "(?i)^.*\.(mp3|ogg|wav|wave|m3u|pls|e2pls)" useServiceRef = True elif param["types"] == "video": matchingPattern = "(?i)^.*\.(ts|avi|mpeg|m3u|pls|e2pls|mpg|vob)" useServiceRef = True elif param["types"] == "any": matchingPattern = ".*" else: matchingPattern = param["types"] filelist = FileList(param["path"], showDirectories=True, showFiles=True, matchingPattern=matchingPattern, useServiceRef=useServiceRef, isTop=False) list = filelist.getFileList() for x in list: if useServiceRef == True: if x[0][1] == False: #isDir returnList.append((x[0][0].toString(), x[0][1], param["path"])) else: returnList.append((x[0][0], x[0][1], param["path"])) else: if x[0][1] == False: #isDir returnList.append((param["path"] + x[0][0], x[0][1], param["path"])) else: returnList.append((x[0][0], x[0][1], param["path"])) return returnList
class Selectmusic(Screen): def __init__(self, session): Screen.__init__(self, session) self["actions"] = HelpableActionMap(self, "MC_AudioPlayerActions", { "ok": (self.KeyOk, "Play selected file"), "left": (self.leftUp, "List Top"), "right": (self.rightDown, "List Bottom"), "up": (self.up, "List up"), "down": (self.down, "List down"), }, -2) self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", { "cancel": self.close }, -2) currDir = config.plugins.mc_ap.lastDir.value if not pathExists(currDir): currDir = "/" inhibitDirs = ["/bin", "/boot", "/dev", "/dev.static", "/etc", "/lib" , "/proc", "/ram", "/root" , "/sbin", "/sys", "/tmp", "/usr", "/var"] self.filelist = FileList(currDir, useServiceRef = True, showDirectories = True, showFiles = True, matchingPattern = "(?i)^.*\.(m3u|mp2|mp3|wav|wave|pls|wma|m4a|ogg|ra|flac)", inhibitDirs = inhibitDirs) self["filelist"] = self.filelist self["currentfolder"] = Label() self["currentfolder"].setText(str(currDir)) def up(self): self["filelist"].up() def down(self): self["filelist"].down() def leftUp(self): self["filelist"].pageUp() def rightDown(self): self["filelist"].pageDown() def KeyOk(self): self.filename = self.filelist.getFilename() self["currentfolder"].setText(str(self.filelist.getCurrentDirectory())) if self.filelist.getFilename() is not None: if self.filelist.canDescent(): self.filelist.descent() else: config.plugins.mc_pp.music.value = self.filename config.plugins.mc_pp.save() self.close() else: if self.filelist.canDescent(): self.filelist.descent() else: config.plugins.mc_pp.music.value = self.filename config.plugins.mc_pp.save() self.close()
def __init__(self, session): Screen.__init__(self, session) HelpableScreen.__init__(self) # Show Background MVI #system("/usr/bin/showiframe /usr/lib/enigma2/python/Plugins/Extensions/EVOMediaCenter/icons/background.mvi &") self["key_red"] = Button("Favorites") self["key_green"] = Button("Slide Show") self["key_yellow"] = Button("Thumb View") self["key_blue"] = Button(_("Settings")) self["currentfolder"] = Label("") self["currentfavname"] = Label("") self.curfavfolder = -1 self["actions"] = HelpableActionMap(self, "EVOMC_PictureViewerActions", { "ok": (self.KeyOk, "Show Picture"), # "cancel": (self.Exit, "Exit Picture Viewer"), "left": (self.leftUp, "List Top"), "right": (self.rightDown, "List Bottom"), "up": (self.up, "List up"), "down": (self.down, "List down"), "menu": (self.KeyMenu, "File / Folder Options"), "info": (self.StartExif, "Show File Info"), "nextBouquet": (self.NextFavFolder, "Next Favorite Folder"), "prevBouquet": (self.PrevFavFolder, "Previous Favorite Folder"), "red": (self.FavoriteFolders, "Favorite Folders"), "green": (self.startslideshow, "Start Slideshow"), "yellow": (self.StartThumb, "Thumb View"), "blue": (self.Settings, "Settings"), }, -2) self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", { "cancel": (self.Exit, "Exit Picture Viewer"), }, -2) self.aspect = getAspect() currDir = config.plugins.EVOMC_pp.lastDir.value if not pathExists(currDir): currDir = "/" self["currentfolder"].setText(str(currDir)) self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)") self["filelist"] = self.filelist self["thumbnail"] = Pixmap() evfd.getInstance().vfd_write_string("EVO-PICVIEWER") self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.ThumbTimer.start(500, True) self.picload = ePicLoad()
def getFileList(self, param): if param["path"] == "playlist": mp = self.tryOpenMP() # TODO: Fix dummy return if unable to load mp if mp is None: return (("empty", True, "playlist"),) if mp.playlist: return [(serviceRef.getPath(), False, "playlist") for serviceRef in mp.playlist.getServiceRefList()] else: return (("empty", True, "playlist"),) matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob)" #MediaPlayer-Match useServiceRef = False if param["types"] == "audio": matchingPattern = "(?i)^.*\.(mp3|ogg|wav|wave|m3u|pls|e2pls)" useServiceRef = True elif param["types"] == "video": matchingPattern = "(?i)^.*\.(ts|avi|mpeg|m3u|pls|e2pls|mpg|vob)" useServiceRef = True elif param["types"] == "any": matchingPattern = ".*" elif param["types"]: matchingPattern = param["types"] path = param["path"] if path == "Filesystems": path = None elif path is not None and not os_path.isdir(path): # TODO: returning something is better than just dying but is this return sane? return ((None, True, path),) filelist = FileList(path, showDirectories=True, showFiles=True, matchingPattern=matchingPattern, useServiceRef=useServiceRef, isTop=False) list = filelist.getFileList() if useServiceRef is True: returnList = [ (x[0][0].toString(), x[0][1], path) if x[0][1] is False else (x[0][0], x[0][1], path) for x in list ] else: returnList = [ (param["path"] + x[0][0], x[0][1], path) if x[0][1] is False else (x[0][0], x[0][1], path) for x in list ] return returnList
def __init__(self, session): self.skin = """<screen position="80,80" size="560,440" title="PicturePlayer" > <ePixmap position="0,0" size="140,40" pixmap="skin_default/buttons/red.png" alphatest="on" /> <ePixmap position="140,0" size="140,40" pixmap="skin_default/buttons/green.png" alphatest="on" /> <ePixmap position="280,0" size="140,40" pixmap="skin_default/buttons/yellow.png" alphatest="on" /> <ePixmap position="420,0" size="140,40" pixmap="skin_default/buttons/blue.png" alphatest="on" /> <widget name="key_red" position="0,0" size="140,40" font="Regular;20" backgroundColor="#9f1313" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" /> <widget name="key_green" position="140,0" size="140,40" font="Regular;20" backgroundColor="#1f771f" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" /> <widget name="key_yellow" position="280,0" size="140,40" font="Regular;20" backgroundColor="#a08500" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" /> <widget name="key_blue" position="420,0" size="140,40" font="Regular;20" backgroundColor="#18188b" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" /> <widget name="label" position="5,55" size="350,140" font="Regular;19" /> <widget name="thn" position="360,40" size="180,160" alphatest="on" /> <widget name="filelist" position="5,205" zPosition="2" size="550,230" scrollbarMode="showOnDemand" /> </screen>""" Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions"], { "cancel": self.KeyExit, "red": self.KeyRed, "yellow": self.KeyYellow, "blue": self.KeyBlue, "ok": self.KeyOk }, -1) self["key_red"] = Button(_("Thumbnails")) self["key_green"] = Button() self["key_yellow"] = Button(_("Exif")) self["key_blue"] = Button(_("Setup")) self["label"] = Label() self["thn"] = Pixmap() currDir = config.pic.lastDir.value if not pathExists(currDir): currDir = "/" self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)") self["filelist"] = self.filelist self["filelist"].onSelectionChanged.append(self.selectionChanged) self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.picload = ePicLoad() self.picload.PictureData.get().append(self.showPic) self.onLayoutFinish.append(self.setConf)
def __init__( self, session, startdir, message="", showDirectories=True, showFiles=True, showMountpoints=True, matchingPattern="", useServiceRef=False, inhibitDirs=False, inhibitMounts=False, isTop=False, enableWrapAround=False, additionalExtensions=None, ): Screen.__init__(self, session) HelpableScreen.__init__(self) Screen.setTitle(self, _("Please select medium")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText() self["message"] = StaticText(message) self.filelist = FileList( startdir, showDirectories=showDirectories, showFiles=showFiles, showMountpoints=showMountpoints, matchingPattern=matchingPattern, useServiceRef=useServiceRef, inhibitDirs=inhibitDirs, inhibitMounts=inhibitMounts, isTop=isTop, enableWrapAround=enableWrapAround, additionalExtensions=additionalExtensions, ) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], {"green": self.use, "red": self.exit, "ok": self.ok, "cancel": self.exit} ) hotplugNotifier.append(self.hotplugCB) self.onShown.append(self.updateButton) self.onClose.append(self.removeHotplug)
def __init__(self, session, scope, configRef): Screen.__init__(self, session) # for the skin: first try FileBrowser_DVDBurn, then FileBrowser, this allows individual skinning self.skinName = ["FileBrowser_DVDBurn", "FileBrowser" ] HelpableScreen.__init__(self) self.scope = scope pattern = "" self.configRef = configRef currDir = "/" if self.scope == "project": currDir = self.getDir() pattern = "(?i)^.*\.(ddvdp\.xml)" elif self.scope == "menutemplate": currDir = self.getDir() pattern = "(?i)^.*\.(ddvdm\.xml)" if self.scope == "menubg": currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)" elif self.scope == "menuaudio": currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(mp2|m2a|ac3)" elif self.scope == "vmgm": currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(mpg|mpeg)" elif self.scope == "font_face": currDir = self.getDir(configRef.getValue(), resolveFilename(SCOPE_FONTS)) pattern = "(?i)^.*\.(ttf)" elif self.scope == "isopath": currDir = configRef.getValue() elif self.scope == "image": currDir = resolveFilename(SCOPE_HDD) pattern = "(?i)^.*\.(iso)" self.filelist = FileList(currDir, matchingPattern=pattern) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap(["SetupActions"], { "save": self.ok, "ok": self.ok, "cancel": self.exit }) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session, downloadDir): Screen.__init__(self, session) self.skinName = ['YouTubeDirBrowser', 'FileBrowser'] self['key_red'] = StaticText(_('Cancel')) self['key_green'] = StaticText(_('Use')) if not os.path.exists(downloadDir): downloadDir = '/' self.filelist = FileList(downloadDir, showFiles = False) self['filelist'] = self.filelist self['FilelistActions'] = ActionMap(['SetupActions', 'ColorActions'], { 'cancel': self.cancel, 'red': self.cancel, 'ok': self.ok, 'green': self.use }, -2) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session, currDir): Screen.__init__(self, session) self.skinName = ["EMCFileBrowser"] HelpableScreen.__init__(self) self["cancel"] = Button(_("Cancel")) self["open"] = Button(_("Open")) self.filelist = FileList(currDir, showFiles=True, matchingPattern=".(e2pls|m3u)") self["filelist"] = self.filelist self.lastDir = currDir self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "ok": self.ok, "cancel": self.exit }) self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session, currDir): from Components.Sources.StaticText import StaticText Screen.__init__(self, session) HelpableScreen.__init__(self) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Use")) self.filelist = FileList(currDir, matchingPattern="") self["filelist"] = self.filelist self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "ok": self.ok, "cancel": self.exit })
def __init__(self, session, curdir, matchingPattern=None): Screen.__init__(self, session) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Save")) self["curdir"] = StaticText("current: %s"%(curdir or '')) self.filelist = FileList(curdir, matchingPattern=matchingPattern, enableWrapAround=True) self.filelist.onSelectionChanged.append(self.__selChanged) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], { "green": self.keyGreen, "red": self.keyRed, "ok": self.keyOk, "cancel": self.keyRed }) self.onLayoutFinish.append(self.__layoutFinished)
def __init__(self, session): Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MenuActions"], { "cancel": self.KeyExit, "red": self.KeyExit, "green": self.KeyGreen, "yellow": self.KeyYellow, "menu": self.KeyMenu, "ok": self.KeyOk }, -1) self["key_red"] = StaticText(_("Close")) self["key_green"] = StaticText(_("Thumbnails")) self["key_yellow"] = StaticText("") self["label"] = StaticText("") self["thn"] = Pixmap() currDir = config.pic.lastDir.value if not pathExists(currDir): currDir = "/" self.oldService = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() # Show Background MVI import os try: os.system("/usr/bin/showiframe /usr/share/enigma2/black.mvi &") except: pass self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)") self["filelist"] = self.filelist self["filelist"].onSelectionChanged.append(self.selectionChanged) self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.picload = ePicLoad() self.picload.PictureData.get().append(self.showPic) self.onLayoutFinish.append(self.setConf)
def __init__(self, session, currDir): Screen.__init__(self, session) # for the skin: first try MediaPlayerDirectoryBrowser, then FileBrowser, this allows individual skinning self.skinName = ["MediaPlayerDirectoryBrowser", "FileBrowser" ] HelpableScreen.__init__(self) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Use")) self.filelist = FileList(currDir, matchingPattern="") self["filelist"] = self.filelist self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "ok": self.ok, "cancel": self.exit }) self.onLayoutFinish.append(self.layoutFinished)
class picshow(Screen): skin = """ <screen name="picshow" position="center,80" size="1200,610" title="PicturePlayer"> <ePixmap pixmap="skin_default/buttons/red.png" position="10,5" size="200,40" /> <ePixmap pixmap="skin_default/buttons/green.png" position="210,5" size="200,40" /> <ePixmap pixmap="skin_default/buttons/yellow.png" position="410,5" size="200,40" /> <ePixmap pixmap="skin_default/buttons/blue.png" position="610,5" size="200,40" /> <widget source="key_red" render="Label" position="10,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-2,-2" /> <widget source="key_green" render="Label" position="210,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-2,-2" /> <widget source="key_yellow" render="Label" position="410,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-2,-2" /> <widget source="key_blue" render="Label" position="610,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-2,-2" /> <widget source="global.CurrentTime" render="Label" position="1130,12" size="60,25" font="Regular;22" halign="right"> <convert type="ClockToText">Default</convert> </widget> <widget source="global.CurrentTime" render="Label" position="820,12" size="300,25" font="Regular;22" halign="right"> <convert type="ClockToText">Format:%A %d. %B</convert> </widget> <eLabel position="10,50" size="1180,1" backgroundColor="grey" /> <eLabel position="380,50" size="1,585" backgroundColor="grey" /> <widget name="path" position="400,60" size="790,30" font="Regular;24"/> <eLabel position="380,90" size="810,1" backgroundColor="grey" /> <widget source="label" render="Label" position="20,370" size="330,140" font="Regular;19"/> <widget name="thn" position="40,60" size="300,300" /> <widget name="filelist" position="400,95" size="790,510" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session): Screen.__init__(self, session) self["actions"] = ActionMap( ["OkCancelActions", "ColorActions", "DirectionActions"], { "cancel": self.KeyExit, "red": self.KeyExit, "green": self.KeyGreen, "yellow": self.KeyYellow, "blue": self.KeyBlue, "ok": self.KeyOk }, -1) self["key_red"] = StaticText(_("Close")) self["key_green"] = StaticText(_("Thumbnails")) self["key_yellow"] = StaticText("") self["key_blue"] = StaticText(_("Setup")) self["label"] = StaticText("") self["thn"] = Pixmap() currDir = config.pic.lastDir.value if not pathExists(currDir): currDir = "/" self["path"] = Label(currDir) self.filelist = FileList( currDir, matchingPattern="(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)") self["filelist"] = self.filelist self["filelist"].onSelectionChanged.append(self.selectionChanged) self.ThumbTimer = eTimer() self.ThumbTimer_conn = self.ThumbTimer.timeout.connect(self.showThumb) self.picload = ePicLoad() self.picload_conn = self.picload.PictureData.connect(self.showPic) self.onLayoutFinish.append(self.setConf) def showPic(self, picInfo=""): ptr = self.picload.getData() if ptr != None: setPixmap(self["thn"], ptr, self._scaleSize, self._aspectRatio) self["thn"].show() text = picInfo.split('\n', 1) self["label"].setText(text[1]) self["key_yellow"].setText(_("Exif")) def showThumb(self): if not self.filelist.canDescent(): if self.filelist.getCurrentDirectory( ) and self.filelist.getFilename(): if self.picload.getThumbnail( self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1: self.ThumbTimer.start(config.pic.thumbDelay.value, True) def selectionChanged(self): if not self.filelist.canDescent(): self.ThumbTimer.start(config.pic.thumbDelay.value, True) else: self["label"].setText("") self["thn"].hide() self["key_yellow"].setText("") def KeyGreen(self): #if not self.filelist.canDescent(): self.session.openWithCallback(self.callbackView, Pic_Thumb, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) def KeyYellow(self): if not self.filelist.canDescent(): self.session.open( Pic_Exif, self.picload.getInfo(self.filelist.getCurrentDirectory() + self.filelist.getFilename())) def KeyBlue(self): self.session.openWithCallback(self.setConf, Pic_Setup) def KeyOk(self): if self.filelist.canDescent(): self.filelist.descent() self["path"].setText(self.filelist.getCurrentDirectory()) else: self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) def setConf(self): self.setTitle(_("PicturePlayer")) sc = getScale() self._aspectRatio = eSize(sc[0], sc[1]) self._scaleSize = self["thn"].instance.size() #0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB) params = (self._scaleSize.width(), self._scaleSize.height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), "#00000000") self.picload.setPara(params) def callbackView(self, val=0): if val > 0: self.filelist.moveToIndex(val) def KeyExit(self): self.ThumbTimer.stop() del self.picload_conn del self.picload if self.filelist.getCurrentDirectory() is None: config.pic.lastDir.value = "/" else: config.pic.lastDir.value = self.filelist.getCurrentDirectory() config.pic.save() self.close()
class FlashImageConfig(Screen): def __init__(self, session, curdir, matchingPattern=None): try: sz_w = getDesktop(0).size().width() except: sz_w = 720 if sz_w == 1920: self.skin = skinflashfullhd elif sz_w >= 1280: self.skin = skinflashhd else: self.skin = skinflashsd Screen.__init__(self, session) self.skin_path = resolveFilename(SCOPE_PLUGINS, "Extensions/BackupSuite") self["Title"].setText(_("Select the folder with backup")) self["key_red"] = StaticText(_("Close")) self["key_green"] = StaticText("") self["key_yellow"] = StaticText("") self["key_blue"] = StaticText("") self["curdir"] = StaticText(_("current: %s") % (curdir or '')) self.founds = False self.dualboot = self.dualBoot() self.ForceMode = self.ForceMode() self.filelist = FileList(curdir, matchingPattern=matchingPattern, enableWrapAround=True) self.filelist.onSelectionChanged.append(self.__selChanged) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], { "green": self.keyGreen, "red": self.keyRed, "yellow": self.keyYellow, "blue": self.KeyBlue, "ok": self.keyOk, "cancel": self.keyRed }) self.onLayoutFinish.append(self.__layoutFinished) def __layoutFinished(self): pass def dualBoot(self): if BoxInfo.getItem("model") == "et8500": rootfs2 = False kernel2 = False f = open("/proc/mtd") l = f.readlines() for x in l: if 'rootfs2' in x: rootfs2 = True if 'kernel2' in x: kernel2 = True f.close() if rootfs2 and kernel2: return True return False def ForceMode(self): if BoxInfo.getItem("platform") in ("zgemmahisi3798mv200", "zgemmahisi3716mv430"): return True return False def getCurrentSelected(self): dirname = self.filelist.getCurrentDirectory() filename = self.filelist.getFilename() if not filename and not dirname: cur = '' elif not filename: cur = dirname elif not dirname: cur = filename else: if not self.filelist.canDescent() or len(filename) <= len(dirname): cur = dirname else: cur = filename return cur or '' def __selChanged(self): self["key_yellow"].setText("") self["key_green"].setText("") self["key_blue"].setText("") self["curdir"].setText(_("current: %s") % (self.getCurrentSelected())) file_name = self.getCurrentSelected() try: if not self.filelist.canDescent( ) and file_name != '' and file_name != '/': filename = self.filelist.getFilename() if filename and filename.endswith(".zip"): self["key_yellow"].setText(_("Unzip")) elif self.filelist.canDescent( ) and file_name != '' and file_name != '/': if os.path.isfile(file_name + LOGFILE) and os.path.isfile(file_name + VERSIONFILE): self["key_green"].setText(_("Run flash")) self["key_yellow"].setText(_("Backup info")) self["key_blue"].setText(_("Delete")) except: pass def keyOk(self): if self.filelist.canDescent(): self.filelist.descent() def confirmedWarning(self, result): if result: self.founds = False self.showparameterlist() def keyGreen(self): if self["key_green"].getText() == _("Run flash"): dirname = self.filelist.getCurrentDirectory() if dirname: warning_text = "\n" if self.dualboot: warning_text += _("\nYou are using dual multiboot!") self.session.openWithCallback( lambda r: self.confirmedWarning(r), MessageBox, _("Warning!\nUse at your own risk! Make always a backup before use!\nDon't use it if you use multiple ubi volumes in ubi layer!" ) + warning_text, MessageBox.TYPE_INFO) def showparameterlist(self): if self["key_green"].getText() == _("Run flash"): dirname = self.getCurrentSelected() if dirname: backup_files = [] text = _("Select parameter for start flash!\n") text += _('For flashing your receiver files are needed:\n') backup_files = [(rootfile, kernelfile)] text += rootfile + ", " + kernelfile try: self.founds = False text += _('\nThe found files:') for name in os.listdir(dirname): if name in backup_files: text += _(" %s (maybe ok)") % name self.founds = True if not self.founds: text += _(' nothing!') except: pass if self.founds: open_list = [ (_("Simulate (no write)"), "simulate"), (_("Standard (root and kernel)"), "standard"), (_("Only root"), "root"), (_("Only kernel"), "kernel"), ] open_list2 = [ (_("Simulate second partition (no write)"), "simulate2"), (_("Second partition (root and kernel)"), "standard2"), (_("Second partition (only root)"), "rootfs2"), (_("Second partition (only kernel)"), "kernel2"), ] if self.dualboot: open_list += open_list2 else: open_list = [ (_("Exit"), "exit"), ] self.session.openWithCallback(self.Callbackflashing, MessageBox, text, simple=True, list=open_list) def Callbackflashing(self, ret): if ret: if ret == "exit": self.close() return if self.session.nav.RecordTimer.isRecording(): self.session.open( MessageBox, _("A recording is currently running. Please stop the recording before trying to start a flashing." ), MessageBox.TYPE_ERROR) self.founds = False return dir_flash = self.getCurrentSelected() text = _("Flashing: ") cmd = "echo -e" if ret == "simulate": text += _("Simulate (no write)") cmd = "%s -n '%s'" % (ofgwrite_bin, dir_flash) elif ret == "standard": text += _("Standard (root and kernel)") if self.ForceMode: cmd = "%s -f -r -k '%s' > /dev/null 2>&1 &" % ( ofgwrite_bin, dir_flash) else: cmd = "%s -r -k '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) elif ret == "root": text += _("Only root") cmd = "%s -r '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) elif ret == "kernel": text += _("Only kernel") cmd = "%s -k '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) elif ret == "simulate2": text += _("Simulate second partition (no write)") cmd = "%s -kmtd3 -rmtd4 -n '%s'" % (ofgwrite_bin, dir_flash) elif ret == "standard2": text += _("Second partition (root and kernel)") cmd = "%s -kmtd3 -rmtd4 '%s' > /dev/null 2>&1 &" % ( ofgwrite_bin, dir_flash) elif ret == "rootfs2": text += _("Second partition (only root)") cmd = "%s -rmtd4 '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) elif ret == "kernel2": text += _("Second partition (only kernel)") cmd = "%s -kmtd3 '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) else: return message = "echo -e '\n" message += _('NOT found files for flashing!\n') message += "'" if ret == "simulate" or ret == "simulate2": if self.founds: message = "echo -e '\n" message += _('Show only found image and mtd partitions.\n') message += "'" else: if self.founds: message = "echo -e '\n" message += _( 'ofgwrite will stop enigma2 now to run the flash.\n') message += _( 'Your STB will freeze during the flashing process.\n') message += _( 'Please: DO NOT reboot your STB and turn off the power.\n' ) message += _( 'The image or kernel will be flashing and auto booted in few minutes.\n' ) message += "'" self.session.open(Console, text, [message, cmd]) def keyRed(self): self.close() def keyYellow(self): if self["key_yellow"].getText() == _("Unzip"): filename = self.filelist.getFilename() if filename and filename.endswith(".zip"): self.session.openWithCallback( self.doUnzip, MessageBox, _("Do you really want to unpack %s ?") % filename, MessageBox.TYPE_YESNO) elif self["key_yellow"].getText() == _("Backup info"): self.session.open(MessageBox, "\n\n\n%s" % self.getBackupInfo(), MessageBox.TYPE_INFO) def getBackupInfo(self): backup_dir = self.getCurrentSelected() backup_info = "" for line in open(backup_dir + VERSIONFILE, "r"): backup_info += line return backup_info def doUnzip(self, answer): if answer is True: dirname = self.filelist.getCurrentDirectory() filename = self.filelist.getFilename() if dirname and filename: try: os.system('unzip -o %s%s -d %s' % (dirname, filename, dirname)) self.filelist.refresh() except: pass def confirmedDelete(self, answer): if answer is True: backup_dir = self.getCurrentSelected() cmdmessage = "echo -e 'Removing backup: %s\n'" % os.path.basename( backup_dir.rstrip('/')) cmddelete = "rm -rf %s > /dev/null 2>&1" % backup_dir self.session.open(Console, _("Delete backup"), [cmdmessage, cmddelete], self.filelist.refresh) def KeyBlue(self): if self["key_blue"].getText() == _("Delete"): self.session.openWithCallback( self.confirmedDelete, MessageBox, _("You are about to delete this backup:\n\n%s\nContinue?") % self.getBackupInfo(), MessageBox.TYPE_YESNO)
def __init__(self, session, destdir="/tmp/"): self.skin = NFIDownload.skin Screen.__init__(self, session) self["job_progressbar"] = Progress() self["job_progresslabel"] = StaticText() self["infolabel"] = StaticText() self["statusbar"] = StaticText() self["label_top"] = StaticText() self["label_bottom"] = StaticText() self["path_bottom"] = StaticText() self["key_green"] = StaticText() self["key_yellow"] = StaticText() self["key_blue"] = StaticText() self["key_red"] = StaticText() self["feedlist"] = Feedlist([ 0, (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 250, 30, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, "feed not available") ]) self["destlist"] = FileList(destdir, showDirectories=True, showFiles=False) self["destlist"].hide() self.download_container = eConsoleAppContainer() self.nfo = "" self.nfofile = "" self.feedhtml = "" self.focus = None self.download = None self.box = HardwareInfo().get_device_name() self.feed_base = "http://www.dreamboxupdate.com/opendreambox/1.5/%s/images/" % self.box self.nfi_filter = "" # "release" # only show NFIs containing this string, or all if "" self.wizard_mode = False self["actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "DirectionActions", "EPGSelectActions" ], { "cancel": self.closeCB, "red": self.closeCB, "green": self.nfi_download, "yellow": self.switchList, "blue": self.askCreateUSBstick, "prevBouquet": self.switchList, "nextBouquet": self.switchList, "ok": self.ok, "left": self.left, "right": self.right, "up": self.up, "upRepeated": self.up, "downRepeated": self.down, "down": self.down }, -1) self.feed_download()
class DeviceBrowser(Screen, HelpableScreen): skin = '\n\t\t<screen name="DeviceBrowser" position="center,center" size="520,430" >\n\t\t\t<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t\t<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />\n\t\t\t<widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t\t<widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />\n\t\t\t<widget source="message" render="Label" position="5,50" size="510,150" font="Regular;16" />\n\t\t\t<widget name="filelist" position="5,210" size="510,220" scrollbarMode="showOnDemand" />\n\t\t</screen>' def __init__(self, session, startdir, message = '', showDirectories = True, showFiles = True, showMountpoints = True, matchingPattern = '', useServiceRef = False, inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = False, additionalExtensions = None): Screen.__init__(self, session) HelpableScreen.__init__(self) Screen.setTitle(self, _('Please select medium')) #edit lululla # self['key_red'] = StaticText(_('Cancel')) # self['key_green'] = StaticText() # self['message'] = StaticText(message) self['key_green'] = Label(_('')) self['key_red'] = Label(_('Cancel')) self['message'] = Label(_('')) self['message'].setText(message) ############## self.filelist = FileList(startdir, showDirectories=showDirectories, showFiles=showFiles, showMountpoints=showMountpoints, matchingPattern=matchingPattern, useServiceRef=useServiceRef, inhibitDirs=inhibitDirs, inhibitMounts=inhibitMounts, isTop=isTop, enableWrapAround=enableWrapAround, additionalExtensions=additionalExtensions) self['filelist'] = self.filelist self['FilelistActions'] = ActionMap(['SetupActions', 'ColorActions'], {'green': self.use, 'red': self.exit, 'ok': self.ok, 'cancel': self.exit}) hotplugNotifier.append(self.hotplugCB) self.onShown.append(self.updateButton) self.onClose.append(self.removeHotplug) def hotplugCB(self, dev, action): print '[hotplugCB]', dev, action self.updateButton() def updateButton(self): if self['filelist'].getFilename() or self['filelist'].getCurrentDirectory(): #edit lululla # self['key_green'].text = _('Flash') # else: # self['key_green'].text = '' ############# self['key_green'].setText('Flash') else: self['key_green'].setText('') def removeHotplug(self): print '[removeHotplug]' hotplugNotifier.remove(self.hotplugCB) def ok(self): if self.filelist.canDescent(): if self['filelist'].showMountpoints == True and self['filelist'].showDirectories == False: self.use() else: self.filelist.descent() def use(self): print '[use]', self['filelist'].getCurrentDirectory(), self['filelist'].getFilename() if self['filelist'].getFilename() is not None and self['filelist'].getCurrentDirectory() is not None: if self['filelist'].getFilename().endswith('.bin') or self['filelist'].getFilename().endswith('.ubi') or self['filelist'].getFilename().endswith('.jffs2'): self.close(self['filelist'].getCurrentDirectory(), self['filelist'].getFilename(), 0) elif self['filelist'].getFilename().endswith('.zip'): self.close(self['filelist'].getCurrentDirectory(), self['filelist'].getFilename(), 1) else: return return def exit(self): self.close(False, False, -1)
class FlashImageConfig(Screen): def __init__(self, session, curdir, matchingPattern=None): try: sz_w = getDesktop(0).size().width() except: sz_w = 720 if sz_w == 1920: self.skin = skinflashfullhd elif sz_w >= 1280: self.skin = skinflashhd else: self.skin = skinflashsd Screen.__init__(self, session) self['Title'].setText(_('Select the folder with backup')) self['key_red'] = StaticText(_('Close')) self['key_green'] = StaticText('') self['key_yellow'] = StaticText('') self['key_blue'] = StaticText('') self['curdir'] = StaticText(_('current: %s') % (curdir or '')) self.founds = False self.dualboot = self.dualBoot() self.ForceMode = self.ForceMode() self.filelist = FileList(curdir, matchingPattern=matchingPattern, enableWrapAround=True) self.filelist.onSelectionChanged.append(self.__selChanged) self['filelist'] = self.filelist self['FilelistActions'] = ActionMap( ['SetupActions', 'ColorActions'], { 'green': self.keyGreen, 'red': self.keyRed, 'yellow': self.keyYellow, 'blue': self.KeyBlue, 'ok': self.keyOk, 'cancel': self.keyRed }) self.onLayoutFinish.append(self.__layoutFinished) def __layoutFinished(self): pass def dualBoot(self): if getBoxType() == 'et8500': rootfs2 = False kernel2 = False f = open('/proc/mtd') l = f.readlines() for x in l: if 'rootfs2' in x: rootfs2 = True if 'kernel2' in x: kernel2 = True f.close() if rootfs2 and kernel2: return True return False def ForceMode(self): if getBoxType() in ('h9', 'h9combo', 'i55plus', 'h10'): return True return False def getCurrentSelected(self): dirname = self.filelist.getCurrentDirectory() filename = self.filelist.getFilename() if not filename and not dirname: cur = '' elif not filename: cur = dirname elif not dirname: cur = filename elif not self.filelist.canDescent() or len(filename) <= len(dirname): cur = dirname else: cur = filename return cur or '' def __selChanged(self): self['key_yellow'].setText('') self['key_green'].setText('') self['key_blue'].setText('') self['curdir'].setText(_('current: %s') % self.getCurrentSelected()) file_name = self.getCurrentSelected() try: if not self.filelist.canDescent( ) and file_name != '' and file_name != '/': filename = self.filelist.getFilename() if filename and filename.endswith('.zip'): self['key_yellow'].setText(_('Unzip')) elif self.filelist.canDescent( ) and file_name != '' and file_name != '/': self['key_green'].setText(_('Run flash')) if os.path.isfile(file_name + LOGFILE) and os.path.isfile(file_name + VERSIONFILE): self['key_yellow'].setText(_('Backup info')) self['key_blue'].setText(_('Delete')) except: pass def keyOk(self): if self.filelist.canDescent(): self.filelist.descent() def confirmedWarning(self, result): if result: self.founds = False self.showparameterlist() def keyGreen(self): if self['key_green'].getText() == _('Run flash'): dirname = self.filelist.getCurrentDirectory() if dirname: warning_text = '\n' if self.dualboot: warning_text += _('\nYou are using dual multiboot!') self.session.openWithCallback( lambda r: self.confirmedWarning(r), MessageBox, _("Warning!\nUse at your own risk! Make always a backup before use!\nDon't use it if you use multiple ubi volumes in ubi layer!" ) + warning_text, MessageBox.TYPE_INFO) def showparameterlist(self): if self['key_green'].getText() == _('Run flash'): dirname = self.getCurrentSelected() model = getBoxType() if dirname: backup_files = [] no_backup_files = [] text = _('Select parameter for start flash!\n') text += _('For flashing your receiver files are needed:\n') if model.startswith('dm'): if 'dm9' in model: backup_files = ['kernel.bin', 'rootfs.tar.bz2'] no_backup_files = [ 'kernel_cfe_auto.bin', 'rootfs.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel.bin, rootfs.tar.bz2' elif model in ('dm520', 'dm7080', 'dm820'): backup_files = ['*.xz'] no_backup_files = [ 'kernel_cfe_auto.bin', 'rootfs.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel_auto.bin', 'kernel.bin', 'rootfs.tar.bz2', 'uImage', 'rootfs.ubi' ] text += '*.xz' else: backup_files = ['*.nfi'] no_backup_files = [ 'kernel_cfe_auto.bin', 'rootfs.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel_auto.bin', 'kernel.bin', 'rootfs.tar.bz2', 'uImage', 'rootfs.ubi' ] text += '*.nfi' elif model.startswith('gb'): if '4k' not in model: backup_files = ['kernel.bin', 'rootfs.bin'] no_backup_files = [ 'kernel_cfe_auto.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'rootfs.tar.bz2', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel.bin, rootfs.bin' else: backup_files = ['kernel.bin', 'rootfs.tar.bz2'] no_backup_files = [ 'kernel_cfe_auto.bin', 'rootfs.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel.bin, rootfs.tar.bz2' elif model.startswith('vu'): if '4k' in model: backup_files = ['kernel_auto.bin', 'rootfs.tar.bz2'] no_backup_files = [ 'kernel_cfe_auto.bin', 'rootfs.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel_auto.bin, rootfs.tar.bz2' elif model in ('vuduo2', 'vusolose', 'vusolo2', 'vuzero'): backup_files = [ 'kernel_cfe_auto.bin', 'root_cfe_auto.bin' ] no_backup_files = [ 'rootfs.bin', 'root_cfe_auto.jffs2', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel.bin', 'rootfs.tar.bz2', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel_cfe_auto.bin, root_cfe_auto.bin' else: backup_files = [ 'kernel_cfe_auto.bin', 'root_cfe_auto.jffs2' ] no_backup_files = [ 'rootfs.bin', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel.bin', 'rootfs.tar.bz2', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel_cfe_auto.bin, root_cfe_auto.jffs2' elif model in ('hd51', 'h7', 'sf4008', 'sf5008', 'sf8008', 'vs1500', 'et11000', 'et13000', 'bre2ze4k', 'spycat4k', 'spycat4kmini', 'protek4k', 'e4hdultra', 'cc1', 'spycatminiv2', 'iziboxecohd', 'jdhdduo', 'turing', 'arivacombo', 'arivatwin') or model.startswith( ('anadol', 'axashis4', 'dinobot4', 'ferguson4', 'mediabox4', 'axashisc4')): backup_files = ['kernel.bin', 'rootfs.tar.bz2'] no_backup_files = [ 'kernel_cfe_auto.bin', 'rootfs.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel.bin, rootfs.tar.bz2' elif model in ('h9', 'h9combo', 'i55plus', 'h10', 'dinobotu55', 'iziboxx3', 'dinoboth265', 'axashistwin', 'protek4kx1'): backup_files = ['uImage', 'rootfs.ubi'] no_backup_files = [ 'kernel_cfe_auto.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'rootfs.tar.bz2', 'kernel_auto.bin', 'kernel.bin', 'rootfs.tar.bz2' ] text += 'uImage, rootfs.ubi' elif model in ('hd60', 'hd61', 'multibox', 'multiboxplus', 'v8plus'): backup_files = ['uImage', 'rootfs.tar.bz2'] no_backup_files = [ 'kernel_cfe_auto.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'rootfs.ubi', 'kernel_auto.bin', 'kernel.bin' ] text += 'uImage, rootfs.tar.bz2' elif model.startswith( ('et4', 'et5', 'et6', 'et7', 'et8', 'et9', 'et10')): backup_files = ['kernel.bin', 'rootfs.bin'] no_backup_files = [ 'kernel_cfe_auto.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'rootfs.tar.bz2', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel.bin, rootfs.bin' elif model.startswith('ebox'): backup_files = [ 'kernel_cfe_auto.bin', 'root_cfe_auto.jffs2' ] no_backup_files = [ 'rootfs.bin', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'kernel.bin', 'rootfs.tar.bz2', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel_cfe_auto.bin, root_cfe_auto.jffs2' elif model.startswith( ('fusion', 'pure', 'optimus', 'force', 'iqon', 'ios', 'tm2', 'tmn', 'tmt', 'tms', 'lunix', 'mediabox', 'vala')): backup_files = ['oe_kernel.bin', 'oe_rootfs.bin'] no_backup_files = [ 'kernel_cfe_auto.bin', 'rootfs.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'kernel.bin', 'rootfs.tar.bz2', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'oe_kernel.bin, oe_rootfs.bin' elif '4k' or 'uhd' in model: backup_files = ['oe_kernel.bin', 'rootfs.tar.bz2'] no_backup_files = [ 'kernel_cfe_auto.bin', 'rootfs.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_rootfs.bin', 'kernel.bin', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'oe_kernel.bin, rootfs.tar.bz2' else: backup_files = ['kernel.bin', 'rootfs.bin'] no_backup_files = [ 'kernel_cfe_auto.bin', 'root_cfe_auto.jffs2', 'root_cfe_auto.bin', 'oe_kernel.bin', 'oe_rootfs.bin', 'rootfs.tar.bz2', 'kernel_auto.bin', 'uImage', 'rootfs.ubi' ] text += 'kernel.bin, rootfs.bin' try: self.founds = False text += _('\nThe found files:') for name in os.listdir(dirname): if name in backup_files: text += _(' %s (maybe ok)') % name self.founds = True if name in no_backup_files: text += _(' %s (maybe error)') % name self.founds = True if not self.founds: text += _(' nothing!') except: pass if self.founds: open_list = [(_('Simulate (no write)'), 'simulate'), (_('Standard (root and kernel)'), 'standard'), (_('Only root'), 'root'), (_('Only kernel'), 'kernel')] open_list2 = [ (_('Simulate second partition (no write)'), 'simulate2'), (_('Second partition (root and kernel)'), 'standard2'), (_('Second partition (only root)'), 'rootfs2'), (_('Second partition (only kernel)'), 'kernel2') ] if self.dualboot: open_list += open_list2 else: open_list = [(_('Exit'), 'exit')] self.session.openWithCallback(self.Callbackflashing, MessageBox, text, simple=True, list=open_list) def Callbackflashing(self, ret): if ret: if ret == 'exit': self.close() return if self.session.nav.RecordTimer.isRecording(): self.session.open( MessageBox, _('A recording is currently running. Please stop the recording before trying to start a flashing.' ), MessageBox.TYPE_ERROR) self.founds = False return dir_flash = self.getCurrentSelected() text = _('Flashing: ') cmd = 'echo -e' if ret == 'simulate': text += _('Simulate (no write)') cmd = "%s -n '%s'" % (ofgwrite_bin, dir_flash) elif ret == 'standard': text += _('Standard (root and kernel)') if self.ForceMode: cmd = "%s -f -r -k '%s' > /dev/null 2>&1 &" % ( ofgwrite_bin, dir_flash) else: cmd = "%s -r -k '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) elif ret == 'root': text += _('Only root') cmd = "%s -r '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) elif ret == 'kernel': text += _('Only kernel') cmd = "%s -k '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) elif ret == 'simulate2': text += _('Simulate second partition (no write)') cmd = "%s -kmtd3 -rmtd4 -n '%s'" % (ofgwrite_bin, dir_flash) elif ret == 'standard2': text += _('Second partition (root and kernel)') cmd = "%s -kmtd3 -rmtd4 '%s' > /dev/null 2>&1 &" % ( ofgwrite_bin, dir_flash) elif ret == 'rootfs2': text += _('Second partition (only root)') cmd = "%s -rmtd4 '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) elif ret == 'kernel2': text += _('Second partition (only kernel)') cmd = "%s -kmtd3 '%s' > /dev/null 2>&1 &" % (ofgwrite_bin, dir_flash) else: return message = "echo -e '\n" message += _('NOT found files for flashing!\n') message += "'" if ret == 'simulate' or ret == 'simulate2': if self.founds: message = "echo -e '\n" message += _('Show only found image and mtd partitions.\n') message += "'" elif self.founds: message = "echo -e '\n" message += _( 'ofgwrite will stop enigma2 now to run the flash.\n') message += _( 'Your STB will freeze during the flashing process.\n') message += _( 'Please: DO NOT reboot your STB and turn off the power.\n') message += _( 'The image or kernel will be flashing and auto booted in few minutes.\n' ) message += "'" self.session.open(Console, text, [message, cmd]) def keyRed(self): self.close() def keyYellow(self): if self['key_yellow'].getText() == _('Unzip'): filename = self.filelist.getFilename() if filename and filename.endswith('.zip'): self.session.openWithCallback( self.doUnzip, MessageBox, _('Do you really want to unpack %s ?') % filename, MessageBox.TYPE_YESNO) elif self['key_yellow'].getText() == _('Backup info'): self.session.open(MessageBox, '\n\n\n%s' % self.getBackupInfo(), MessageBox.TYPE_INFO) def getBackupInfo(self): backup_dir = self.getCurrentSelected() backup_info = '' for line in open(backup_dir + VERSIONFILE, 'r'): backup_info += line return backup_info def doUnzip(self, answer): if answer is True: dirname = self.filelist.getCurrentDirectory() filename = self.filelist.getFilename() if dirname and filename: try: os.system('unzip -o %s%s -d %s' % (dirname, filename, dirname)) self.filelist.refresh() except: pass def confirmedDelete(self, answer): if answer is True: backup_dir = self.getCurrentSelected() cmdmessage = "echo -e 'Removing backup: %s\n'" % os.path.basename( backup_dir.rstrip('/')) cmddelete = 'rm -rf %s > /dev/null 2>&1' % backup_dir self.session.open(Console, _('Delete backup'), [cmdmessage, cmddelete], self.filelist.refresh) def KeyBlue(self): if self['key_blue'].getText() == _('Delete'): self.session.openWithCallback( self.confirmedDelete, MessageBox, _('You are about to delete this backup:\n\n%s\nContinue?') % self.getBackupInfo(), MessageBox.TYPE_YESNO)
class MC_PictureViewer(Screen, HelpableScreen): def __init__(self, session): Screen.__init__(self, session) HelpableScreen.__init__(self) self["key_green"] = Button("Slide Show") self["key_yellow"] = Button("Thumb View") self["currentfolder"] = Label("") self["currentfavname"] = Label("") self["actions"] = HelpableActionMap( self, "MC_PictureViewerActions", { "ok": (self.KeyOk, "Show Picture"), "cancel": (self.Exit, "Exit Picture Viewer"), "left": (self.leftUp, "List Top"), "right": (self.rightDown, "List Bottom"), "up": (self.up, "List up"), "down": (self.down, "List down"), "info": (self.StartExif, "Show File Info"), "green": (self.startslideshow, "Start Slideshow"), "yellow": (self.StartThumb, "Thumb View"), "blue": (self.Settings, "Settings"), }, -2) self.aspect = getAspect() currDir = config.plugins.mc_pp.lastDir.value if not pathExists(currDir): currDir = "/" self["currentfolder"].setText(str(currDir)) self.filelist = [] self["filelist"] = [] inhibitDirs = [ "/bin", "/boot", "/dev", "/dev.static", "/etc", "/lib", "/proc", "/ram", "/root", "/sbin", "/sys", "/tmp", "/usr", "/var" ] self.filelist = FileList( currDir, showDirectories=True, showFiles=True, showMountpoints=True, isTop=False, matchingPattern="(?i)^.*\.(jpeg|jpg|jpe|png|bmp)", inhibitDirs=inhibitDirs) self["filelist"] = self.filelist self["filelist"].show() self["thumbnail"] = Pixmap() self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.ThumbTimer.start(500, True) self.picload = ePicLoad() #self.picload.PictureData.get().append(self.showPic) def startslideshow(self): self.session.openWithCallback(self.returnVal, MC_PicView, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory(), True) def up(self): self["filelist"].up() self.ThumbTimer.start(500, True) def down(self): self["filelist"].down() self.ThumbTimer.start(500, True) def leftUp(self): self["filelist"].pageUp() self.ThumbTimer.start(500, True) def rightDown(self): self["filelist"].pageDown() self.ThumbTimer.start(500, True) def showPic(self, picInfo=""): ptr = self.picload.getData() if ptr != None: self["thumbnail"].instance.setPixmap(ptr.__deref__()) self["thumbnail"].show() def showThumb(self): return if not self.filelist.canDescent(): if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1: ptr = self.picload.getData() else: ptr = None #ptr = loadPic(self.filelist.getCurrentDirectory() + self.filelist.getFilename(), 180, 160, self.aspect, int(config.plugins.mc_pp.resize.value), 0, 0, cachefile) if ptr != None: self["thumbnail"].instance.setPixmap(ptr.__deref__()) self["thumbnail"].show() else: self["thumbnail"].hide() def KeyOk(self): if self.filelist.canDescent(): self.filelist.descent() else: self.session.openWithCallback(self.returnVal, MC_PicView, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory(), False) def StartThumb(self): self.session.openWithCallback(self.returnVal, MC_PicThumbViewer, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) def JumpToFolder(self, jumpto=None): if jumpto is None: return else: self["filelist"].changeDir(jumpto) self["currentfolder"].setText(("%s") % (jumpto)) def returnVal(self, val=0): if val > 0: for x in self.filelist.getFileList(): if x[0][1] == True: val += 1 self.filelist.moveToIndex(val) def StartExif(self): if not self.filelist.canDescent(): #self.session.open(Pic_Exif, self.filelist.getCurrentDirectory() + self.filelist.getFilename(), self.filelist.getFilename()) #self.session.open(Pic_Exif, self.picload.getInfo(self.filelist.getSelectionIndex())) self.session.open(MessageBox, "Oh no, bugged in this version :(", MessageBox.TYPE_ERROR) def Settings(self): self.session.open(MC_PicSetup) def Exit(self): if self.filelist.getCurrentDirectory() is None: config.plugins.mc_pp.lastDir.value = "/" else: config.plugins.mc_pp.lastDir.value = self.filelist.getCurrentDirectory( ) config.plugins.mc_pp.save() self.close()
class DeviceBrowser(Screen, HelpableScreen): skin = """ <screen name="DeviceBrowser" position="center,center" size="520,430" > <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/pics/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/pics/green.png" position="140,0" size="140,40" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> <widget source="message" render="Label" position="5,50" size="510,150" font="Regular;16" /> <widget name="filelist" position="5,210" size="510,220" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session, startdir, message="", showDirectories=True, showFiles=True, showMountpoints=True, matchingPattern="", useServiceRef=False, inhibitDirs=False, inhibitMounts=False, isTop=False, enableWrapAround=False, additionalExtensions=None): Screen.__init__(self, session) HelpableScreen.__init__(self) Screen.setTitle(self, _("Please select medium")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText() self["message"] = StaticText(message) self.filelist = FileList(startdir, showDirectories=showDirectories, showFiles=showFiles, showMountpoints=showMountpoints, matchingPattern=matchingPattern, useServiceRef=useServiceRef, inhibitDirs=inhibitDirs, inhibitMounts=inhibitMounts, isTop=isTop, enableWrapAround=enableWrapAround, additionalExtensions=additionalExtensions) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "ok": self.ok, "cancel": self.exit }) hotplugNotifier.append(self.hotplugCB) self.onShown.append(self.updateButton) self.onClose.append(self.removeHotplug) def hotplugCB(self, dev, action): print "[hotplugCB]", dev, action self.updateButton() def updateButton(self): if self["filelist"].getFilename( ) or self["filelist"].getCurrentDirectory(): self["key_green"].text = _("Flash") else: self["key_green"].text = "" def removeHotplug(self): print "[removeHotplug]" hotplugNotifier.remove(self.hotplugCB) def ok(self): if self.filelist.canDescent(): if self["filelist"].showMountpoints == True and self[ "filelist"].showDirectories == False: self.use() else: self.filelist.descent() def use(self): print "[use]", self["filelist"].getCurrentDirectory( ), self["filelist"].getFilename() if self["filelist"].getFilename( ) is not None and self["filelist"].getCurrentDirectory() is not None: if self["filelist"].getFilename().endswith(".bin") or self[ "filelist"].getFilename().endswith(".jffs2"): self.close(self["filelist"].getCurrentDirectory(), self["filelist"].getFilename(), 0) elif self["filelist"].getFilename().endswith(".zip"): self.close(self["filelist"].getCurrentDirectory(), self["filelist"].getFilename(), 1) else: return def exit(self): self.close(False, False, -1)
def __init__(self, session, text='', filename='', currDir=None, location=None, userMode=False, windowTitle=_('Choose Download location'), minFree=None, autoAdd=False, editDir=False, inhibitDirs=[], inhibitMounts=[]): Screen.__init__(self, session) HelpableScreen.__init__(self) self['text'] = StaticText(_('Selected memory place:')) self['oktext'] = StaticText(_('for select sublist!')) self.text = text self.filename = filename self.minFree = minFree self.reallocation = location self.location = location and location.value[:] or [] self.userMode = userMode self.autoAdd = autoAdd self.editDir = editDir self.inhibitDirs = inhibitDirs self.inhibitMounts = inhibitMounts inhibitDirs = [ '/bin', '/boot', '/dev', '/lib', '/proc', '/sbin', '/sys', '/mnt', '/var', '/home', '/tmp', '/srv', '/etc', '/share', '/usr', '/ba', '/MB_Images' ] inhibitMounts = ['/mnt', '/ba', '/MB_Images'] self['filelist'] = FileList(currDir, showDirectories=True, showFiles=False, inhibitMounts=inhibitMounts, inhibitDirs=inhibitDirs) self['mountlist'] = MenuList(mountedDevs) self['key_green'] = Button(_('Save')) self['key_red'] = Button(_('Close')) self['green'] = Pixmap() self['red'] = Pixmap() self['target'] = Label() if self.userMode: self.usermodeOn() class DownloadLocationActionMap(HelpableActionMap): def __init__(self, parent, context, actions={}, prio=0): HelpableActionMap.__init__(self, parent, context, actions, prio) self['WizardActions'] = DownloadLocationActionMap( self, 'WizardActions', { 'left': self.left, 'right': self.right, 'up': self.up, 'down': self.down, 'ok': (self.ok, _('Select')), 'back': (self.cancel, _('Cancel')) }, -2) self['ColorActions'] = DownloadLocationActionMap( self, 'ColorActions', { 'red': self.cancel, 'green': self.select }, -2) self.setWindowTitle() self.onLayoutFinish.append(self.switchToFileListOnStart)
class DirectorySelectorWidget(Screen): screenwidth = getDesktop(0).size().width() if screenwidth and screenwidth == 1920: skin = """ <screen name="IPTVDirectorySelectorWidget" position="center,center" size="820,860" title=""> <widget name="key_red" position="10,10" zPosition="2" size="600,35" valign="center" halign="left" font="Regular;28" transparent="1" foregroundColor="red" /> <widget name="key_blue" position="10,10" zPosition="2" size="600,35" valign="center" halign="center" font="Regular;28" transparent="1" foregroundColor="blue" /> <widget name="key_green" position="10,10" zPosition="2" size="600,35" valign="center" halign="right" font="Regular;28" transparent="1" foregroundColor="green" /> <widget name="curr_dir" position="10,50" zPosition="2" size="600,35" valign="center" halign="left" font="Regular;28" transparent="1" foregroundColor="white" /> <widget name="filelist" position="10,95" zPosition="1" size="800,725" transparent="1" scrollbarMode="showOnDemand" /> </screen>""" else: skin = """ <screen name="IPTVDirectorySelectorWidget" position="center,center" size="620,440" title=""> <widget name="key_red" position="10,10" zPosition="2" size="600,35" valign="center" halign="left" font="Regular;22" transparent="1" foregroundColor="red" /> <widget name="key_blue" position="10,10" zPosition="2" size="600,35" valign="center" halign="center" font="Regular;22" transparent="1" foregroundColor="blue" /> <widget name="key_green" position="10,10" zPosition="2" size="600,35" valign="center" halign="right" font="Regular;22" transparent="1" foregroundColor="green" /> <widget name="curr_dir" position="10,50" zPosition="2" size="600,35" valign="center" halign="left" font="Regular;18" transparent="1" foregroundColor="white" /> <widget name="filelist" position="10,85" zPosition="1" size="580,335" transparent="1" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session, currDir, title="Directory browser"): printDBG( "DirectorySelectorWidget.__init__ -------------------------------") Screen.__init__(self, session) # for the skin: first try MediaPlayerDirectoryBrowser, then FileBrowser, this allows individual skinning #self.skinName = ["MediaPlayerDirectoryBrowser", "FileBrowser" ] self["key_red"] = Label(_("Anuluj")) #self["key_yellow"] = Label(_("Odśwież")) self["key_blue"] = Label(_("New folder")) self["key_green"] = Label(_("Apply")) self["curr_dir"] = Label(_(" ")) self.filelist = FileList(directory=currDir, matchingPattern="", showFiles=False) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "yellow": self.refresh, "blue": self.newDir, "ok": self.ok, "cancel": self.exit }) self.title = title self.onLayoutFinish.append(self.layoutFinished) self.onClose.append(self.__onClose) def __del__(self): printDBG( "DirectorySelectorWidget.__del__ -------------------------------") def __onClose(self): printDBG( "DirectorySelectorWidget.__onClose -----------------------------") self.onClose.remove(self.__onClose) self.onLayoutFinish.remove(self.layoutFinished) def layoutFinished(self): printDBG( "DirectorySelectorWidget.layoutFinished -------------------------------" ) self.setTitle(_(self.title)) self.currDirChanged() def currDirChanged(self): self["curr_dir"].setText(_(self.getCurrentDirectory())) def getCurrentDirectory(self): currDir = self["filelist"].getCurrentDirectory() if currDir and os_path.isdir(currDir): return currDir else: return "/" def use(self): self.close(self.getCurrentDirectory()) def exit(self): self.close(None) def ok(self): if self.filelist.canDescent(): self.filelist.descent() self.currDirChanged() def refresh(self): self["filelist"].refresh() def newDir(self): currDir = self["filelist"].getCurrentDirectory() if currDir and os_path.isdir(currDir): self.session.openWithCallback(boundFunction( self.enterPatternCallBack, currDir), VirtualKeyBoard, title=(_("Enter name")), text="") def enterPatternCallBack(self, currDir, newDirName=None): if None != currDir and newDirName != None: sts = False if IsValidFileName(newDirName): sts, msg = mkdir(os_path.join(currDir, newDirName)) else: msg = _("Invalid name.") if sts: self.refresh() else: self.session.open(MessageBox, msg, type=MessageBox.TYPE_INFO, timeout=5)
def __init__(self, session, args=None): Screen.__init__(self, session) InfoBarAudioSelection.__init__(self) InfoBarCueSheetSupport.__init__(self, actionmap="MediaPlayerCueSheetActions") InfoBarNotifications.__init__(self) InfoBarBase.__init__(self) InfoBarScreenSaver.__init__(self) InfoBarSubtitleSupport.__init__(self) HelpableScreen.__init__(self) self.summary = None self.oldService = self.session.nav.getCurrentlyPlayingServiceOrGroup() self.session.nav.stopService() self.setTitle(_("Media player")) self.playlistparsers = {} self.addPlaylistParser(PlaylistIOM3U, "m3u") self.addPlaylistParser(PlaylistIOPLS, "pls") self.addPlaylistParser(PlaylistIOInternal, "e2pls") # 'None' is magic to start at the list of mountpoints defaultDir = config.mediaplayer.defaultDir.getValue() self.filelist = FileList( defaultDir, matchingPattern= "(?i)^.*\.(mp2|mp3|ogg|ts|mts|m2ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|flv|mov|dts|3gp|3g2|asf|wmv|wma)", useServiceRef=True, additionalExtensions="4098:m3u 4098:e2pls 4098:pls") self["filelist"] = self.filelist self.playlist = MyPlayList() self.is_closing = False self.delname = "" self.playlistname = "" self["playlist"] = self.playlist self["PositionGauge"] = ServicePositionGauge(self.session.nav) self["currenttext"] = Label("") self["artisttext"] = Label(_("Artist") + ':') self["artist"] = Label("") self["titletext"] = Label(_("Title") + ':') self["title"] = Label("") self["albumtext"] = Label(_("Album") + ':') self["album"] = Label("") self["yeartext"] = Label(_("Year") + ':') self["year"] = Label("") self["genretext"] = Label(_("Genre") + ':') self["genre"] = Label("") self["coverArt"] = MediaPixmap() self["repeat"] = MultiPixmap() self.seek_target = None try: from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier hotplugNotifier.append(self.hotplugCB) except Exception, ex: print "[MediaPlayer] No hotplug support", ex
def mediaPlayerList(session, path, types): if types == "video": mpattern = "(?i)^.*\.(ts|mts|m2ts|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|dat|flv|mov|dts)" mserviceref = True elif types == "audio": mserviceref = True mpattern = "(?i)^.*\.(mp2|mp3|ogg|wav|wave|m3u|pls|e2pls|m4a|flac)" elif types == "any" or types == "": mserviceref = True # complete pattern from mediaplayer mpattern = "(?i)^.*\.(mp2|mp3|ogg|ts|mts|m2ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|flv|mov|dts)" else: mserviceref = False mpattern = types rpath = path if rpath == "": rpath = None if rpath == "playlist": mp = getOrCreateMpInstance(session) if mp is None: return {"result": False, "files": []} files = [] for service in mp.playlist.getServiceRefList(): files.append({ "servicereference": service.getPath(), "isdirectory": False, "root": "playlist" }) return {"result": True, "files": files} elif rpath == None or os.path.isdir(rpath): files = [] filelist = FileList( rpath, matchingPattern=mpattern, useServiceRef=mserviceref, additionalExtensions="4098:m3u 4098:e2pls 4098:pls") for item in filelist.getFileList(): if item[0][1]: files.append({ "servicereference": item[0][0], "isdirectory": item[0][1], "root": rpath }) elif mserviceref: files.append({ "servicereference": item[0][0].toString(), "isdirectory": item[0][1], "root": rpath }) else: files.append({ "servicereference": path + item[0][0], "isdirectory": item[0][1], "root": rpath }) return {"result": True, "files": files} return {"result": False, "files": []}
class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, InfoBarSubtitleSupport, HelpableScreen): ALLOW_SUSPEND = True ENABLE_RESUME_SUPPORT = True def __init__(self, session, args=None): Screen.__init__(self, session) InfoBarAudioSelection.__init__(self) InfoBarCueSheetSupport.__init__(self, actionmap="MediaPlayerCueSheetActions") InfoBarNotifications.__init__(self) InfoBarBase.__init__(self) InfoBarSubtitleSupport.__init__(self) HelpableScreen.__init__(self) self.summary = None self.playlistparsers = {} self.addPlaylistParser(PlaylistIOM3U, "m3u") self.addPlaylistParser(PlaylistIOPLS, "pls") self.addPlaylistParser(PlaylistIOInternal, "e2pls") # 'None' is magic to start at the list of mountpoints defaultDir = config.mediaplayer.defaultDir.getValue() self.filelist = FileList( defaultDir, matchingPattern= "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|mov|m2ts|flv|wma|wmv)", useServiceRef=True, additionalExtensions="4098:m3u 4098:e2pls 4098:pls") self["filelist"] = self.filelist self.playlist = MyPlayList() self.is_closing = False self.delname = "" self["playlist"] = self.playlist self["PositionGauge"] = ServicePositionGauge(self.session.nav) self["currenttext"] = Label("") self["artisttext"] = Label(_("Artist") + ':') self["artist"] = Label("") self["titletext"] = Label(_("Title") + ':') self["title"] = Label("") self["albumtext"] = Label(_("Album") + ':') self["album"] = Label("") self["yeartext"] = Label(_("Year") + ':') self["year"] = Label("") self["genretext"] = Label(_("Genre") + ':') self["genre"] = Label("") self["coverArt"] = MediaPixmap() self["repeat"] = MultiPixmap() self.seek_target = None from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier hotplugNotifier.append(self.hotplugCB) class MoviePlayerActionMap(NumberActionMap): def __init__(self, player, contexts=[], actions={}, prio=0): NumberActionMap.__init__(self, contexts, actions, prio) self.player = player def action(self, contexts, action): self.player.show() return NumberActionMap.action(self, contexts, action) self["OkCancelActions"] = HelpableActionMap( self, "OkCancelActions", { "ok": (self.ok, _("add file to playlist")), "cancel": (self.exit, _("exit mediaplayer")), }, -2) self["MediaPlayerActions"] = HelpableActionMap( self, "MediaPlayerActions", { "play": (self.xplayEntry, _("play entry")), "pause": (self.pauseEntry, _("pause")), "stop": (self.stopEntry, _("stop entry")), "previous": (self.previousMarkOrEntry, _("play from previous mark or playlist entry")), "next": (self.nextMarkOrEntry, _("play from next mark or playlist entry")), "menu": (self.showMenu, _("menu")), "skipListbegin": (self.skip_listbegin, _("jump to listbegin")), "skipListend": (self.skip_listend, _("jump to listend")), "prevBouquet": (self.switchToPlayList, _("switch to playlist")), "nextBouquet": (self.switchToFileList, _("switch to filelist")), "delete": (self.deletePlaylistEntry, _("delete playlist entry")), "shift_stop": (self.clear_playlist, _("clear playlist")), "shift_record": (self.playlist.PlayListShuffle, _("shuffle playlist")), "subtitles": (self.subtitleSelection, _("Subtitle selection")), }, -2) self["InfobarEPGActions"] = HelpableActionMap( self, "InfobarEPGActions", { "showEventInfo": (self.showEventInformation, _("show event details")), }) self["actions"] = MoviePlayerActionMap( self, ["DirectionActions"], { "right": self.rightDown, "rightRepeated": self.doNothing, "rightUp": self.rightUp, "left": self.leftDown, "leftRepeated": self.doNothing, "leftUp": self.leftUp, "up": self.up, "upRepeated": self.up, "upUp": self.doNothing, "down": self.down, "downRepeated": self.down, "downUp": self.doNothing, }, -2) InfoBarSeek.__init__(self, actionmap="MediaPlayerSeekActions") self.onClose.append(self.delMPTimer) self.righttimer = False self.rightKeyTimer = eTimer() self.rightKeyTimer_conn = self.rightKeyTimer.timeout.connect( self.rightTimerFire) self.lefttimer = False self.leftKeyTimer = eTimer() self.leftKeyTimer_conn = self.leftKeyTimer.timeout.connect( self.leftTimerFire) self.currList = "filelist" self.isAudioCD = False self.AudioCD_albuminfo = {} self.cdAudioTrackFiles = [] self.onShown.append(self.applySettings) self.playlistIOInternal = PlaylistIOInternal() list = self.playlistIOInternal.open( resolveFilename(SCOPE_CONFIG, "playlist.e2pls")) if list: for x in list: self.playlist.addFile(x.ref) self.playlist.updateList() self.__event_tracker = ServiceEventTracker( screen=self, eventmap={ iPlayableService.evUpdatedInfo: self.__evUpdatedInfo, eServiceMP3.evAudioDecodeError: self.__evAudioDecodeError, eServiceMP3.evVideoDecodeError: self.__evVideoDecodeError, eServiceMP3.evPluginError: self.__evPluginError, eServiceMP3.evEmbeddedCoverArt: self["coverArt"].embeddedCoverArt, eServiceMP3.evUpdatedBitrate: self.__evUpdatedBitrate, eServiceMP3.evStreamingSrcError: self.__evStreamingSrcError }) def doNothing(self): pass def createSummary(self): return MediaPlayerLCDScreen def exit(self): self.playlistIOInternal.clear() for x in self.playlist.list: self.playlistIOInternal.addService(ServiceReference(x[0])) if self.savePlaylistOnExit: try: self.playlistIOInternal.save( resolveFilename(SCOPE_CONFIG, "playlist.e2pls")) except IOError: print "couldn't save playlist.e2pls" if config.mediaplayer.saveDirOnExit.getValue(): config.mediaplayer.defaultDir.setValue( self.filelist.getCurrentDirectory()) config.mediaplayer.defaultDir.save() from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier hotplugNotifier.remove(self.hotplugCB) del self["coverArt"].picload self.close() def checkSkipShowHideLock(self): self.updatedSeekState() def doEofInternal(self, playing): if playing: self.nextEntry() else: self.show() def __evUpdatedBitrate(self): currPlay = self.session.nav.getCurrentService() if currPlay is not None: self.bitrate = currPlay.info().getInfo( iServiceInformation.sTagBitrate) def __evUpdatedInfo(self): currPlay = self.session.nav.getCurrentService() sTagTrackNumber = currPlay.info().getInfo( iServiceInformation.sTagTrackNumber) sTagTrackCount = currPlay.info().getInfo( iServiceInformation.sTagTrackCount) sTagTitle = currPlay.info().getInfoString( iServiceInformation.sTagTitle) print "[__evUpdatedInfo] title %d of %d (%s)" % ( sTagTrackNumber, sTagTrackCount, sTagTitle) self.readTitleInformation() def __evAudioDecodeError(self): currPlay = self.session.nav.getCurrentService() sTagAudioCodec = currPlay.info().getInfoString( iServiceInformation.sUser + 12) print "[__evAudioDecodeError] audio-codec %s can't be decoded by hardware" % ( sTagAudioCodec) self.session.open(MessageBox, _("This Dreambox can't decode %s streams!") % sTagAudioCodec, type=MessageBox.TYPE_INFO, timeout=20) def __evVideoDecodeError(self): currPlay = self.session.nav.getCurrentService() sTagVideoCodec = currPlay.info().getInfoString( iServiceInformation.sUser + 12) print "[__evVideoDecodeError] video-codec %s can't be decoded by hardware" % ( sTagVideoCodec) self.session.open(MessageBox, _("This Dreambox can't decode %s streams!") % sTagVideoCodec, type=MessageBox.TYPE_INFO, timeout=20) def __evPluginError(self): currPlay = self.session.nav.getCurrentService() message = currPlay.info().getInfoString(iServiceInformation.sUser + 12) print "[__evPluginError]", message self.session.open(MessageBox, message, type=MessageBox.TYPE_INFO, timeout=20) def __evStreamingSrcError(self): currPlay = self.session.nav.getCurrentService() message = currPlay.info().getInfoString(iServiceInformation.sUser + 12) print "[__evStreamingSrcError]", message self.session.open(MessageBox, _("Streaming error: %s") % message, type=MessageBox.TYPE_INFO, timeout=20) def delMPTimer(self): del self.rightKeyTimer del self.leftKeyTimer def readTitleInformation(self): currPlay = self.session.nav.getCurrentService() if currPlay is not None: sTitle = currPlay.info().getInfoString( iServiceInformation.sTagTitle) sAlbum = currPlay.info().getInfoString( iServiceInformation.sTagAlbum) sGenre = currPlay.info().getInfoString( iServiceInformation.sTagGenre) sArtist = currPlay.info().getInfoString( iServiceInformation.sTagArtist) sYear = currPlay.info().getInfoString(iServiceInformation.sTagDate) if sTitle == "": if not self.isAudioCD: sTitle = currPlay.info().getName().split('/')[-1] else: sTitle = self.playlist.getServiceRefList()[ self.playlist.getCurrentIndex()].getName() if self.AudioCD_albuminfo: if sAlbum == "" and "title" in self.AudioCD_albuminfo: sAlbum = self.AudioCD_albuminfo["title"] if sGenre == "" and "genre" in self.AudioCD_albuminfo: sGenre = self.AudioCD_albuminfo["genre"] if sArtist == "" and "artist" in self.AudioCD_albuminfo: sArtist = self.AudioCD_albuminfo["artist"] if "year" in self.AudioCD_albuminfo: sYear = self.AudioCD_albuminfo["year"] self.updateMusicInformation(sArtist, sTitle, sAlbum, sYear, sGenre, clear=True) else: self.updateMusicInformation() def updateMusicInformation(self, artist="", title="", album="", year="", genre="", clear=False): self.updateSingleMusicInformation("artist", artist, clear) self.updateSingleMusicInformation("title", title, clear) self.updateSingleMusicInformation("album", album, clear) self.updateSingleMusicInformation("year", year, clear) self.updateSingleMusicInformation("genre", genre, clear) def updateSingleMusicInformation(self, name, info, clear): if info != "" or clear: if self[name].getText() != info: self[name].setText(info) def leftDown(self): self.lefttimer = True self.leftKeyTimer.start(1000) def rightDown(self): self.righttimer = True self.rightKeyTimer.start(1000) def leftUp(self): if self.lefttimer: self.leftKeyTimer.stop() self.lefttimer = False self[self.currList].pageUp() self.updateCurrentInfo() def rightUp(self): if self.righttimer: self.rightKeyTimer.stop() self.righttimer = False self[self.currList].pageDown() self.updateCurrentInfo() def leftTimerFire(self): self.leftKeyTimer.stop() self.lefttimer = False self.switchToFileList() def rightTimerFire(self): self.rightKeyTimer.stop() self.righttimer = False self.switchToPlayList() def switchToFileList(self): self.currList = "filelist" self.filelist.selectionEnabled(1) self.playlist.selectionEnabled(0) self.updateCurrentInfo() def switchToPlayList(self): if len(self.playlist) != 0: self.currList = "playlist" self.filelist.selectionEnabled(0) self.playlist.selectionEnabled(1) self.updateCurrentInfo() def up(self): self[self.currList].up() self.updateCurrentInfo() def down(self): self[self.currList].down() self.updateCurrentInfo() def showAfterSeek(self): pass def showAfterCuesheetOperation(self): self.show() def hideAfterResume(self): self.hide() def getIdentifier(self, ref): if self.isAudioCD: return ref.getName() else: text = ref.getPath() return text.split('/')[-1] # FIXME: maybe this code can be optimized def updateCurrentInfo(self): text = "" if self.currList == "filelist": idx = self.filelist.getSelectionIndex() r = self.filelist.list[idx] text = r[1][7] if r[0][1] == True: if len(text) < 2: text += " " if text[:2] != "..": text = "/" + text self.summaries.setText(text, 2) idx += 1 if idx < len(self.filelist.list): r = self.filelist.list[idx] text = r[1][7] if r[0][1] == True: text = "/" + text self.summaries.setText(text, 3) else: self.summaries.setText(" ", 3) idx += 1 if idx < len(self.filelist.list): r = self.filelist.list[idx] text = r[1][7] if r[0][1] == True: text = "/" + text self.summaries.setText(text, 4) else: self.summaries.setText(" ", 4) text = "" if not self.filelist.canDescent(): r = self.filelist.getServiceRef() if r is None: return text = r.getPath() self["currenttext"].setText(os_path.basename(text)) if self.currList == "playlist": t = self.playlist.getSelection() if t is None: return #display current selected entry on LCD text = self.getIdentifier(t) self.summaries.setText(text, 2) self["currenttext"].setText(text) idx = self.playlist.getSelectionIndex() idx += 1 if idx < len(self.playlist): currref = self.playlist.getServiceRefList()[idx] text = self.getIdentifier(currref) self.summaries.setText(text, 3) else: self.summaries.setText(" ", 3) idx += 1 if idx < len(self.playlist): currref = self.playlist.getServiceRefList()[idx] text = self.getIdentifier(currref) self.summaries.setText(text, 4) else: self.summaries.setText(" ", 4) def ok(self): if self.currList == "filelist": if self.filelist.canDescent(): self.filelist.descent() self.updateCurrentInfo() else: self.copyFile() if self.currList == "playlist": selection = self["playlist"].getSelection() self.changeEntry(self.playlist.getSelectionIndex()) def showMenu(self): menu = [] if len(self.cdAudioTrackFiles): menu.insert(0, (_("Play Audio-CD..."), "audiocd")) if self.currList == "filelist": if self.filelist.canDescent(): menu.append((_("add directory to playlist"), "copydir")) else: menu.append((_("add files to playlist"), "copyfiles")) menu.append((_("switch to playlist"), "playlist")) menu.append((_("clear playlist"), "clear")) if config.usage.setup_level.index >= 1: # intermediate+ menu.append((_("delete file"), "deletefile")) else: menu.append((_("switch to filelist"), "filelist")) menu.append((_("clear playlist"), "clear")) menu.append((_("Delete entry"), "deleteentry")) if config.usage.setup_level.index >= 1: # intermediate+ menu.append((_("shuffle playlist"), "shuffle")) menu.append((_("hide player"), "hide")) menu.append((_("load playlist"), "loadplaylist")) if config.usage.setup_level.index >= 1: # intermediate+ menu.append((_("save playlist"), "saveplaylist")) menu.append((_("delete saved playlist"), "deleteplaylist")) menu.append((_("Edit settings"), "settings")) self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu) def menuCallback(self, choice): if choice is None: return if choice[1] == "copydir": self.copyDirectory(self.filelist.getSelection()[0]) elif choice[1] == "copyfiles": self.stopEntry() self.playlist.clear() self.isAudioCD = False self.copyDirectory( os_path.dirname(self.filelist.getSelection()[0].getPath()) + "/", recursive=False) self.playServiceRefEntry(self.filelist.getServiceRef()) elif choice[1] == "playlist": self.switchToPlayList() elif choice[1] == "filelist": self.switchToFileList() elif choice[1] == "deleteentry": if self.playlist.getSelectionIndex( ) == self.playlist.getCurrentIndex(): self.stopEntry() self.deleteEntry() elif choice[1] == "clear": self.clear_playlist() elif choice[1] == "hide": self.hide() elif choice[1] == "saveplaylist": self.save_playlist() elif choice[1] == "loadplaylist": self.load_playlist() elif choice[1] == "deleteplaylist": self.delete_saved_playlist() elif choice[1] == "shuffle": self.playlist.PlayListShuffle() elif choice[1] == "deletefile": self.deleteFile() elif choice[1] == "settings": self.session.openWithCallback(self.applySettings, MediaPlayerSettings, self) elif choice[1] == "audiocd": self.playAudioCD() def playAudioCD(self): from enigma import eServiceReference from Plugins.Extensions.CDInfo.plugin import Query if len(self.cdAudioTrackFiles): self.playlist.clear() self.savePlaylistOnExit = False self.isAudioCD = True for file in self.cdAudioTrackFiles: ref = eServiceReference(eServiceReference.idGST, 0, file) self.playlist.addFile(ref) cdinfo = Query(self) cdinfo.scan() self.changeEntry(0) self.switchToPlayList() def applySettings(self): self.savePlaylistOnExit = config.mediaplayer.savePlaylistOnExit.getValue( ) if config.mediaplayer.repeat.getValue() == True: self["repeat"].setPixmapNum(1) else: self["repeat"].setPixmapNum(0) def showEventInformation(self): from Screens.EventView import EventViewSimple from ServiceReference import ServiceReference evt = self[self.currList].getCurrentEvent() if evt: self.session.open(EventViewSimple, evt, ServiceReference(self.getCurrent())) # also works on filelist (?) def getCurrent(self): return self["playlist"].getCurrent() def deletePlaylistEntry(self): if self.currList == "playlist": if self.playlist.getSelectionIndex( ) == self.playlist.getCurrentIndex(): self.stopEntry() self.deleteEntry() def skip_listbegin(self): if self.currList == "filelist": self.filelist.moveToIndex(0) else: self.playlist.moveToIndex(0) self.updateCurrentInfo() def skip_listend(self): if self.currList == "filelist": idx = len(self.filelist.list) self.filelist.moveToIndex(idx - 1) else: self.playlist.moveToIndex(len(self.playlist) - 1) self.updateCurrentInfo() def save_playlist(self): self.session.openWithCallback( self.save_playlist2, InputBox, title=_("Please enter filename (empty = use current date)"), windowTitle=_("Save Playlist")) def save_playlist2(self, name): if name is not None: name = name.strip() if name == "": name = strftime("%y%m%d_%H%M%S") name += ".e2pls" self.playlistIOInternal.clear() for x in self.playlist.list: self.playlistIOInternal.addService(ServiceReference(x[0])) self.playlistIOInternal.save( resolveFilename(SCOPE_PLAYLIST) + name) def load_playlist(self): listpath = [] playlistdir = resolveFilename(SCOPE_PLAYLIST) try: for i in os_listdir(playlistdir): listpath.append((i, playlistdir + i)) except IOError, e: print "Error while scanning subdirs ", e self.session.openWithCallback(self.PlaylistSelected, ChoiceBox, title=_("Please select a playlist..."), list=listpath)
def __init__(self): self.ftpclient = None self.select = None self.isValid = False FileList.__init__(self, "/")
class DirectorySelectorWidget(Screen): skin = """ <screen name="DirectorySelectorWidget" position="center,center" size="620,440" title=""> <widget name="key_red" position="10,10" zPosition="2" size="600,35" valign="center" halign="left" font="Regular;22" transparent="1" foregroundColor="red" /> <widget name="key_blue" position="10,10" zPosition="2" size="600,35" valign="center" halign="center" font="Regular;22" transparent="1" foregroundColor="blue" /> <widget name="key_green" position="10,10" zPosition="2" size="600,35" valign="center" halign="right" font="Regular;22" transparent="1" foregroundColor="green" /> <widget name="key_yellow" position="10,10" zPosition="2" size="600,35" valign="center" halign="right" font="Regular;22" transparent="1" foregroundColor="green" /> <widget name="curr_dir" position="10,50" zPosition="2" size="600,35" valign="center" halign="left" font="Regular;18" transparent="1" foregroundColor="white" /> <widget name="filelist" position="10,85" zPosition="1" size="580,335" transparent="1" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session, currDir, title="Select directory"): printDBG( "DirectorySelectorWidget.__init__ -------------------------------") Screen.__init__(self, session) # for the skin: first try MediaPlayerDirectoryBrowser, then FileBrowser, this allows individual skinning #self.skinName = ["MediaPlayerDirectoryBrowser", "FileBrowser" ] self["key_red"] = Label(_("Cancel")) #self["key_yellow"] = Label(_("Refresh")) self["key_blue"] = Label(_("New directory")) self["key_green"] = Label(_("Select")) self["curr_dir"] = Label(_(" ")) self.filelist = FileList(directory=currDir, matchingPattern="", showFiles=False) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "yellow": self.refresh, "blue": self.newDir, "ok": self.ok, "cancel": self.exit }) self.title = title self.onLayoutFinish.append(self.layoutFinished) self.onClose.append(self.__onClose) def mkdir(newdir): """ Wrapper for the os.mkdir function returns status instead of raising exception """ try: os.mkdir(newdir) sts = True msg = _('Directory "%s" has been created.') % newdir except: sts = False msg = _('Error creating directory "%s".') % newdir printExc() return sts, msg def __del__(self): printDBG( "DirectorySelectorWidget.__del__ -------------------------------") def __onClose(self): printDBG( "DirectorySelectorWidget.__onClose -----------------------------") self.onClose.remove(self.__onClose) self.onLayoutFinish.remove(self.layoutFinished) def layoutFinished(self): printDBG( "DirectorySelectorWidget.layoutFinished -------------------------------" ) self.setTitle(_(self.title)) self.currDirChanged() def currDirChanged(self): self["curr_dir"].setText(_(self.getCurrentDirectory())) def getCurrentDirectory(self): currDir = self["filelist"].getCurrentDirectory() if currDir and os.path.isdir(currDir): return currDir else: return "/" def use(self): self.close(self.getCurrentDirectory()) def exit(self): self.close(None) def ok(self): if self.filelist.canDescent(): self.filelist.descent() self.currDirChanged() def refresh(self): self["filelist"].refresh() def newDir(self): currDir = self["filelist"].getCurrentDirectory() if currDir and os.path.isdir(currDir): self.session.openWithCallback(boundFunction( self.enterPatternCallBack, currDir), VirtualKeyBoard, title=(_("Enter name")), text="") def IsValidFileName(name, NAME_MAX=255): prohibited_characters = [ '/', "\000", '\\', ':', '*', '<', '>', '|', '"' ] if isinstance(name, basestring) and (1 <= len(name) <= NAME_MAX): for it in name: if it in prohibited_characters: return False return True return False def enterPatternCallBack(self, currDir, newDirName=None): if None != currDir and newDirName != None: sts = False if self.IsValidFileName(newDirName): sts, msg = self.mkdir(os.path.join(currDir, newDirName)) else: msg = _("Incorrect directory name.") if sts: self.refresh() else: self.session.open(MessageBox, msg, type=MessageBox.TYPE_INFO, timeout=5)
class Selectmusic(Screen): def __init__(self, session): Screen.__init__(self, session) self["actions"] = HelpableActionMap( self, "MC_AudioPlayerActions", { "ok": (self.KeyOk, "Play selected file"), "left": (self.leftUp, "List Top"), "right": (self.rightDown, "List Bottom"), "up": (self.up, "List up"), "down": (self.down, "List down"), }, -2) self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", {"cancel": self.close}, -2) currDir = config.plugins.mc_ap.lastDir.value if not pathExists(currDir): currDir = "/" inhibitDirs = [ "/bin", "/boot", "/dev", "/dev.static", "/etc", "/lib", "/proc", "/ram", "/root", "/sbin", "/sys", "/tmp", "/usr", "/var" ] self.filelist = FileList( currDir, useServiceRef=True, showDirectories=True, showFiles=True, matchingPattern= "(?i)^.*\.(m3u|mp2|mp3|wav|wave|pls|wma|m4a|ogg|ra|flac)", inhibitDirs=inhibitDirs) self["filelist"] = self.filelist self["currentfolder"] = Label() self["currentfolder"].setText(str(currDir)) def up(self): self["filelist"].up() def down(self): self["filelist"].down() def leftUp(self): self["filelist"].pageUp() def rightDown(self): self["filelist"].pageDown() def KeyOk(self): self.filename = self.filelist.getFilename() self["currentfolder"].setText(str(self.filelist.getCurrentDirectory())) if self.filelist.getFilename() is not None: if self.filelist.canDescent(): self.filelist.descent() else: config.plugins.mc_pp.music.value = self.filename config.plugins.mc_pp.save() self.close() else: if self.filelist.canDescent(): self.filelist.descent() else: config.plugins.mc_pp.music.value = self.filename config.plugins.mc_pp.save() self.close()
class picshow(Screen): skin = """ <screen name="picshow" position="center,center" size="560,440" title="Picture player" > <ePixmap pixmap="buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="buttons/green.png" position="140,0" size="140,40" alphatest="on" /> <ePixmap pixmap="buttons/yellow.png" position="280,0" size="140,40" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" /> <widget source="label" render="Label" position="5,55" size="350,140" font="Regular;19" backgroundColor="#25062748" transparent="1" /> <widget name="thn" position="360,40" size="180,160" alphatest="on" /> <widget name="filelist" position="5,205" zPosition="2" size="550,230" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session): Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MenuActions"], { "cancel": self.KeyExit, "red": self.KeyExit, "green": self.KeyGreen, "yellow": self.KeyYellow, "menu": self.KeyMenu, "ok": self.KeyOk }, -1) self["key_red"] = StaticText(_("Close")) self["key_green"] = StaticText(_("Thumbnails")) self["key_yellow"] = StaticText("") self["label"] = StaticText("") self["thn"] = Pixmap() currDir = config.pic.lastDir.value if not pathExists(currDir): currDir = "/" self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)") self["filelist"] = self.filelist self["filelist"].onSelectionChanged.append(self.selectionChanged) self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.picload = ePicLoad() self.picload.PictureData.get().append(self.showPic) self.onLayoutFinish.append(self.setConf) def showPic(self, picInfo=""): ptr = self.picload.getData() if ptr is not None: self["thn"].instance.setPixmap(ptr.__deref__()) self["thn"].show() text = picInfo.split('\n',1) self["label"].setText(text[1]) self["key_yellow"].setText(_("Exif")) def showThumb(self): if not self.filelist.canDescent(): if self.filelist.getCurrentDirectory() and self.filelist.getFilename(): if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1: self.ThumbTimer.start(500, True) def selectionChanged(self): if not self.filelist.canDescent(): self.ThumbTimer.start(500, True) else: self["label"].setText("") self["thn"].hide() self["key_yellow"].setText("") def KeyGreen(self): #if not self.filelist.canDescent(): self.session.openWithCallback(self.callbackView, Pic_Thumb, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) def KeyYellow(self): if not self.filelist.canDescent(): self.session.open(Pic_Exif, self.picload.getInfo(self.filelist.getCurrentDirectory() + self.filelist.getFilename())) def KeyMenu(self): self.session.openWithCallback(self.setConf ,Pic_Setup) def KeyOk(self): if self.filelist.canDescent(): self.filelist.descent() else: self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) def setConf(self, retval=None): self.setTitle(_("Picture player")) sc = getScale() #0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB) self.picload.setPara((self["thn"].instance.size().width(), self["thn"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), "#00000000")) def callbackView(self, val=0): if val > 0: self.filelist.moveToIndex(val) def KeyExit(self): del self.picload if self.filelist.getCurrentDirectory() is None: config.pic.lastDir.setValue("/") else: config.pic.lastDir.setValue(self.filelist.getCurrentDirectory()) config.pic.save() self.close()
def __init__(self, session, text='', filename='', currDir=None, bookmarks=None, userMode=False, windowTitle='Select location', minFree=None, autoAdd=False, editDir=False, inhibitDirs=[], inhibitMounts=[]): if not inhibitDirs: inhibitDirs = [] if not inhibitMounts: inhibitMounts = [] Screen.__init__(self, session) NumericalTextInput.__init__(self, handleTimeout=False) HelpableScreen.__init__(self) self.setUseableChars(u'1234567890abcdefghijklmnopqrstuvwxyz') self.qs_timer = eTimer() self.qs_timer.callback.append(self.timeout) self.qs_timer_type = 0 self.curr_pos = -1 self.quickselect = '' self['text'] = Label(text) self['textbook'] = Label(_('Bookmarks')) self.text = text self.filename = filename self.minFree = minFree self.realBookmarks = bookmarks self.bookmarks = bookmarks and bookmarks.value[:] or [] self.userMode = userMode self.autoAdd = autoAdd self.editDir = editDir self.inhibitDirs = inhibitDirs self['filelist'] = FileList(currDir, showDirectories=True, showFiles=False, inhibitMounts=inhibitMounts, inhibitDirs=inhibitDirs) self['booklist'] = MenuList(self.bookmarks) self['key_green'] = Button(_('OK')) self['key_yellow'] = Button(_('Rename')) self['key_blue'] = Button(_('Remove bookmark')) self['key_red'] = Button(_('Cancel')) self['green'] = Pixmap() self['yellow'] = Pixmap() self['blue'] = Pixmap() self['red'] = Pixmap() self['target'] = Label() self['targetfreespace'] = Label() if self.userMode: self.usermodeOn() class LocationBoxActionMap(HelpableActionMap): def __init__(self, parent, context, actions=None, prio=0): if not actions: actions = {} HelpableActionMap.__init__(self, parent, context, actions, prio) self.box = parent def action(self, contexts, action): self.box.timeout(force=True) return HelpableActionMap.action(self, contexts, action) self['WizardActions'] = LocationBoxActionMap(self, 'WizardActions', { 'ok': (self.ok, _('select')), 'back': (self.cancel, _('Cancel')) }, -2) self['DirectionActions'] = LocationBoxActionMap( self, 'DirectionActions', { 'left': self.left, 'right': self.right, 'up': self.up, 'down': self.down }, -2) self['ColorActions'] = LocationBoxActionMap( self, 'ColorActions', { 'red': self.cancel, 'green': self.select, 'yellow': self.changeName, 'blue': self.addRemoveBookmark }, -2) self['EPGSelectActions'] = LocationBoxActionMap( self, 'EPGSelectActions', { 'prevService': (self.switchToBookList, _('switch to bookmarks')), 'nextService': (self.switchToFileList, _('switch to filelist')) }, -2) self['MenuActions'] = LocationBoxActionMap( self, 'MenuActions', {'menu': (self.showMenu, _('menu'))}, -2) self['NumberActions'] = NumberActionMap( ['NumberActions'], { '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 }) self.onShown.extend((boundFunction(self.setTitle, _('Select Location')), self.updateTarget, self.showHideRename)) self.onLayoutFinish.append(self.switchToFileListOnStart) self.onClose.append(self.disableTimer)
def __init__(self, session, text="", filename="", currDir=None, bookmarks=None, userMode=False, windowTitle=_("Select location"), minFree=None, autoAdd=False, editDir=False, inhibitDirs=None, inhibitMounts=None): # Init parents if not inhibitDirs: inhibitDirs = [] if not inhibitMounts: inhibitMounts = [] Screen.__init__(self, session) NumericalTextInput.__init__(self, handleTimeout=False) HelpableScreen.__init__(self) # Set useable chars self.setUseableChars(u'1234567890abcdefghijklmnopqrstuvwxyz') # Quickselect Timer self.qs_timer = eTimer() self.qs_timer.callback.append(self.timeout) self.qs_timer_type = 0 # Initialize Quickselect self.curr_pos = -1 self.quickselect = "" # Set Text self["text"] = Label(text) self["textbook"] = Label(_("Bookmarks")) # Save parameters locally self.text = text self.filename = filename self.minFree = minFree self.realBookmarks = bookmarks self.bookmarks = bookmarks and bookmarks.getValue()[:] or [] self.userMode = userMode self.autoAdd = autoAdd self.editDir = editDir self.inhibitDirs = inhibitDirs # Initialize FileList self["filelist"] = FileList(currDir, showDirectories=True, showFiles=False, inhibitMounts=inhibitMounts, inhibitDirs=inhibitDirs) # Initialize BookList self["booklist"] = MenuList(self.bookmarks) # Buttons self["key_green"] = Button(_("OK")) self["key_yellow"] = Button(_("Rename")) self["key_blue"] = Button() self.onExecBegin.append(self._initialButtonTexts) self["key_red"] = Button(_("Cancel")) # Background for Buttons self["green"] = Pixmap() self["yellow"] = Pixmap() self["blue"] = Pixmap() self["red"] = Pixmap() # Initialize Target self["target"] = Label() if self.userMode: self.usermodeOn() # Custom Action Handler class LocationBoxActionMap(HelpableActionMap): def __init__(self, parent, context, actions=None, prio=0): if not actions: actions = {} HelpableActionMap.__init__(self, parent, context, actions, prio) self.box = parent def action(self, contexts, action): # Reset Quickselect self.box.timeout(force=True) return HelpableActionMap.action(self, contexts, action) # Actions that will reset quickselect self["WizardActions"] = LocationBoxActionMap( self, "WizardActions", { "ok": (self.ok, _("Select")), "back": (self.cancel, _("Cancel")), }, prio=-2) self["DirectionActions"] = LocationBoxActionMap( self, "DirectionActions", { "left": self.left, "right": self.right, "up": self.up, "down": self.down, }, prio=-2) self["ColorActions"] = LocationBoxActionMap( self, "ColorActions", { "red": self.cancel, "green": self.select, "yellow": self.changeName, "blue": self.addRemoveBookmark, }, prio=-2) self["EPGSelectActions"] = LocationBoxActionMap( self, "EPGSelectActions", { "prevService": (self.switchToBookList, _("Switch to bookmarks")), "nextService": (self.switchToFileList, _("Switch to filelist")), }, prio=-2) self["MenuActions"] = LocationBoxActionMap( self, "MenuActions", { "menu": (self.showMenu, _("Menu")), }, prio=-2) # Actions used by quickselect self["NumberActions"] = NumberActionMap( ["NumberActions"], { "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 }) # Run some functions when shown self.onShown.extend(( boundFunction(self.setTitle, _("Select Location")), self.updateTarget, self.showHideRename, )) self.onLayoutFinish.append(self.switchToFileListOnStart) # Make sure we remove our callback self.onClose.append(self.disableTimer)
def __init__(self, session): Screen.__init__(self, session) HelpableScreen.__init__(self) InfoBarNotifications.__init__(self) self.ftpclient = None self.queueManagerInstance = None self.file = None self.queue = None self.currlist = "local" # # NOTE: having self.checkNotifications in onExecBegin might make our gui # disappear, so let's move it to onShow self.onExecBegin.remove(self.checkNotifications) self.onShow.append(self.checkNotifications) # Init what we need for dl progress self.currentLength = 0 self.lastLength = 0 self.lastTime = 0 self.lastApprox = 0 self.fileSize = 0 self["localText"] = StaticText(_("Local")) self["local"] = FileList("/media/hdd/", showMountpoints=False) self["remoteText"] = StaticText(_("Remote (not connected)")) self["remote"] = FTPFileList() self["eta"] = StaticText("") self["speed"] = StaticText("") self["progress"] = VariableProgressSource() self["key_red"] = StaticText(_("Exit")) self["key_green"] = StaticText(_("Rename")) self["key_yellow"] = StaticText(_("Delete")) self["key_blue"] = StaticText(_("Upload")) self.server = None self["ftpbrowserBaseActions"] = HelpableActionMap( self, "ftpbrowserBaseActions", { "ok": (self.ok, _("enter directory/get file/put file")), "cancel": (self.cancel, _("close")), "menu": (self.menu, _("open menu")), }, -2) self["ftpbrowserListActions"] = HelpableActionMap( self, "ftpbrowserListActions", { "channelUp": (self.setLocal, _("Select local file list")), "channelDown": (self.setRemote, _("Select remote file list")), }) self["actions"] = ActionMap( ["ftpbrowserDirectionActions", "ColorActions"], { "up": self.up, "down": self.down, "left": self.left, "right": self.right, "green": self.rename, "yellow": self.delete, "blue": self.transfer, }, -2) self.onExecBegin.append(self.reinitialize)
class DirectorySelectorWidget(Screen): skin = """ <screen name="DirectorySelectorWidget" position="center,center" size="620,440" title=""> <widget name="key_red" position="10,10" zPosition="2" size="600,35" valign="center" halign="left" font="Regular;22" transparent="1" foregroundColor="red" /> <widget name="key_blue" position="10,10" zPosition="2" size="600,35" valign="center" halign="center" font="Regular;22" transparent="1" foregroundColor="blue" /> <widget name="key_green" position="10,10" zPosition="2" size="600,35" valign="center" halign="right" font="Regular;22" transparent="1" foregroundColor="green" /> <widget name="key_yellow" position="10,10" zPosition="2" size="600,35" valign="center" halign="center" font="Regular;22" transparent="1" foregroundColor="yellow" /> <widget name="curr_dir" position="10,50" zPosition="2" size="600,35" valign="center" halign="left" font="Regular;18" transparent="1" foregroundColor="white" /> <widget name="filelist" position="10,85" zPosition="1" size="580,335" transparent="1" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session, currDir, title="Select directory", FileMode=False, searchpattern=""): print( "DirectorySelectorWidget.__init__ -------------------------------") Screen.__init__(self, session) # for the skin: first try MediaPlayerDirectoryBrowser, then FileBrowser, this allows individual skinning #self.skinName = ["MediaPlayerDirectoryBrowser", "FileBrowser" ] self["key_red"] = Label(_("Cancel")) self["key_yellow"] = Label(_("Refresh")) #self["key_blue"] = Label(_("New directory")) self["key_green"] = Label(_("Select")) self["curr_dir"] = Label(_(" ")) self.filelist = FileList(directory=currDir, matchingPattern=searchpattern, showFiles=FileMode) self.FileMode = FileMode self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], { "green": self.use, "red": self.exit, "yellow": self.refresh, "ok": self.ok, "cancel": self.exit }) self.title = title self.onLayoutFinish.append(self.layoutFinished) self.onClose.append(self.__onClose) def __del__(self): print( "DirectorySelectorWidget.__del__ -------------------------------") def __onClose(self): print( "DirectorySelectorWidget.__onClose -----------------------------") self.onClose.remove(self.__onClose) self.onLayoutFinish.remove(self.layoutFinished) def layoutFinished(self): print( "DirectorySelectorWidget.layoutFinished -------------------------------" ) self.setTitle(_(self.title)) self.currDirChanged() def currDirChanged(self): self["curr_dir"].setText(self.getCurrentDirectory()) def getCurrentDirectory(self): currDir = self["filelist"].getCurrentDirectory() if currDir and os_path.isdir(currDir): return currDir else: return "/" def use(self): if self.FileMode: selection = self["filelist"].getSelection() self.close("%s/%s" % (self.filelist.getCurrentDirectory(), selection[0])) else: self.close(self.getCurrentDirectory()) def exit(self): self.close(None) def ok(self): if self.filelist.canDescent(): self.filelist.descent() self.currDirChanged() def refresh(self): self["filelist"].refresh()
class DirectoryBrowser(Screen): skin = """<screen name="DirectoryBrowser" position="center,center" size="520,440" title=" " > <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> <widget source="curdir" render="Label" position="5,50" size="510,20" font="Regular;20" halign="left" valign="center" backgroundColor="background" transparent="1" noWrap="1" /> <widget name="filelist" position="5,80" size="510,345" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session, curdir, matchingPattern=None): Screen.__init__(self, session) self["Title"].setText(_("Directory browser")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Save")) self["curdir"] = StaticText(_("current: %s") % (curdir or '')) self.filelist = FileList(curdir, matchingPattern=matchingPattern, enableWrapAround=True) self.filelist.onSelectionChanged.append(self.__selChanged) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap( ["SetupActions", "ColorActions"], { "green": self.keyGreen, "red": self.keyRed, "ok": self.keyOk, "cancel": self.keyRed }) self.onLayoutFinish.append(self.__layoutFinished) def __layoutFinished(self): pass def getCurrentSelected(self): dirname = self.filelist.getCurrentDirectory() filename = self.filelist.getFilename() if not filename and not dirname: cur = '' elif not filename: cur = dirname elif not dirname: cur = filename else: if not self.filelist.canDescent() or len(filename) <= len(dirname): cur = dirname else: cur = filename return cur or '' def __selChanged(self): self["curdir"].setText(_("current: %s") % (self.getCurrentSelected())) def keyOk(self): if self.filelist.canDescent(): self.filelist.descent() def keyGreen(self): if self.filelist.canDescent() and self.getCurrentSelected(): self.close(self.getCurrentSelected()) def keyRed(self): self.close(False)
class MC_PictureViewer(Screen, HelpableScreen): def __init__(self, session): Screen.__init__(self, session) HelpableScreen.__init__(self) self['key_green'] = Button('Slide Show') self['key_yellow'] = Button('Thumb View') self['currentfolder'] = Label('') self['currentfavname'] = Label('') self['actions'] = HelpableActionMap(self, 'MC_PictureViewerActions', {'ok': (self.KeyOk, 'Show Picture'), 'cancel': (self.Exit, 'Exit Picture Viewer'), 'left': (self.leftUp, 'List Top'), 'right': (self.rightDown, 'List Bottom'), 'up': (self.up, 'List up'), 'down': (self.down, 'List down'), 'info': (self.StartExif, 'Show File Info'), 'green': (self.startslideshow, 'Start Slideshow'), 'yellow': (self.StartThumb, 'Thumb View'), 'blue': (self.Settings, 'Settings')}, -2) self.aspect = getAspect() currDir = config.plugins.mc_pp.lastDir.value if not pathExists(currDir): currDir = '/' self['currentfolder'].setText(str(currDir)) self.filelist = [] self['filelist'] = [] inhibitDirs = ['/bin', '/boot', '/dev', '/dev.static', '/etc', '/lib', '/proc', '/ram', '/root', '/sbin', '/sys', '/tmp', '/usr', '/var'] self.filelist = FileList(currDir, showDirectories=True, showFiles=True, showMountpoints=True, isTop=False, matchingPattern='(?i)^.*\\.(jpeg|jpg|jpe|png|bmp)', inhibitDirs=inhibitDirs) self['filelist'] = self.filelist self['filelist'].show() self['thumbnail'] = Pixmap() self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.ThumbTimer.start(500, True) self.picload = ePicLoad() def startslideshow(self): self.session.openWithCallback(self.returnVal, MC_PicView, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory(), True) def up(self): self['filelist'].up() self.ThumbTimer.start(500, True) def down(self): self['filelist'].down() self.ThumbTimer.start(500, True) def leftUp(self): self['filelist'].pageUp() self.ThumbTimer.start(500, True) def rightDown(self): self['filelist'].pageDown() self.ThumbTimer.start(500, True) def showPic(self, picInfo = ''): ptr = self.picload.getData() if ptr != None: self['thumbnail'].instance.setPixmap(ptr.__deref__()) self['thumbnail'].show() return def showThumb(self): return if not self.filelist.canDescent(): if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1: ptr = self.picload.getData() else: ptr = None if ptr != None: self['thumbnail'].instance.setPixmap(ptr.__deref__()) self['thumbnail'].show() else: self['thumbnail'].hide() return def KeyOk(self): if self.filelist.canDescent(): self.filelist.descent() else: self.session.openWithCallback(self.returnVal, MC_PicView, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory(), False) def StartThumb(self): self.session.openWithCallback(self.returnVal, MC_PicThumbViewer, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) def JumpToFolder(self, jumpto = None): if jumpto is None: return else: self['filelist'].changeDir(jumpto) self['currentfolder'].setText('%s' % jumpto) return return def returnVal(self, val = 0): if val > 0: for x in self.filelist.getFileList(): if x[0][1] == True: val += 1 self.filelist.moveToIndex(val) def StartExif(self): if not self.filelist.canDescent(): self.session.open(MessageBox, 'Oh no, bugged in this version :(', MessageBox.TYPE_ERROR) def Settings(self): self.session.open(MC_PicSetup) def Exit(self): if self.filelist.getCurrentDirectory() is None: config.plugins.mc_pp.lastDir.value = '/' else: config.plugins.mc_pp.lastDir.value = self.filelist.getCurrentDirectory() config.plugins.mc_pp.save() self.close() return
def __init__(self, session, startDir = None, showDirectories = True, showFiles = False, \ showMountpoints = True, matchingPattern = None, useServiceRef = False, \ inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = False, \ additionalExtensions = None, selOnlyFiles = False, permanentBookmark = None, \ loggerInstance = None): try: Screen.__init__(self, session) self.session = session self.selOnlyFiles = selOnlyFiles self.showFiles = showFiles if self.selOnlyFiles: self.showFiles = True self.epath = "" self.log = loggerInstance if self.log == None: self.log = getGeneralLogger() self["button_green"] = Pixmap() self["key_green_text"] = Button() self["button_red"] = Pixmap() self["key_red_text"] = Label(_("Close")) self["button_blue"] = Pixmap() self["key_blue_text"] = Button() if startDir == None or startDir == "": startDir = "/media/hdd" self["filelist"] = FileList(directory = startDir, showDirectories = showDirectories, \ showFiles = self.showFiles, showMountpoints = showMountpoints, \ matchingPattern = matchingPattern, useServiceRef = useServiceRef, \ inhibitDirs = inhibitDirs, inhibitMounts = inhibitMounts, isTop = isTop, \ enableWrapAround = enableWrapAround, additionalExtensions = additionalExtensions) self["actions"] = ActionMap( ["WizardActions", "DirectionActions", "ColorActions"], { "ok": self.ok, "back": self.cancel, "left": self.left, "right": self.right, "up": self.up, "down": self.down, "green": self.green, "red": self.red, "blue": self.goToPermanentBookmark, }, -1) if permanentBookmark != None and not isinstance( permanentBookmark, dict): permanentBookmark = None self.permanentBookmark = permanentBookmark self.configureBlueButton() self.onLayoutFinish.append(self.setStartDir) except: if self.log == None: self.log.printOut("selectFileDlg-Init-Error:\n%s" % (str(format_exc())), level=ERROR_LEVEL) else: getGeneralLogger().printOut("selectFileDlg-Init-Error:\n%s" % (str(format_exc())), level=ERROR_LEVEL) self.close(None)
class FileBrowser(Screen, HelpableScreen): def __init__(self, session, scope, configRef): Screen.__init__(self, session) # for the skin: first try FileBrowser_DVDBurn, then FileBrowser, this allows individual skinning self.skinName = ["FileBrowser_DVDBurn", "FileBrowser" ] HelpableScreen.__init__(self) self.scope = scope pattern = "" self.configRef = configRef currDir = "/" if self.scope == "project": currDir = self.getDir() pattern = "(?i)^.*\.(ddvdp\.xml)" elif self.scope == "menutemplate": currDir = self.getDir() pattern = "(?i)^.*\.(ddvdm\.xml)" if self.scope == "menubg": currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)" elif self.scope == "menuaudio": currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(mp2|m2a|ac3)" elif self.scope == "vmgm": currDir = self.getDir(configRef.getValue()) pattern = "(?i)^.*\.(mpg|mpeg)" elif self.scope == "font_face": currDir = self.getDir(configRef.getValue(), resolveFilename(SCOPE_FONTS)) pattern = "(?i)^.*\.(ttf)" elif self.scope == "isopath": currDir = configRef.getValue() elif self.scope == "image": currDir = resolveFilename(SCOPE_HDD) pattern = "(?i)^.*\.(iso)" self.filelist = FileList(currDir, matchingPattern=pattern) self["filelist"] = self.filelist self["FilelistActions"] = ActionMap(["SetupActions"], { "save": self.ok, "ok": self.ok, "cancel": self.exit }) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(_("DVD file browser")) def getDir(self, currentVal=None, defaultDir=None): if currentVal: return (currentVal.rstrip("/").rsplit("/",1))[0] return defaultDir or (resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/") def ok(self): if self.filelist.canDescent(): self.filelist.descent() if self.scope == "image": path = self["filelist"].getCurrentDirectory() or "" if fileExists(path+"VIDEO_TS"): self.close(path,self.scope,self.configRef) else: ret = self["filelist"].getCurrentDirectory() + '/' + self["filelist"].getFilename() self.close(ret,self.scope,self.configRef) def exit(self): if self.scope == "isopath": self.close(self["filelist"].getCurrentDirectory(),self.scope,self.configRef) self.close(None,False,None)
class EL_Screen_PathSelector(Screen): #=========================================================================== # #=========================================================================== def __init__(self, session, initDir, myType, title): Screen.__init__(self, session) self.guiElements = getGuiElements() self.myType = myType self.title = title if not os.path.exists(initDir): initDir = "/etc/" self.filelist = FileList("/dev/", showDirectories=True, showFiles=True, showMountpoints=True, isTop=False, matchingPattern="") self["filelist"] = self.filelist #self["filelist"] = FileList(initDir, showDirectories = True, showFiles = True, showMountpoints = False, isTop = True, matchingPattern = "^.*\.(conf|config)") self["filelist"].changeDir(initDir.rsplit('/', 1)[0] + "/", select=initDir.rsplit('/', 1)[1]) self["help"] = Label() self["help"].setText(initDir) self["actions"] = ActionMap( [ "WizardActions", "DirectionActions", "ColorActions", "EPGSelectActions" ], { "back": self.cancel, "left": self.left, "right": self.right, "up": self.up, "down": self.down, "ok": self.ok, "green": self.green, "red": self.cancel }, -1) self["btn_red"] = Pixmap() self["btn_redText"] = Label() self["btn_green"] = Pixmap() self["btn_greenText"] = Label() self.onLayoutFinish.append(self.finishLayout) #=========================================================================== # #=========================================================================== def finishLayout(self): self["btn_red"].instance.setPixmapFromFile(self.guiElements["key_red"]) self["btn_redText"].setText(_("Cancel")) self["btn_green"].instance.setPixmapFromFile( self.guiElements["key_green"]) self["btn_greenText"].setText(_("Ok")) self.setTitle(_(self.title)) #=========================================================================== # #=========================================================================== def cancel(self): self.close(None, self.myType) #=========================================================================== # #=========================================================================== def green(self): self.close( str(self["filelist"].getCurrentDirectory()) + str(self["filelist"].getSelection()[0]), self.myType) #=========================================================================== # #=========================================================================== def up(self): self["filelist"].up() self.updateTarget() #=========================================================================== # #=========================================================================== def down(self): self["filelist"].down() self.updateTarget() #=========================================================================== # #=========================================================================== def left(self): self["filelist"].pageUp() self.updateTarget() #=========================================================================== # #=========================================================================== def right(self): self["filelist"].pageDown() self.updateTarget() #=========================================================================== # #=========================================================================== def ok(self): if self["filelist"].canDescent(): self["filelist"].descent() self.updateTarget() #=========================================================================== # #=========================================================================== def updateTarget(self): currFolder = str(self["filelist"].getCurrentDirectory()) currFile = str(self.filelist.getCurrentDirectory()) + str( self.filelist.getFilename()) if currFolder is not None: self["help"].setText(_("Selected file: %s") % (currFile)) else: self["help"].setText(_("Invalid Location"))
def __init__(self, session): Screen.__init__(self, session) HelpableScreen.__init__(self) self.bScreen = self.session.instantiateDialog(Blackscreen) self.bScreen.show() self.myaudioScreenSaverconfig = int(config.plugins.EVOMC_saver.myaudioScreenSaver.value) self.myaudioScreenSaverTimer = eTimer() self.myaudioScreenSaverTimer.timeout.get().append(self.myaudioScreenSaverTimer_Timeout) self.ResetmyaudioScreenSaverTimer() self.start_timer = eTimer() self.moveTimer = eTimer() self.start_timer.timeout.get().append(self.onLayoutFinished) self.isVisible = True self.oldService = self.session.nav.getCurrentlyPlayingServiceReference() self.skindir = "/usr/lib/enigma2/python/Plugins/Extensions/EVOMediaCenter/skins/basic" self.coverArtFileName = "" self["PositionGauge"] = ServicePositionGauge(self.session.nav) self["key_red"] = Button(_("Delete")) self["key_green"] = Button(_("Play All")) self["key_yellow"] = Button(_("Favorites")) self["key_blue"] = Button(_("Settings")) self["fileinfo"] = Label() self["coverArt"] = MediaPixmap() self["currentfolder"] = Label() self["currentfavname"] = Label() self.playlist = MyPlayList() self.currList = "filelist" self.curfavfolder = -1 self["play"] = Pixmap() self["stop"] = Pixmap() self["curplayingtitle"] = Label() self.currPlaying = 0 self.PlaySingle = 0 self.PlaySingleRUN = 0 self.PlayAll = 0 self.__event_tracker = ServiceEventTracker(screen=self, eventmap= { iPlayableService.evEOF: self.doEOF, iPlayableService.evStopped: self.StopPlayback, iPlayableService.evUser+11: self.__evDecodeError, iPlayableService.evUser+12: self.__evPluginError, iPlayableService.evUser+13: self["coverArt"].embeddedCoverArt }) self["actions"] = HelpableActionMap(self, "EVOMC_AudioPlayerActions", { "ok": (self.KeyPlaySingle, "Play selected file"), "left": (self.leftUp, "List Top"), "right": (self.rightDown, "List Bottom"), "up": (self.up, "List up"), "down": (self.down, "List down"), "menu": (self.KeyMenu, "File / Folder Options"), "video": (self.visibility, "Show / Hide Player"), "nextBouquet": (self.NextFavFolder, "Next Favorite Folder"), "prevBouquet": (self.PrevFavFolder, "Previous Favorite Folder"), "red": (self.deleteFile, "Delete File"), "green": (self.KeyPlayAll, "Play All"), "yellow": (self.FavoriteFolders, "Favorite Folders"), "blue": (self.Settings, "Settings"), }, -2) self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", { "cancel": (self.Exit, "Exit Audio Player"), }, -2) self["InfobarShowHideActions"] = HelpableActionMap(self, "InfobarShowHideActions", { "toggleShow": (self.showFileInfo, "Show File Info"), }, -2) self["MediaPlayerActions"] = HelpableActionMap(self, "MediaPlayerActions", { "stop": (self.StopPlayback, "Stop Playback"), }, -2) self.aspect = getAspect() currDir = config.plugins.EVOMC_ap.lastDir.value if not pathExists(currDir): currDir = "/" self["currentfolder"].setText(str(currDir)) self.filelist = FileList(currDir, useServiceRef = True, showDirectories = True, showFiles = True, matchingPattern = "(?i)^.*\.(mp3|ogg|wma|wav|wave|flac|m4a)") self["filelist"] = self.filelist self["thumbnail"] = Pixmap() evfd.getInstance().vfd_write_string("EVO-AUDIOPLAYER") self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.ThumbTimer.start(config.plugins.EVOMC_ap.preview_delay.getValue() * 1000, True) self.DimmerTimer = eTimer() self.DimmerTimer.callback.append(self.showDimmer) self.DimmerTimer.start(config.plugins.EVOMC_all.dimmer_delay.getValue() * 1000, True) self.BlinkingPlayIconTimer = eTimer() self.BlinkingPlayIconTimer.callback.append(self.BlinkingPlayIcon) self.blinking=False self.FileInfoTimer = eTimer() self.FileInfoTimer.callback.append(self.updateFileInfo) self.myaudioScreenSaverconfig = int(config.plugins.EVOMC_saver.myaudioScreenSaver.value) self.ResetmyaudioScreenSaverTimer()
class Selectmusic(Screen): def __init__(self, session): Screen.__init__(self, session) self['actions'] = HelpableActionMap(self, 'MC_AudioPlayerActions', {'ok': (self.KeyOk, 'Play selected file'), 'left': (self.leftUp, 'List Top'), 'right': (self.rightDown, 'List Bottom'), 'up': (self.up, 'List up'), 'down': (self.down, 'List down')}, -2) self['OkCancelActions'] = HelpableActionMap(self, 'OkCancelActions', {'cancel': self.close}, -2) currDir = config.plugins.mc_ap.lastDir.value if not pathExists(currDir): currDir = '/' inhibitDirs = ['/bin', '/boot', '/dev', '/dev.static', '/etc', '/lib', '/proc', '/ram', '/root', '/sbin', '/sys', '/tmp', '/usr', '/var'] self.filelist = FileList(currDir, useServiceRef=True, showDirectories=True, showFiles=True, matchingPattern='(?i)^.*\\.(m3u|mp2|mp3|wav|wave|pls|wma|m4a|ogg|ra|flac)', inhibitDirs=inhibitDirs) self['filelist'] = self.filelist self['currentfolder'] = Label() self['currentfolder'].setText(str(currDir)) def up(self): self['filelist'].up() def down(self): self['filelist'].down() def leftUp(self): self['filelist'].pageUp() def rightDown(self): self['filelist'].pageDown() def KeyOk(self): self.filename = self.filelist.getFilename() self['currentfolder'].setText(str(self.filelist.getCurrentDirectory())) if self.filelist.getFilename() is not None: if self.filelist.canDescent(): self.filelist.descent() else: config.plugins.mc_pp.music.value = self.filename config.plugins.mc_pp.save() self.close() elif self.filelist.canDescent(): self.filelist.descent() else: config.plugins.mc_pp.music.value = self.filename config.plugins.mc_pp.save() self.close() return
class EVOMC_AudioPlayer(Screen, HelpableScreen): def __init__(self, session): Screen.__init__(self, session) HelpableScreen.__init__(self) self.bScreen = self.session.instantiateDialog(Blackscreen) self.bScreen.show() self.myaudioScreenSaverconfig = int(config.plugins.EVOMC_saver.myaudioScreenSaver.value) self.myaudioScreenSaverTimer = eTimer() self.myaudioScreenSaverTimer.timeout.get().append(self.myaudioScreenSaverTimer_Timeout) self.ResetmyaudioScreenSaverTimer() self.start_timer = eTimer() self.moveTimer = eTimer() self.start_timer.timeout.get().append(self.onLayoutFinished) self.isVisible = True self.oldService = self.session.nav.getCurrentlyPlayingServiceReference() self.skindir = "/usr/lib/enigma2/python/Plugins/Extensions/EVOMediaCenter/skins/basic" self.coverArtFileName = "" self["PositionGauge"] = ServicePositionGauge(self.session.nav) self["key_red"] = Button(_("Delete")) self["key_green"] = Button(_("Play All")) self["key_yellow"] = Button(_("Favorites")) self["key_blue"] = Button(_("Settings")) self["fileinfo"] = Label() self["coverArt"] = MediaPixmap() self["currentfolder"] = Label() self["currentfavname"] = Label() self.playlist = MyPlayList() self.currList = "filelist" self.curfavfolder = -1 self["play"] = Pixmap() self["stop"] = Pixmap() self["curplayingtitle"] = Label() self.currPlaying = 0 self.PlaySingle = 0 self.PlaySingleRUN = 0 self.PlayAll = 0 self.__event_tracker = ServiceEventTracker(screen=self, eventmap= { iPlayableService.evEOF: self.doEOF, iPlayableService.evStopped: self.StopPlayback, iPlayableService.evUser+11: self.__evDecodeError, iPlayableService.evUser+12: self.__evPluginError, iPlayableService.evUser+13: self["coverArt"].embeddedCoverArt }) self["actions"] = HelpableActionMap(self, "EVOMC_AudioPlayerActions", { "ok": (self.KeyPlaySingle, "Play selected file"), "left": (self.leftUp, "List Top"), "right": (self.rightDown, "List Bottom"), "up": (self.up, "List up"), "down": (self.down, "List down"), "menu": (self.KeyMenu, "File / Folder Options"), "video": (self.visibility, "Show / Hide Player"), "nextBouquet": (self.NextFavFolder, "Next Favorite Folder"), "prevBouquet": (self.PrevFavFolder, "Previous Favorite Folder"), "red": (self.deleteFile, "Delete File"), "green": (self.KeyPlayAll, "Play All"), "yellow": (self.FavoriteFolders, "Favorite Folders"), "blue": (self.Settings, "Settings"), }, -2) self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", { "cancel": (self.Exit, "Exit Audio Player"), }, -2) self["InfobarShowHideActions"] = HelpableActionMap(self, "InfobarShowHideActions", { "toggleShow": (self.showFileInfo, "Show File Info"), }, -2) self["MediaPlayerActions"] = HelpableActionMap(self, "MediaPlayerActions", { "stop": (self.StopPlayback, "Stop Playback"), }, -2) self.aspect = getAspect() currDir = config.plugins.EVOMC_ap.lastDir.value if not pathExists(currDir): currDir = "/" self["currentfolder"].setText(str(currDir)) self.filelist = FileList(currDir, useServiceRef = True, showDirectories = True, showFiles = True, matchingPattern = "(?i)^.*\.(mp3|ogg|wma|wav|wave|flac|m4a)") self["filelist"] = self.filelist self["thumbnail"] = Pixmap() evfd.getInstance().vfd_write_string("EVO-AUDIOPLAYER") self.ThumbTimer = eTimer() self.ThumbTimer.callback.append(self.showThumb) self.ThumbTimer.start(config.plugins.EVOMC_ap.preview_delay.getValue() * 1000, True) self.DimmerTimer = eTimer() self.DimmerTimer.callback.append(self.showDimmer) self.DimmerTimer.start(config.plugins.EVOMC_all.dimmer_delay.getValue() * 1000, True) self.BlinkingPlayIconTimer = eTimer() self.BlinkingPlayIconTimer.callback.append(self.BlinkingPlayIcon) self.blinking=False self.FileInfoTimer = eTimer() self.FileInfoTimer.callback.append(self.updateFileInfo) self.myaudioScreenSaverconfig = int(config.plugins.EVOMC_saver.myaudioScreenSaver.value) self.ResetmyaudioScreenSaverTimer() def onLayoutFinished(self): global startindex self.startindex = startindex self.num += 1 if startindex is not None: self.start_timer.stop() else: if self.num < 30: self.start_timer.start(2000) else: self.start_timer.stop() fehler = "Fehler beim automatischen Start" self.session.open(MessageBox,_("%s" %fehler), MessageBox.TYPE_INFO) def myaudioScreenSaverTimer_Timeout(self): if self.myaudioScreenSaverTimer.isActive(): self.myaudioScreenSaverTimer.stop() self.session.openWithCallback(self.ResetmyaudioScreenSaverTimer,myaudioScreenSaver) def ResetmyaudioScreenSaverTimer(self): if onmyaudioScreenSaver: pass if self.myaudioScreenSaverconfig != 0: if self.myaudioScreenSaverTimer.isActive(): self.myaudioScreenSaverTimer.stop() self.myaudioScreenSaverTimer.start(self.myaudioScreenSaverconfig * 1000) def deleteFile(self): if self.currList == "filelist": self.service = self.filelist.getServiceRef() else: self.service = self.playlist.getSelection() if self.service is None: return if self.service.type != 4098 and self.session.nav.getCurrentlyPlayingServiceReference() is not None: if self.service == self.session.nav.getCurrentlyPlayingServiceReference(): self.stopEntry() serviceHandler = eServiceCenter.getInstance() offline = serviceHandler.offlineOperations(self.service) info = serviceHandler.info(self.service) name = info and info.getName(self.service) result = False if offline is not None: # simulate first if not offline.deleteFromDisk(1): result = True if result == True: self.session.openWithCallback(self.deleteConfirmed_offline, MessageBox, _("Do you really want to delete %s?") % (name)) else: self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR) def deleteConfirmed_offline(self, confirmed): if confirmed: serviceHandler = eServiceCenter.getInstance() offline = serviceHandler.offlineOperations(self.service) result = False if offline is not None: # really delete! if not offline.deleteFromDisk(0): result = True if result == False: self.session.open(MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR) else: self.removeListEntry() def removeListEntry(self): self.savePlaylistOnExit = True currdir = self.filelist.getCurrentDirectory() self.filelist.changeDir(currdir) deleteend = False while not deleteend: index = 0 deleteend = True if len(self.playlist) > 0: for x in self.playlist.list: if self.service == x[0]: self.playlist.deleteFile(index) deleteend = False break index += 1 self.playlist.updateList() if self.currList == "playlist": if len(self.playlist) == 0: self.switchToFileList() def up(self): self["filelist"].up() system("stfbcontrol a 255") self.ThumbTimer.start(config.plugins.EVOMC_ap.preview_delay.getValue() * 1000, True) self.DimmerTimer.start(config.plugins.EVOMC_all.dimmer_delay.getValue() * 1000, True) def down(self): self["filelist"].down() system("stfbcontrol a 255") self.ThumbTimer.start(config.plugins.EVOMC_ap.preview_delay.getValue() * 1000, True) self.DimmerTimer.start(config.plugins.EVOMC_all.dimmer_delay.getValue() * 1000, True) def leftUp(self): self["filelist"].pageUp() system("stfbcontrol a 255") self.ThumbTimer.start(config.plugins.EVOMC_ap.preview_delay.getValue() * 1000, True) self.DimmerTimer.start(config.plugins.EVOMC_all.dimmer_delay.getValue() * 1000, True) def rightDown(self): self["filelist"].pageDown() system("stfbcontrol a 255") self.ThumbTimer.start(config.plugins.EVOMC_ap.preview_delay.getValue() * 1000, True) self.DimmerTimer.start(config.plugins.EVOMC_all.dimmer_delay.getValue() * 1000, True) def showDimmer(self): if config.plugins.EVOMC_all.showDimmer.value: system("stfbcontrol a 80") # else: # pass def NextFavFolder(self): system("stfbcontrol a 255") if self.curfavfolder + 1 < config.plugins.EVOMC_favorites.foldercount.value: self.curfavfolder += 1 self.favname = config.plugins.EVOMC_favorites.folders[self.curfavfolder].name.value self.folder = config.plugins.EVOMC_favorites.folders[self.curfavfolder].basedir.value self["currentfolder"].setText(("%s") % (self.folder)) self["currentfavname"].setText(("%s") % (self.favname)) if pathExists(self.folder) == True: self["filelist"].changeDir(self.folder) else: return def PrevFavFolder(self): system("stfbcontrol a 255") if self.curfavfolder <= 0: return else: self.curfavfolder -= 1 self.favname = config.plugins.EVOMC_favorites.folders[self.curfavfolder].name.value self.folder = config.plugins.EVOMC_favorites.folders[self.curfavfolder].basedir.value self["currentfolder"].setText(("%s") % (self.folder)) self["currentfavname"].setText(("%s") % (self.favname)) if pathExists(self.folder) == True: self["filelist"].changeDir(self.folder) def KeyPlaySingle(self): filename = self["filelist"].getFilename() print "filename", filename print "self.PlaySingle", self.PlaySingle if self.PlaySingleRUN == 0: if self.PlaySingle == 1 or config.plugins.EVOMC_ap.showPreview.getValue(): if filename.upper().endswith(".MP3") or filename.upper().endswith(".OGG") or filename.upper().endswith(".WAV") or filename.upper().endswith(".WAVE") or filename.upper().endswith(".FLAC") or filename.upper().endswith(".M4A"): return else: if config.plugins.EVOMC_ap.showPreview.getValue(): if filename.upper().endswith(".MP3") or filename.upper().endswith(".OGG") or filename.upper().endswith(".WAV") or filename.upper().endswith(".WAVE") or filename.upper().endswith(".FLAC") or filename.upper().endswith(".M4A"): return system("stfbcontrol a 255") self.ThumbTimer.stop() if self["filelist"].canDescent(): self["currentfavname"].setText("") self.curfavfolder = -1 self.filelist.descent() self["currentfolder"].setText(str(self.filelist.getCurrentDirectory())) else: self.PlaySingle = 1 self.PlaySingleRUN = 1 self.PlayService() self.BlinkingPlayIconTimer.stop() def KeyPlayAll(self): self.ThumbTimer.stop() if not self["filelist"].canDescent(): self.PlaySingle = 0 self.PlayAll = 1 self.PlayService() self.BlinkingPlayIconTimer.start(1000, True) def PlayService(self): system("stfbcontrol a 255") self.StopPlayback() self.filelist.refresh() self.currPlaying = 1 if self.PlayAll == 1: self.BlinkingPlayIconTimer.start(1000, True) evfd.getInstance().vfd_write_string("PLAY") self.session.nav.playService(self["filelist"].getServiceRef()) self.FileInfoTimer.start(2000, True) self["play"].instance.setPixmapFromFile(str(self.skindir) + "/images/icons/play_enabled.png") self["stop"].instance.setPixmapFromFile(str(self.skindir) + "/images/icons/stop_disabled.png") system("vfdctl +play") system("vfdctl +mp3") system("vfdctl +music") path = self["filelist"].getFilename() self["coverArt"].updateCoverArt(path) def JumpToFolder(self, jumpto = None): if jumpto is None: return else: self["filelist"].changeDir(jumpto) self["currentfolder"].setText(("%s") % (jumpto)) def FavoriteFolders(self): self.session.openWithCallback(self.JumpToFolder, EVOMC_FavoriteFolders) def StartThumb(self): self.session.openWithCallback(self.returnVal, ThumbView, self.filelist.getFileList(), self.filelist.getFilename(), self.filelist.getCurrentDirectory()) def showThumb(self): if config.plugins.EVOMC_ap.showPreview.getValue() == False: return if self["filelist"].canDescent(): return else: if self["filelist"].getServiceRef() is not None: system("stfbcontrol a 255") self.ThumbTimer.stop() system("killall -9 showiframe") system("stfbcontrol a 255") self.filelist.refresh() self.session.nav.stopService() self.session.nav.playService(self["filelist"].getServiceRef()) self.currPlaying = 1 self["play"].instance.setPixmapFromFile(str(self.skindir) + "/images/icons/play_enabled.png") self["stop"].instance.setPixmapFromFile(str(self.skindir) + "/images/icons/stop_disabled.png") self.FileInfoTimer.start(2000, True) self.BlinkingPlayIconTimer.start(1000, True) def returnVal(self, val=0): if val > 0: for x in self.filelist.getFileList(): if x[0][1] == True: val += 1 self.filelist.moveToIndex(val) def StartExif(self): if not self.filelist.canDescent(): self.session.open(ExifView, self.filelist.getCurrentDirectory() + self.filelist.getFilename(), self.filelist.getFilename()) def visibility(self, force=1): if self.isVisible == True: self.isVisible = False self.hide() else: self.isVisible = True self.show() def BlinkingPlayIcon(self): if self.blinking: self.blinking=False self["play"].instance.setPixmapFromFile(str(self.skindir) + "/images/icons/play_disabled.png") self.BlinkingPlayIconTimer.start(1000, True) else: self.blinking=True self["play"].instance.setPixmapFromFile(str(self.skindir) + "/images/icons/play_enabled.png") self.BlinkingPlayIconTimer.start(1000, True) def StopPlayback(self): evfd.getInstance().vfd_write_string("STOP") if self.isVisible == False: self.show() self.isVisible = True if self.session.nav.getCurrentService() is None: return else: self.session.nav.stopService() self["play"].instance.setPixmapFromFile(str(self.skindir) + "/images/icons/play_disabled.png") self["stop"].instance.setPixmapFromFile(str(self.skindir) + "/images/icons/stop_enabled.png") self.currPlaying = 0 self.BlinkingPlayIconTimer.stop() self.ThumbTimer.stop() system("killall -9 showiframe") system("stfbcontrol a 255") self.ThumbTimer.start(config.plugins.EVOMC_ap.preview_delay.getValue() * 1000, True) self.DimmerTimer.start(config.plugins.EVOMC_all.dimmer_delay.getValue() * 1000, True) system("vfdctl -play") system("vfdctl -mp3") system("vfdctl -music") self.StopPlayback() def showFileInfo(self): if self["filelist"].canDescent(): return else: system("stfbcontrol a 255") self.ThumbTimer.start(config.plugins.EVOMC_ap.preview_delay.getValue() * 1000, True) self.DimmerTimer.start(config.plugins.EVOMC_all.dimmer_delay.getValue() * 1000, True) self.session.open(EVOMC_AudioInfoView, self["filelist"].getCurrentDirectory() + self["filelist"].getFilename() , self["filelist"].getFilename(), self["filelist"].getServiceRef()) def updateFileInfo(self): if self["filelist"].canDescent(): return currPlay = self.session.nav.getCurrentService() if currPlay is not None: stitle = currPlay.info().getInfoString(iServiceInformation.sTagTitle) sArtist = currPlay.info().getInfoString(iServiceInformation.sTagArtist) sAlbum = currPlay.info().getInfoString(iServiceInformation.sTagAlbum) sGenre = currPlay.info().getInfoString(iServiceInformation.sTagGenre) sYear = currPlay.info().getInfoString(iServiceInformation.sTimeCreate) # sComment = currPlay.info().getInfoString(iServiceInformation.sTagComment) if stitle == "": stitle = currPlay.info().getName().split('/')[-1] self["fileinfo"].setText("Title: " + stitle + "\nArtist: " + sArtist + "\nAlbum: " + sAlbum + "\nGenre: " + sGenre) self["curplayingtitle"].setText(stitle) else: pass def doEOF(self): try: print "EVO-MediaCenter: EOF Event ..." if self.PlaySingle == 0: print "Play Next File ..." self.ThumbTimer.stop() self.down() try: self.PlayService() except: pass else: print "Stop Playback ..." self.StopPlayback() system("vfdctl -play") system("vfdctl -mp3") system("vfdctl -music") except: pass def __evDecodeError(self): currPlay = self.session.nav.getCurrentService() sAudioType = currPlay.info().getInfoString(iServiceInformation.sUser+10) print "[__evAudioDecodeError] audio-codec %s can't be decoded by hardware" % (sAudioType) self.session.open(MessageBox, _("This UFS can't decode %s streams!") % sAudioType, type = MessageBox.TYPE_INFO,timeout = 5 ) def __evPluginError(self): currPlay = self.session.nav.getCurrentService() message = currPlay.info().getInfoString(iServiceInformation.sUser+12) print "[__evPluginError]" , message self.session.open(MessageBox, message, type = MessageBox.TYPE_INFO,timeout = 20 ) def Playlists(self): evfd.getInstance().vfd_write_string("PLAYLIST") self.ThumbTimer.stop() self.session.open(MessageBox,"Coming soon ... :)", MessageBox.TYPE_INFO) def KeyMenu(self): self.ThumbTimer.stop() if self["filelist"].canDescent(): if self.filelist.getCurrent()[0][1]: self.currentDirectory = self.filelist.getCurrent()[0][0] self.foldername = self.currentDirectory.split('/') self.foldername = self.foldername[-2] self.session.open(EVOMC_FolderOptions, self.currentDirectory, self.foldername) def Settings(self): evfd.getInstance().vfd_write_string("SETTINGS") system("stfbcontrol a 255") self.ThumbTimer.stop() self.session.open(AudioPlayerSettings) config.plugins.EVOMC_ap.save() config.plugins.EVOMC_all.save() def Exit(self): if self.isVisible == False: self.visibility() return if self.filelist.getCurrentDirectory() is None: config.plugins.EVOMC_ap.lastDir.value = "/" else: config.plugins.EVOMC_ap.lastDir.value = self.filelist.getCurrentDirectory() system("killall -9 showiframe") system("stfbcontrol a 255") system("vfdctl -play") system("vfdctl -mp3") system("vfdctl -music") self.ThumbTimer.stop() self.DimmerTimer.stop() self.FileInfoTimer.stop() del self["coverArt"].picload config.plugins.EVOMC_ap.save() config.plugins.EVOMC_all.save() self.session.nav.stopService() evfd.getInstance().vfd_write_string("EVO-MediaCenter") self.close()
def __init__(self, session, args=None): Screen.__init__(self, session) InfoBarAudioSelection.__init__(self) InfoBarCueSheetSupport.__init__(self, actionmap="MediaPlayerCueSheetActions") InfoBarNotifications.__init__(self) InfoBarBase.__init__(self) InfoBarSubtitleSupport.__init__(self) HelpableScreen.__init__(self) self.summary = None self.playlistparsers = {} self.addPlaylistParser(PlaylistIOM3U, "m3u") self.addPlaylistParser(PlaylistIOPLS, "pls") self.addPlaylistParser(PlaylistIOInternal, "e2pls") # 'None' is magic to start at the list of mountpoints defaultDir = config.mediaplayer.defaultDir.getValue() self.filelist = FileList( defaultDir, matchingPattern= "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|mov|m2ts|flv|wma|wmv)", useServiceRef=True, additionalExtensions="4098:m3u 4098:e2pls 4098:pls") self["filelist"] = self.filelist self.playlist = MyPlayList() self.is_closing = False self.delname = "" self["playlist"] = self.playlist self["PositionGauge"] = ServicePositionGauge(self.session.nav) self["currenttext"] = Label("") self["artisttext"] = Label(_("Artist") + ':') self["artist"] = Label("") self["titletext"] = Label(_("Title") + ':') self["title"] = Label("") self["albumtext"] = Label(_("Album") + ':') self["album"] = Label("") self["yeartext"] = Label(_("Year") + ':') self["year"] = Label("") self["genretext"] = Label(_("Genre") + ':') self["genre"] = Label("") self["coverArt"] = MediaPixmap() self["repeat"] = MultiPixmap() self.seek_target = None from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier hotplugNotifier.append(self.hotplugCB) class MoviePlayerActionMap(NumberActionMap): def __init__(self, player, contexts=[], actions={}, prio=0): NumberActionMap.__init__(self, contexts, actions, prio) self.player = player def action(self, contexts, action): self.player.show() return NumberActionMap.action(self, contexts, action) self["OkCancelActions"] = HelpableActionMap( self, "OkCancelActions", { "ok": (self.ok, _("add file to playlist")), "cancel": (self.exit, _("exit mediaplayer")), }, -2) self["MediaPlayerActions"] = HelpableActionMap( self, "MediaPlayerActions", { "play": (self.xplayEntry, _("play entry")), "pause": (self.pauseEntry, _("pause")), "stop": (self.stopEntry, _("stop entry")), "previous": (self.previousMarkOrEntry, _("play from previous mark or playlist entry")), "next": (self.nextMarkOrEntry, _("play from next mark or playlist entry")), "menu": (self.showMenu, _("menu")), "skipListbegin": (self.skip_listbegin, _("jump to listbegin")), "skipListend": (self.skip_listend, _("jump to listend")), "prevBouquet": (self.switchToPlayList, _("switch to playlist")), "nextBouquet": (self.switchToFileList, _("switch to filelist")), "delete": (self.deletePlaylistEntry, _("delete playlist entry")), "shift_stop": (self.clear_playlist, _("clear playlist")), "shift_record": (self.playlist.PlayListShuffle, _("shuffle playlist")), "subtitles": (self.subtitleSelection, _("Subtitle selection")), }, -2) self["InfobarEPGActions"] = HelpableActionMap( self, "InfobarEPGActions", { "showEventInfo": (self.showEventInformation, _("show event details")), }) self["actions"] = MoviePlayerActionMap( self, ["DirectionActions"], { "right": self.rightDown, "rightRepeated": self.doNothing, "rightUp": self.rightUp, "left": self.leftDown, "leftRepeated": self.doNothing, "leftUp": self.leftUp, "up": self.up, "upRepeated": self.up, "upUp": self.doNothing, "down": self.down, "downRepeated": self.down, "downUp": self.doNothing, }, -2) InfoBarSeek.__init__(self, actionmap="MediaPlayerSeekActions") self.onClose.append(self.delMPTimer) self.righttimer = False self.rightKeyTimer = eTimer() self.rightKeyTimer_conn = self.rightKeyTimer.timeout.connect( self.rightTimerFire) self.lefttimer = False self.leftKeyTimer = eTimer() self.leftKeyTimer_conn = self.leftKeyTimer.timeout.connect( self.leftTimerFire) self.currList = "filelist" self.isAudioCD = False self.AudioCD_albuminfo = {} self.cdAudioTrackFiles = [] self.onShown.append(self.applySettings) self.playlistIOInternal = PlaylistIOInternal() list = self.playlistIOInternal.open( resolveFilename(SCOPE_CONFIG, "playlist.e2pls")) if list: for x in list: self.playlist.addFile(x.ref) self.playlist.updateList() self.__event_tracker = ServiceEventTracker( screen=self, eventmap={ iPlayableService.evUpdatedInfo: self.__evUpdatedInfo, eServiceMP3.evAudioDecodeError: self.__evAudioDecodeError, eServiceMP3.evVideoDecodeError: self.__evVideoDecodeError, eServiceMP3.evPluginError: self.__evPluginError, eServiceMP3.evEmbeddedCoverArt: self["coverArt"].embeddedCoverArt, eServiceMP3.evUpdatedBitrate: self.__evUpdatedBitrate, eServiceMP3.evStreamingSrcError: self.__evStreamingSrcError })
def __init__(self, session, text = '', filename = '', currDir = None, location = None, userMode = False, minFree = None, autoAdd = False, editDir = False, inhibitDirs = [], inhibitMounts = []): self.session = session if dwidth == 1280: skin = '/usr/lib/enigma2/python/Plugins/Extensions/SatVenusPanel/Skin/sellocHD.xml' else: skin = '/usr/lib/enigma2/python/Plugins/Extensions/SatVenusPanel/Skin/sellocFHD.xml' f = open(skin, 'r') self.skin = f.read() f.close() Screen.__init__(self, session) HelpableScreen.__init__(self) self['text'] = StaticText(_('Selected download location:')) self.text = text self.filename = filename self.minFree = minFree self.reallocation = location self.location = location and location.value[:] or [] self.userMode = userMode self.autoAdd = autoAdd self.editDir = editDir self.inhibitDirs = inhibitDirs self.inhibitMounts = inhibitMounts inhibitDirs = ['/bin', '/boot', '/dev', '/lib', '/proc', '/sbin', '/sys', '/mnt', '/var', '/home', '/tmp', '/srv', '/etc', '/share', '/usr', '/ba', '/MB_Images'] inhibitMounts = ['/mnt', '/ba', '/MB_Images'] self['filelist'] = FileList(currDir, showDirectories=True, showFiles=False, inhibitMounts=inhibitMounts, inhibitDirs=inhibitDirs) # self['mountlist'] = MenuList(mountedDevs) self['ButtonGreentext'] = Label(_('SAVE')) self['ButtonRedtext'] = Label(_('Exit')) self['target'] = Label() self['actions'] = ActionMap(['SetupActions', 'ColorActions'], {'red': self.close, 'cancel': self.close}, -2) if self.userMode: self.usermodeOn() class DownloadLocationActionMap(HelpableActionMap): def __init__(self, parent, context, actions = {}, prio = 0): HelpableActionMap.__init__(self, parent, context, actions, prio) self['WizardActions'] = DownloadLocationActionMap(self, 'WizardActions', {'left': self.left, 'right': self.right, 'up': self.up, 'down': self.down, 'ok': (self.ok, _('Select')), 'back': (self.cancel, _('Cancel'))}, -2) self['ColorActions'] = DownloadLocationActionMap(self, 'ColorActions', {'red': self.cancel, 'green': self.select}, -2) self.onLayoutFinish.append(self.switchToFileListOnStart)