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 Plugins(path, **kwargs): global plugin_path plugin_path = path return [ PluginDescriptor(name=_("NetworkBrowser"), description=_("Search for network shares"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": NetworkBrowserCallFunction, "menuEntryName": lambda x: _("NetworkBrowser"), "menuEntryDescription": lambda x: _("Search for network shares...")}), PluginDescriptor(name=_("MountManager"), description=_("Manage network shares"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": MountManagerCallFunction, "menuEntryName": lambda x: _("MountManager"), "menuEntryDescription": lambda x: _("Manage your network shares...")}), ]
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) self.list = [ ] self.XMLKeymaps = [] self.onChangedEntry = [ ] ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry) self.setup_title = _("Keymap configurator") self["actions"] = ActionMap(["SetupActions", "ColorActions"], { "cancel": self.keyCancel, "green": self.keySave, "ok": self.keySave, "red": self.keyCancel, "blue": self.keyBlue, "yellow": self.LoadXML, }, -2) self["key_green"] = Label(_("Save")) self["key_red"] = Label(_("Cancel")) self["key_yellow"] = Label(_("Read")) self["key_blue"] = Label(_("Make backup")) self.myDir=eEnv.resolve("${datadir}/enigma2/") self.myConsole = Console() self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session): Screen.__init__(self, session) self.onChangedEntry = [ ] self.list = [ ] ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry) self.setup_title = _("Graterlia system settings configurator") self["actions"] = ActionMap(["SetupActions", "ColorActions"], { "cancel": self.keyCancel, "green": self.keySave, "ok": self.keySave, "red": self.keyCancel, "blue": self.keyBlue, }, -2) self["key_green"] = Label(_("Save")) self["key_red"] = Label(_("Cancel")) self["key_blue"] = Label(_("Restart RC")) self.MySetupFile = "" if fileExists("/etc/init.d/graterlia_init"): self.MySetupFile="/etc/sysctl.gos" else: self.MySetupFile= resolveFilename(SCOPE_PLUGINS, 'Extensions/GOSmanager/sysctl.gos') #to do developowania na openpliPC self.myConsole = Console() #self.runSetup() self.onLayoutFinish.append(self.layoutFinished)
def startTVWallfromMenu(menuid, **kwargs): if menuid == "mainmenu" and config.plugins.TVWall.showinMainMenu.value == True: return [(_("TVWall"), main, "TVWall_main", None)] elif menuid != "system": return [ ] else: return [(_("TVWall config"), mainSetup, "TVWallconfig", None)]
def selectionChanged(self): sel = self["menu"].getCurrent() self.setPicture(sel[0]) if sel[2] == self.enabled_pic: self["key_green"].setText(_("off")) elif sel[2] == self.disabled_pic: self["key_green"].setText(_("on"))
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, hostName): Screen.__init__(self, session) self.onChangedEntry = [ ] self.list = [ ] ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry) self.hostName = hostName self.setup_title = _("Configuration of %s") % self.hostName self["key_green"] = Label(_("Save")) self["key_red"] = Label(_("Cancel")) self["key_blue"] = Label(_('Virtual Keyboard')) self["actions"] = ActionMap(["SetupActions", "ColorActions"], { "cancel": self.keyCancel, "green": self.keySave, "ok": self.keySave, "red": self.keyCancel, "blue": self.keyVirtualKeyBoard, }, -2) self.host = __import__('forums.forum' + hostName, globals(), locals(), ['GetConfigList'], -1) self.runSetup() self.onLayoutFinish.append(self.layoutFinished)
def __init__(self, session): Screen.__init__(self, session) self.Console = Console() self["key_red"] = Label(_("Stop")) self["key_green"] = Label(_("Start")) self["key_yellow"] = Label(_("Restart")) self["key_blue"] = Label(_("Setup")) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "cancel": self.cancel, "ok": self.ok, "green": self.start, "red": self.stop, "yellow": self.restart, "blue": self.setup }, -1) self["status"] = ScrollLabel() self["list"] = List([]) self.actcam = config.plugins.AltSoftcam.actcam.value self.camstartcmd = "" self.CreateInfo() self.Timer = eTimer() self.Timer.callback.append(self.listecminfo) self.Timer.start(1000*4, False) self.title = _("SoftCam Manager")
def __init__(self, session, plugin_path, hostinfo = None ): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) self.hostinfo = hostinfo self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid self.cache_file = '/etc/enigma2/' + self.hostinfo + '.cache' #Path to cache directory self.createConfig() self["actions"] = NumberActionMap(["SetupActions"], { "ok": self.ok, "back": self.close, "cancel": self.close, "red": self.close, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self.list = [] ConfigListScreen.__init__(self, self.list,session = self.session) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Pixmap() self["HelpWindow"] = Pixmap() self["introduction"] = StaticText(_("Press OK to save settings.")) self["key_red"] = StaticText(_("Close"))
def build_UpgradeMenu( result, retval, extra_args = None): printDEBUG( "build_UpgradeMenu" , "..." ) self.list.append((_('Upgrade packages', "plugin-GOSmanager"), '', _('Recommended update installed packages', "plugin-GOSmanager"), 'UpgradeAll', self.upgradeablepng, self.divpng)) self['list'].setList(self.list) self.BlockedInput = False isRelease=False if fileExists("/etc/opkg/opkg.conf"): with open ("/etc/opkg/opkg.conf", "r") as myconfigfile: for line in myconfigfile: if line[0] == '#' and line.find('graterlia.xunil.pl/repodata/testing') > 0: isRelease=True break myconfigfile.close() if isRelease == True: releaseResults = '' inTESTdescr = False for x in result.splitlines(): if x.startswith("* [test]"): inTESTdescr = True elif x.startswith("* [release]"): inTESTdescr = False elif x.startswith("<<"): releaseResults += '\n' inTESTdescr = False if inTESTdescr == False: releaseResults += x + '\n' result = releaseResults.replace("\n\n\n","\n").replace("\n\n","\n").replace(">>\n<<",">>\nAktualizacje gałęzi test\n<<").replace("\n<<","\n\n<<") self["whatUPDATED"].setText(result) self.keyGreenAction = 'UpgradeAll'
def createSetup(self): self.list = [] self.activeEntry = getConfigListEntry(_("Active"), self.activeConfigEntry) self.list.append(self.activeEntry) self.sharenameEntry = getConfigListEntry(_("Local share name"), self.sharenameConfigEntry) self.list.append(self.sharenameEntry) self.mounttypeEntry = getConfigListEntry(_("Mount type"), self.mounttypeConfigEntry) self.list.append(self.mounttypeEntry) self.ipEntry = getConfigListEntry(_("Server IP"), self.ipConfigEntry) self.list.append(self.ipEntry) self.sharedirEntry = getConfigListEntry(_("Server share"), self.sharedirConfigEntry) self.list.append(self.sharedirEntry) self.hdd_replacementEntry = getConfigListEntry(_("use as HDD replacement"), self.hdd_replacementConfigEntry) self.list.append(self.hdd_replacementEntry) if self.optionsConfigEntry.value == self.optionsConfigEntry.default: if self.mounttypeConfigEntry.value == "cifs": self.optionsConfigEntry = NoSave(ConfigText(default = "rw,noatime,noserverino,iocharset=utf8", visible_width = 50, fixed_size = False)) else: self.optionsConfigEntry = NoSave(ConfigText(default = "rw,nolock,soft", visible_width = 50, fixed_size = False)) self.optionsEntry = getConfigListEntry(_("Mount options"), self.optionsConfigEntry) self.list.append(self.optionsEntry) if self.mounttypeConfigEntry.value == "cifs": self.usernameEntry = getConfigListEntry(_("Username"), self.usernameConfigEntry) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_("Password"), self.passwordConfigEntry) self.list.append(self.passwordEntry) self.myBuffers = getConfigListEntry(_("Buffers size:"), self.CurrentBuffers) self.list.append(self.myBuffers) self["config"].list = self.list self["config"].l.setList(self.list) self["config"].onSelectionChanged.append(self.selectionChanged)
def __init__(self, session): Screen.__init__(self, session) self.list = [ ] ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry) self["actions"] = ActionMap(["SetupActions", "ColorActions"], { "cancel": self.keyCancel, "green": self.keySave, "ok": self.keySave, "red": self.keyCancel, "blue": self.keyBlue, "yellow": self.keyYellow, }, -2) self["key_green"] = Label() self["key_green"].setText(_("Save")) self["key_red"] = Label(_("Exit")) self["key_blue"] = Label(_("Update from tuner")) self["key_yellow"] = Label(_("Update from sat")) self.timer = eTimer() self.onLayoutFinish.append(self.layoutFinished)
def buildMountViewItem(self, entry): if entry["isMounted"] is True: isMountedpng = LoadPixmap( cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/ok.png") ) if entry["isMounted"] is False: isMountedpng = LoadPixmap( cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/cancel.png") ) sharename = entry["sharename"] IPdescription = _("IP:") + " " + str(entry["ip"]) DIRdescription = _("Dir:") + " " + str(entry["sharedir"]) if entry["active"] == "True" or entry["active"] == True: activepng = LoadPixmap( cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_on.png") ) if entry["active"] == "False" or entry["active"] == False: activepng = LoadPixmap( cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_error.png") ) if entry["mounttype"] == "nfs": mounttypepng = LoadPixmap( cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/i-nfs.png") ) if entry["mounttype"] == "cifs": mounttypepng = LoadPixmap( cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/i-smb.png") ) return (isMountedpng, sharename, IPdescription, DIRdescription, activepng, mounttypepng)
def restartGUI(self): myMessage = '' if self.BrakPlikuInfo != '': printDEBUG("missing components: %s" % self.BrakPlikuInfo) myMessage += _("Missing components found: %s\n\n") % self.BrakPlikuInfo myMessage += _("Restart necessary, restart GUI now?") restartbox = self.session.openWithCallback(self.restartGUIcb,MessageBox, myMessage, MessageBox.TYPE_YESNO) restartbox.setTitle(_("Message"))
def keyRight(self): ConfigListScreen.keyRight(self) if self["config"].getCurrent()[1] == config.GOSsettings.opkg: if config.GOSsettings.opkg.value == "testing": self.session.open(MessageBox,_("WARNING: The probability of issues in 'testing' branch is high. It's NOT recommended for unexperienced users!\n\nReturning to release branch only through reinstallation!!!"), MessageBox.TYPE_INFO) elif config.GOSsettings.opkg.value == "ready": self.session.open(MessageBox,_("WARNING: The probability of issues in 'ready' branch is small, but exists."), MessageBox.TYPE_INFO) elif self["config"].getCurrent()[1] == config.GOSsettings.ModerateShutDown: self.runSetup()
def Plugins(**kwargs): if GOSHardwareInfo().get_rcstype() == 'ADB5800': return [ PluginDescriptor(name="SVAsetup", where = PluginDescriptor.WHERE_SESSIONSTART, fnc=main ), PluginDescriptor(name=_("Volume Control","plugin-SimpleVolumeAdjustment"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup) ] else: return [ PluginDescriptor(name="SVAsetup", where = PluginDescriptor.WHERE_SESSIONSTART, fnc=main ), PluginDescriptor(name=_("Volume and PIG Control","plugin-SimpleVolumeAdjustment"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup) ]
def checkFreeSpace(self): printDEBUG( "checkFreeSpace" , "" ) self.onShown.remove(self.checkFreeSpace) free_flash_space = self.getFreeSpace('/') if free_flash_space < self.maxSize: self.BlockedInstall = True human_free_space = free_flash_space / 1048576 msg = _('Only %d MB left!!!\nAt least 8MB is required to safely install and upgrade packages.') % human_free_space msg += _('Remove some packages, or upgade from console!') self.session.openWithCallback(self.checkFreeSpaceEnd, MessageBox, msg, MessageBox.TYPE_INFO, timeout = 5)
def onStart(self): self.setTitle(_(self.title)) self.Menulist = [] for item in self.list: try: self.Menulist.append((item[0], _(item[0], "plugin-GOSmanager") , '', '', LoadPixmap(cached=True, path=item[2]) )) except: pass self['list'].setList(self.Menulist) return
def createSetup(self): self.list = [] self.usernameEntry = getConfigListEntry(_("Username"), self.username) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_("Password"), self.password) self.list.append(self.passwordEntry) self["config"].list = self.list self["config"].l.setList(self.list) self["config"].onSelectionChanged.append(self.selectionChanged)
def Plugins(**kwargs): return [ PluginDescriptor(name = _("Alternative SoftCam Manager","plugin-AlternativeSoftCamManager"), description = _("Start, stop, restart SoftCams, change settings.","plugin-AlternativeSoftCamManager"), #where = PluginDescriptor.WHERE_PLUGINMENU, where = [ PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU ], icon = "images/softcam.png", fnc = main), PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, needsRestart = True, fnc = StartCam)]
def middlerun(self, ret=0): tytul = config.GOShddmanager.partitions.value partycja = tytul.split(" ")[0] folder = config.GOShddmanager.folders.value if isPARTITIONmounted(partycja): self.session.openWithCallback(self.endrun, MessageBox, _("Mounted successfully"), type=MessageBox.TYPE_INFO) else: self.session.openWithCallback( self.endrun, MessageBox, _("Error mounting partition"), type=MessageBox.TYPE_INFO )
def ok(self): current = self["config"].getCurrent() if current == self.sharenameEntry or current == self.sharedirEntry or current == self.sharedirEntry or current == self.optionsEntry or current == self.usernameEntry or current == self.passwordEntry: if current[1].help_window.instance is not None: current[1].help_window.instance.hide() sharename = self.sharenameConfigEntry.value if self.mounts.has_key(sharename) is True: self.session.openWithCallback(self.updateConfig, MessageBox, (_("A mount entry with this name already exists!\nUpdate existing entry and continue?\n") ) ) else: self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to save this network mount?\n\n") ) )
def setStatus(self,status = None): if status: self.statuslist = [] if status == 'update': statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/update.png")) self.statuslist.append(( ['info'], statuspng, _("Searching your network. Please wait..."), None, None, None, None )) self['list'].setList(self.statuslist) elif status == 'error': statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/error.png")) self.statuslist.append(( ['info'], statuspng, _("No network devices found!"), None, None, None, None )) self['list'].setList(self.statuslist)
def runSetup(self): config.GOShddmanager = ConfigSubsection() config.GOShddmanager.folders = NoSave(ConfigDirectory(default="/mnt/usb/")) config.GOShddmanager.partitions = NoSave(ConfigSelection(choices=GetPartitions())) self.list.append(getConfigListEntry(_("directory:"), config.GOShddmanager.folders)) self.list.append(getConfigListEntry(_("on partition:"), config.GOShddmanager.partitions)) self["config"].list = self.list self["config"].setList(self.list)
def errorMENU(): printDEBUG( "refreshLists_errorMENU" , "no network connection" ) if len(self.list) >=1: printDEBUG( "refreshLists" , "len(self.list) >=1" ) self.list.pop(-1) self.list.append((_('ERROR connecting to OPKG'), '', _('Neigther internet nor service is working :('), '', self.goremovepng, self.divpng)) self.list.append((_("Install local packet", "plugin-GOSmanager") , " ", _("You will be later prompted for file selection.", "plugin-GOSmanager"), 'InstallLocal', self.gousbpng, self.divpng)) self['list'].setList(self.list) self['key_red'].hide() self['key_green'].hide() self['key_yellow'].hide() self['key_blue'].hide()
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 selectionChanged(self): current = self["list"].getCurrent() self.listindex = self["list"].getIndex() if current: if len(current[0]) >= 2: if current[0][0] in ("nfsShare", "smbShare"): self["infotext"].setText(_("Press OK to mount this share!")) else: selectedhost = current[0][2] if selectedhost in self.expanded: self["infotext"].setText(_("Press OK to collapse this host")) else: self["infotext"].setText(_("Press OK to expand this host"))
def runSetup(self): config.GOShddmanager = ConfigSubsection() config.GOShddmanager.partitions = NoSave(ConfigSelection(choices=GetPartitions(UnmountedOnly=True))) config.GOShddmanager.FormatTypes = NoSave( ConfigSelection(default="ext3", choices=[("ext2", "ext2"), ("ext3", "ext3"), ("ext4", "ext4")]) ) self.list.append(getConfigListEntry(_("partition:"), config.GOShddmanager.partitions)) self.list.append(getConfigListEntry(_("on system:"), config.GOShddmanager.FormatTypes)) self["config"].list = self.list self["config"].setList(self.list)
def __(txt): if txt.find('_(') == -1: txt = _(txt) else: index = 0 while txt.find('_(') != -1: tmptxt = substring_2_translate(txt) translated_tmptxt = _(tmptxt) txt = txt.replace('_(' + tmptxt + ')', translated_tmptxt) index += 1 if index == 10: break return txt
def keySave(self): # openpliPC - F2 emuluje green tytul = config.GOShddmanager.partitions.value partycja = tytul.split(" ")[0] if isEXT(partycja) == True: self.session.openWithCallback( self.endrun, GOSconsole, title=_("Checking /dev/%s") % tytul, cmdlist=[("e2fsck -pfv /dev/%s" % partycja)], ) else: self.session.openWithCallback( self.endrun, MessageBox, _("Only ext[2|3|4] partitions can be checked."), type=MessageBox.TYPE_INFO )