def showMountsList(self): self.list = [] self.mounts = iAutoMount.getMounts() for sharename in self.mounts.keys(): mountentry = iAutoMount.mounts[sharename] self.list.append(self.buildMountViewItem(mountentry)) self["config"].setList(self.list)
def updateNetworkList(self): self.list = [] self.network = {} self.mounts = iAutoMount.getMounts() # reloading mount list for x in self.networklist: if not self.network.has_key(x[2]): self.network[x[2]] = [] self.network[x[2]].append((NetworkDescriptor(name = x[1], description = x[2]), x)) self.network.keys().sort() for x in self.network.keys(): if self.network[x][0][1][3] == '00:00:00:00:00:00': self.device = 'unix' else: self.device = 'windows' if x in self.expanded: networkshares = self.getNetworkShares(x,self.network[x][0][1][1].strip(),self.device) hostentry = self.network[x][0][1] name = hostentry[2] + " ( " +hostentry[1].strip() + " )" expandedIcon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/host.png")) self.list.append(( hostentry, expandedIcon, name, None, None, None, None )) for share in networkshares: self.list.append(self.BuildNetworkShareEntry(share)) else: # HOSTLIST - VIEW hostentry = self.network[x][0][1] name = hostentry[2] + " ( " +hostentry[1].strip() + " )" expandableIcon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/host.png")) self.list.append(( hostentry, expandableIcon, name, None, None, None, None )) if len(self.list): for entry in self.list: entry[0][2]= "%3s.%3s.%3s.%3s" % tuple(entry[0][2].split(".")) self.list.sort(key=lambda x: x[0][2]) for entry in self.list: entry[0][2]= entry[0][2].replace(" ", "") self["list"].setList(self.list) self["list"].setIndex(self.listindex)
def openMountEdit(self, item): if item and item.type != NetworkItem.TYPE_HOST: mounts = iAutoMount.getMounts() self.sharecache_file = None if item.type == NetworkItem.TYPE_NFS: # share entry selected data = iAutoMount.DEFAULT_OPTIONS_NFS if item.type == NetworkItem.TYPE_SMB: # share entry selected data = iAutoMount.DEFAULT_OPTIONS_CIFS self.sharecache_file = eEnv.resolve( "${sysconfdir}/enigma2/") + item.name.strip( ) + '.cache' #Path to cache directory if os_path.exists(self.sharecache_file): print '[Networkbrowser] Loading userinfo from ', self.sharecache_file try: self.hostdata = load_cache(self.sharecache_file) data['username'] = self.hostdata['username'] data['password'] = self.hostdata['password'] except: pass data['active'] = True data['ip'] = item.host data['sharename'] = item.name data['sharedir'] = item.path for sharename, sharedata in mounts.items(): if sharedata['ip'] == item.host and sharedata[ 'sharedir'] == item.path: data = sharedata break Log.i(data) self.session.openWithCallback(self.MountEditClosed, AutoMountEdit, self.skin_path, data)
def openMountEdit(self, item): if item and item.type != NetworkItem.TYPE_HOST: mounts = iAutoMount.getMounts() self.sharecache_file = None if item.type == NetworkItem.TYPE_NFS: # share entry selected data = iAutoMount.DEFAULT_OPTIONS_NFS if item.type == NetworkItem.TYPE_SMB: # share entry selected data = iAutoMount.DEFAULT_OPTIONS_CIFS self.sharecache_file = eEnv.resolve("${sysconfdir}/enigma2/") + item.name.strip() + '.cache' #Path to cache directory if os_path.exists(self.sharecache_file): print '[Networkbrowser] Loading userinfo from ',self.sharecache_file try: self.hostdata = load_cache(self.sharecache_file) data['username'] = self.hostdata['username'] data['password'] = self.hostdata['password'] except: pass data['active'] = True data['ip'] = item.host data['sharename'] = item.name data['sharedir'] = item.path for sharename, sharedata in mounts.items(): if sharedata['ip'] == item.host and sharedata['sharedir'] == item.path: data = sharedata break Log.i(data) self.session.openWithCallback(self.MountEditClosed,AutoMountEdit, self.skin_path, data)
def startRun(self): self.expanded = [] self.setStatus('update') self.mounts = iAutoMount.getMounts() self["infotext"].setText("") self.vc = valid_cache(self.cache_file, self.cache_ttl) if self.cache_ttl > 0 and self.vc != 0: self.process_NetworkIPs() else: self.Timer.start(3000)
def _buildNetworkShareEntry(self, share): verticallineIcon = LoadPixmap( cached=True, path=resolveFilename( SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/verticalLine.png")) if share.type == NetworkItem.TYPE_NFS: newpng = LoadPixmap( cached=True, path=resolveFilename( SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/i-nfs.png")) else: newpng = LoadPixmap( cached=True, path=resolveFilename( SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/i-smb.png")) isMounted = False mounts = iAutoMount.getMounts() for sharename, sharedata in mounts.items(): if sharedata['ip'] == share.host: if share.type == NetworkItem.TYPE_NFS and sharedata[ 'mounttype'] == 'nfs': if share.path == sharedata['sharedir'] and sharedata[ "isMounted"]: isMounted = True elif share.type == NetworkItem.TYPE_SMB and sharedata[ 'mounttype'] == 'cifs': if share.path == sharedata['sharedir'] and sharedata[ "isMounted"]: isMounted = True if isMounted: isMountedpng = LoadPixmap( cached=True, path=resolveFilename( SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/ok.png")) else: isMountedpng = LoadPixmap( cached=True, path=resolveFilename( SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/cancel.png")) return (share, verticallineIcon, None, share.path, share.comment, newpng, isMountedpng)
def openMountEdit(self, selection): if selection: mounts = iAutoMount.getMounts() if selection[0] == 'nfsShare': # share entry selected #Initialize blank mount enty data = iAutoMount.DEFAULT_OPTIONS_NFS # add data data['active'] = True data['ip'] = selection[2] data['sharename'] = selection[1] data['sharedir'] = selection[4] for sharename, sharedata in mounts.items(): if sharedata['ip'] == selection[2] and sharedata[ 'sharedir'] == selection[4]: data = sharedata self.session.openWithCallback(self.MountEditClosed, AutoMountEdit, self.skin_path, data) if selection[0] == 'smbShare': # share entry selected #Initialize blank mount enty data = iAutoMount.DEFAULT_OPTIONS_CIFS # add data data['active'] = True data['ip'] = selection[2] data['sharename'] = selection[1] data['sharedir'] = selection[3] self.sharecache_file = None self.sharecache_file = eEnv.resolve( "${sysconfdir}/enigma2/") + selection[1].strip( ) + '.cache' #Path to cache directory if os_path.exists(self.sharecache_file): print '[Networkbrowser] Loading userinfo from ', self.sharecache_file try: self.hostdata = load_cache(self.sharecache_file) data['username'] = self.hostdata['username'] data['password'] = self.hostdata['password'] except: pass for sharename, sharedata in mounts.items(): if sharedata['ip'] == selection[2].strip( ) and sharedata['sharedir'] == selection[3].strip(): data = sharedata self.session.openWithCallback(self.MountEditClosed, AutoMountEdit, self.skin_path, data)
def openMountEdit(self, selection): if selection: mounts = iAutoMount.getMounts() if selection[0] == 'nfsShare': # share entry selected #Initialize blank mount enty data = iAutoMount.DEFAULT_OPTIONS_NFS # add data data['active'] = True data['ip'] = selection[2] data['sharename'] = selection[1] data['sharedir'] = selection[4] for sharename, sharedata in mounts.items(): if sharedata['ip'] == selection[2] and sharedata['sharedir'] == selection[4]: data = sharedata self.session.openWithCallback(self.MountEditClosed,AutoMountEdit, self.skin_path, data) if selection[0] == 'smbShare': # share entry selected #Initialize blank mount enty data = iAutoMount.DEFAULT_OPTIONS_CIFS # add data data['active'] = True data['ip'] = selection[2] data['sharename'] = selection[1] data['sharedir'] = selection[3] self.sharecache_file = None self.sharecache_file = eEnv.resolve("${sysconfdir}/enigma2/") + selection[1].strip() + '.cache' #Path to cache directory if os_path.exists(self.sharecache_file): print '[Networkbrowser] Loading userinfo from ',self.sharecache_file try: self.hostdata = load_cache(self.sharecache_file) data['username'] = self.hostdata['username'] data['password'] = self.hostdata['password'] except: pass for sharename, sharedata in mounts.items(): if sharedata['ip'] == selection[2].strip() and sharedata['sharedir'] == selection[3].strip(): data = sharedata self.session.openWithCallback(self.MountEditClosed,AutoMountEdit, self.skin_path, data)
def _buildNetworkShareEntry(self, share): verticallineIcon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/verticalLine.png")) if share.type == NetworkItem.TYPE_NFS: newpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/i-nfs.png")) else: newpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/i-smb.png")) isMounted = False mounts = iAutoMount.getMounts() for sharename, sharedata in mounts.items(): if sharedata['ip'] == share.host: if share.type == NetworkItem.TYPE_NFS and sharedata['mounttype'] == 'nfs': if share.path == sharedata['sharedir'] and sharedata["isMounted"]: isMounted = True elif share.type == NetworkItem.TYPE_SMB and sharedata['mounttype'] == 'cifs': if share.path == sharedata['sharedir'] and sharedata["isMounted"]: isMounted = True if isMounted: isMountedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/ok.png")) else: isMountedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/cancel.png")) return (share, verticallineIcon, None, share.path, share.comment, newpng, isMountedpng)
def __init__(self, session, plugin_path, mountinfo = None ): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) ConfigListScreen.__init__(self, [],session = session) self.mountinfo = mountinfo if self.mountinfo is None: #Initialize default mount data (using nfs default options) self.mountinfo = iAutoMount.DEFAULT_OPTIONS_NFS self._applyConfigMsgBox = None self.updateConfigRef = None self.mounts = iAutoMount.getMounts() 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.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Pixmap() self["HelpWindow"] = Pixmap() self["introduction"] = StaticText(_("Press OK to activate the settings.")) self["key_red"] = StaticText(_("Cancel"))
def __init__(self, session, plugin_path, mountinfo=None): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) ConfigListScreen.__init__(self, [], session=session) self.mountinfo = mountinfo if self.mountinfo is None: #Initialize default mount data (using nfs default options) self.mountinfo = iAutoMount.DEFAULT_OPTIONS_NFS self._applyConfigMsgBox = None self.updateConfigRef = None self.mounts = iAutoMount.getMounts() 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.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Pixmap() self["HelpWindow"] = Pixmap() self["introduction"] = StaticText( _("Press OK to activate the settings.")) self["key_red"] = StaticText(_("Cancel"))