def load(self): if not fileExists(XML_CONFIG): return try: config = cet_parse(XML_CONFIG).getroot() except ParseError as pe: from time import time print("[PluginSort] Parse Error occured in configuration, backing it up and starting from scratch!") try: copyfile(XML_CONFIG, "/etc/enigma2/pluginsort.xml.%d" % (int(time()),)) except Error as she: print("[PluginSort] Uh oh, failed to create the backup... I hope you have one anyway :D") return for wheresection in config.findall('where'): where = wheresection.get('type') whereid = WHEREMAP.get(where, None) whereplugins = wheresection.findall('plugin') if whereid is None or not whereplugins: print("[PluginSort] Ignoring section %s because of invalid id (%s) or no plugins (%s)" % (where, repr(whereid), repr(whereplugins))) continue for plugin in whereplugins: name = plugin.get('name') try: weight = int(plugin.get('weight')) except ValueError as ve: print("[PluginSort] Invalid weight of %s received for plugin %s, ignoring" % (repr(plugin.get('weight')), repr(name))) else: self.plugins.setdefault(whereid, {})[name] = weight
def read_timers(self): configuration = cet_parse(self.__timer_filename).getroot() timers = [] for timer in configuration.findall("timer"): timers.append(timer.attrib) return timers
def update(self, suggestions): if suggestions and len(suggestions) > 0: if not self.shown: self.show() suggestions_tree = cet_parse(StringIO(suggestions)).getroot() if suggestions_tree: self.list = [] self.suggestlist = [] for suggestion in suggestions_tree.findall("CompleteSuggestion"): name = None numresults = None for subelement in suggestion: if subelement.attrib.has_key('data'): name = subelement.attrib['data'].encode("UTF-8") if subelement.attrib.has_key('int'): numresults = subelement.attrib['int'] if name and numresults: self.suggestlist.append((name, numresults )) if len(self.suggestlist): self.suggestlist.sort(key=lambda x: int(x[1])) self.suggestlist.reverse() for entry in self.suggestlist: self.list.append((entry[0], entry[1] + _(" Results") )) self["suggestionslist"].setList(self.list) self["suggestionslist"].setIndex(0) else: self.hide()
def readConfiguration(self): if not path.exists(CONFIG): return mtime = path.getmtime(CONFIG) if mtime == self.configMtime: return self.configMtime = mtime self.services[0].clear() self.services[1].clear() configuration = cet_parse(CONFIG).getroot() version = configuration.get("version", None) if version is None: factor = 60 else: factor = 1 for service in configuration.findall("service"): value = service.text if value: pos = value.rfind(':') # don't split alternative service if pos != -1 and not value.startswith('1:134:'): value = value[:pos+1] duration = service.get('duration', None) duration = duration and int(duration)*factor self.services[0].add(EPGRefreshService(value, duration)) for bouquet in configuration.findall("bouquet"): value = bouquet.text if value: duration = bouquet.get('duration', None) duration = duration and int(duration) self.services[1].add(EPGRefreshService(value, duration))
def load(self): if not fileExists(XML_CONFIG): return try: config = cet_parse(XML_CONFIG).getroot() except ParseError as pe: from time import time print("[MenuSort] Parse Error occured in configuration, backing it up and starting from scratch!") try: copyfile(XML_CONFIG, "/etc/enigma2/menusort.xml.%d" % (int(time()),)) except Error as she: print("[MenuSort] Uh oh, failed to create the backup... I hope you have one anyway :D") return for node in config.findall('entry'): text = node.get('text', '').encode("UTF-8") weight = node.get("weight", None) hidden = node.get('hidden', False) hidden = hidden and hidden.lower() == "yes" try: weight = int(weight) except ValueError as ve: print("[MenuSort] Invalid value for weight on entry %s: %s" % (repr(text), repr(weight))) continue if not text or weight is None: print("[MenuSort] Invalid entry in xml (%s, %s), ignoring" % (repr(text), repr(weight))) continue self.weights[text] = (weight, hidden)
def readXml(self): # Abort if no config found if not os_path.exists(XML_CONFIG): doLog("No configuration file present") return # Parse if mtime differs from whats saved mtime = os_path.getmtime(XML_CONFIG) if mtime == self.configMtime: doLog("No changes in configuration, won't parse") return # Save current mtime self.configMtime = mtime # Parse Config configuration = cet_parse(XML_CONFIG).getroot() # Empty out timers and reset Ids del self.timers[:] self.defaultTimer.clear(-1, True) parseConfig( configuration, self.timers, configuration.get("version"), 0, self.defaultTimer ) self.uniqueTimerId = len(self.timers)
def getRemotePCPoints(self): self.remotepc = {} if not os_path.exists(XML_PCTAB): self.setDummyRecord() self.writePCsConfig() tree = cet_parse(XML_PCTAB).getroot() def getValue(definitions, default): ret = "" # How many definitions are present Len = len(definitions) return Len > 0 and definitions[Len-1].text or default # Config is stored in "host" element, read out PC for pc in tree.findall("host"): data = { 'name': False, 'ip': False, 'mac': False, 'system': False, 'user': False, 'passwd': False, 'bqdn': False } try: data['name'] = getValue(pc.findall("name"), _("PC")).encode("UTF-8") data['ip'] = getValue(pc.findall("ip"), "192.168.1.0").encode("UTF-8") data['mac'] = getValue(pc.findall("mac"), "00:00:00:00:00:00").encode("UTF-8") data['system'] = getValue(pc.findall("system"), "0").encode("UTF-8") data['user'] = getValue(pc.findall("user"), "administrator").encode("UTF-8") data['passwd'] = getValue(pc.findall("passwd"), "password").encode("UTF-8") data['bqdn'] = getValue(pc.findall("bqdn"), "0").encode("UTF-8") self.remotepc[data['name']] = data except Exception, e: print "[xpower] Error reading remotepc:", e
def load(self): if not fileExists(XML_CONFIG): return try: config = cet_parse(XML_CONFIG).getroot() except ParseError, pe: from time import time print "[MenuSort] Parse Error occured in configuration, backing it up and starting from scratch!" try: copyfile(XML_CONFIG, "/etc/enigma2/menusort.xml.%d" % (int(time()),)) except Error, she: print "[MenuSort] Uh oh, failed to create the backup... I hope you have one anyway :D"
def __parse(self, file): print "[Bonjour.__parse] parsing %s%s" %(self.AVAHI_SERVICES_DIR, file) config = cet_parse(self.AVAHI_SERVICES_DIR + file).getroot() name = config.find('name').text service = config.find('service') type = service.find('type').text port = service.find('port').text text = service.findall('txt-record') textList = [] if text != None: for txt in text: textList.append(txt.text) print textList service = self.buildServiceFull(file, name, type, port, textList) self.registerService(service)
def __parse(self, file): print "[Bonjour.__parse] parsing %s%s" %(self.AVAHI_SERVICES_DIR, file) config = cet_parse(self.AVAHI_SERVICES_DIR + file).getroot() name = config.find('name').text service = config.find('service') type = service.find('type').text port = service.find('port').text text = service.get('text-record') if text is None: text = "" else: text = text.text service = self.buildServiceFull(file, name, type, port, text) self.registerService(service)
def readConfiguration(self): # Check if file exists if not path.exists(CONFIG): return # Check if file did not change mtime = path.getmtime(CONFIG) if mtime == self.configMtime: return # Keep mtime self.configMtime = mtime # Empty out list self.services[0].clear() self.services[1].clear() # Open file configuration = cet_parse(CONFIG).getroot() version = configuration.get("version", None) if version is None: factor = 60 else: #if version == "1" factor = 1 # Add References for service in configuration.findall("service"): value = service.text if value: # strip all after last : (custom name) pos = value.rfind(':') # don't split alternative service if pos != -1 and not value.startswith('1:134:'): value = value[:pos+1] duration = service.get('duration', None) duration = duration and int(duration)*factor self.services[0].add(EPGRefreshService(value, duration)) for bouquet in configuration.findall("bouquet"): value = bouquet.text if value: duration = bouquet.get('duration', None) duration = duration and int(duration) self.services[1].add(EPGRefreshService(value, duration))
def reload(self, callback=None): Log.i() # Initialize mounts to empty list self._mounts = {} self._numActive = 0 if not pathExists(XML_FSTAB): return tree = cet_parse(XML_FSTAB).getroot() self._parse(tree, ['nfs', 'cifs'], [AutoMount.DEFAULT_OPTIONS_NFS, AutoMount.DEFAULT_OPTIONS_CIFS]) if len(self._mounts): for sharename, sharedata in self._mounts.items(): self._applyShare(sharedata, callback) self._reloadSystemd(callback=self._onSharesApplied) else: Log.i("self._mounts without mounts %s" %(self._mounts,)) if callback is not None: callback(True)
def __parse(self, file): print "[Bonjour.__parse] parsing %s%s" %(self.AVAHI_SERVICES_DIR, file) try: config = cet_parse(self.AVAHI_SERVICES_DIR + file).getroot() except ParseError: #parsing failed, skip the file return name = config.find('name').text service = config.find('service') type = service.find('type').text port = service.find('port').text text = service.findall('txt-record') textList = [] if text is not None: for txt in text: textList.append(txt.text) service = self.buildServiceFull(file, name, type, port, textList) self.registerService(service)
def readXml(self): # Abort if no config found if not os.path.exists(XML_CONFIG): doLog("[AutoTimer] No configuration file present") return # Parse if mtime differs from whats saved mtime = os.path.getmtime(XML_CONFIG) if mtime == self.configMtime: doLog("[AutoTimer] No changes in configuration, won't parse") return # Save current mtime self.configMtime = mtime # Parse Config try: configuration = cet_parse(XML_CONFIG).getroot() except: try: os.rename(XML_CONFIG, XML_CONFIG + "_old") doLog("[AutoTimer] autotimer.xml is corrupt rename file to /etc/enigma2/autotimer.xml_old") except: pass if Standby.inStandby is None: AddPopup(_("The autotimer file (/etc/enigma2/autotimer.xml) is corrupt and could not be loaded."), type = MessageBox.TYPE_ERROR, timeout = 0, id = "AutoTimerLoadFailed") return # Empty out timers and reset Ids del self.timers[:] self.defaultTimer.clear(-1, True) parseConfig( configuration, self.timers, configuration.get("version"), 0, self.defaultTimer ) self.uniqueTimerId = len(self.timers)
def readConfiguration(self): # Check if file exists if not path.exists(CONFIG): return # Check if file did not change mtime = path.getmtime(CONFIG) if mtime == self.configMtime: return # Keep mtime self.configMtime = mtime # Empty out list self.services[0].clear() self.services[1].clear() # Open file configuration= cet_parse(CONFIG).getroot() # Add References for service in configuration.findall("service"): value = service.text if value: # strip all after last : (custom name) pos = value.rfind(':') if pos != -1: value = value[:pos+1] duration = service.get('duration', None) duration = duration and int(duration) self.services[0].add(EPGRefreshService(value, duration)) for bouquet in configuration.findall("bouquet"): value = bouquet.text if value: duration = bouquet.get('duration', None) duration = duration and int(duration) self.services[1].add(EPGRefreshService(value, duration))
def getWebTVStations(self, callback=None): self.webtv_stations = {} if not exists(WEBTV_STATIONS): return tree = cet_parse(WEBTV_STATIONS).getroot() def getValue(definitions, default): Len = len(definitions) return Len > 0 and definitions[Len-1].text or default for tvstation in tree.findall("tvstation"): data = { 'provider': None, 'title': None, 'streamurl': None } try: data['provider'] = getValue(tvstation.findall("provider"), False).encode("UTF-8") data['title'] = getValue(tvstation.findall("title"), False).encode("UTF-8") data['streamurl'] = getValue(tvstation.findall("streamurl"), False).encode("UTF-8") print "TVSTATION--->",data self.webtv_stations[data['title']] = data except Exception, e: print "[WebTVStations] Error reading Stations:", e
def getAutoMountPoints(self, callback = None): automounts = [] self.automounts = {} self.activeMountsCounter = 0 if not os.path.exists(XML_FSTAB): return file = open(XML_FSTAB, 'r') tree = cet_parse(file).getroot() file.close() def getValue(definitions, default): ret = '' Len = len(definitions) return Len > 0 and definitions[(Len - 1)].text or default mountusing = 0 for fstab in tree.findall('fstab'): mountusing = 1 for nfs in fstab.findall('nfs'): for mount in nfs.findall('mount'): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = 'fstab'.encode('UTF-8') data['mounttype'] = 'nfs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data['active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue(mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue(mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue(mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue(mount.findall('options'), 'rw,nolock,tcp,utf8').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', print e for cifs in fstab.findall('cifs'): for mount in cifs.findall('mount'): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = 'fstab'.encode('UTF-8') data['mounttype'] = 'cifs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data['active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue(mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue(mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue(mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue(mount.findall('options'), 'rw,utf8').encode('UTF-8') data['username'] = getValue(mount.findall('username'), 'guest').encode('UTF-8') data['password'] = getValue(mount.findall('password'), '').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', print e for enigma2 in tree.findall('enigma2'): mountusing = 2 for nfs in enigma2.findall('nfs'): for mount in nfs.findall('mount'): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = 'enigma2'.encode('UTF-8') data['mounttype'] = 'nfs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data['active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue(mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue(mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue(mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue(mount.findall('options'), 'rw,nolock,tcp,utf8').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', print e for cifs in enigma2.findall('cifs'): for mount in cifs.findall('mount'): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = 'enigma2'.encode('UTF-8') data['mounttype'] = 'cifs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data['active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue(mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue(mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue(mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue(mount.findall('options'), 'rw,utf8').encode('UTF-8') data['username'] = getValue(mount.findall('username'), 'guest').encode('UTF-8') data['password'] = getValue(mount.findall('password'), '').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', print e if mountusing == 0: for nfs in tree.findall('nfs'): for mount in nfs.findall('mount'): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = 'old_enigma2'.encode('UTF-8') data['mounttype'] = 'nfs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data['active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue(mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue(mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue(mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue(mount.findall('options'), 'rw,nolock,tcp,utf8').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', print e for cifs in tree.findall('cifs'): for mount in cifs.findall('mount'): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = 'old_enigma2'.encode('UTF-8') data['mounttype'] = 'cifs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data['active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue(mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue(mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue(mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue(mount.findall('options'), 'rw,utf8').encode('UTF-8') data['username'] = getValue(mount.findall('username'), 'guest').encode('UTF-8') data['password'] = getValue(mount.findall('password'), '').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', print e self.checkList = self.automounts.keys() if not self.checkList: print '[NetworkBrowser] self.automounts without mounts', print self.automounts if callback is not None: callback(True) else: self.CheckMountPoint(self.checkList.pop(), callback)
def __init__(self, filename): # this may raise an exception, it is up to the caller to handle that self.__dom = cet_parse(filename).getroot()
def getAutoMountPoints(self, callback=None): # Initialize mounts to empty list automounts = [] self.automounts = {} self.activeMountsCounter = 0 if not os.path.exists(XML_FSTAB): return try: tree = cet_parse(XML_FSTAB).getroot() except Exception as e: print("[MountManager] Error reading /etc/enigma2/automounts.xml:", e) try: os.remove(XML_FSTAB) except Exception as e: print( "[MountManager] Error delete corrupt /etc/enigma2/automounts.xml:", e) return def getValue(definitions, default): # Initialize Output ret = "" # How many definitions are present Len = len(definitions) return Len > 0 and definitions[Len - 1].text or default # Config is stored in "mountmanager" element # Read out NFS Mounts for nfs in tree.findall("nfs"): for mount in nfs.findall("mount"): data = { 'isMounted': False, 'active': False, 'ip': False, 'host': False, 'sharename': False, 'sharedir': False, 'username': False, \ 'password': False, 'mounttype' : False, 'options' : False, 'hdd_replacement' : False } try: data['mounttype'] = 'nfs'.encode("UTF-8") data['active'] = getValue(mount.findall("active"), False).encode("UTF-8") if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall("hdd_replacement"), "False").encode("UTF-8") data['ip'] = getValue(mount.findall("ip"), "").encode("UTF-8") data['host'] = getValue(mount.findall("host"), "").encode("UTF-8") data['sharedir'] = getValue(mount.findall("sharedir"), "/media/").encode("UTF-8") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA").encode("UTF-8") data['options'] = getValue(mount.findall("options"), "").encode("UTF-8") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) # Read out CIFS Mounts for nfs in tree.findall("cifs"): for mount in nfs.findall("mount"): data = { 'isMounted': False, 'active': False, 'ip': False, 'host': False, 'sharename': False, 'sharedir': False, 'username': False, \ 'password': False, 'mounttype' : False, 'options' : False, 'hdd_replacement' : False } try: data['mounttype'] = 'cifs'.encode("UTF-8") data['active'] = getValue(mount.findall("active"), False).encode("UTF-8") if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall("hdd_replacement"), "False").encode("UTF-8") data['ip'] = getValue(mount.findall("ip"), "").encode("UTF-8") data['host'] = getValue(mount.findall("host"), "").encode("UTF-8") data['sharedir'] = getValue(mount.findall("sharedir"), "/media/").encode("UTF-8") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA").encode("UTF-8") data['options'] = getValue(mount.findall("options"), "").encode("UTF-8") data['username'] = getValue(mount.findall("username"), "guest").encode("UTF-8") data['password'] = getValue(mount.findall("password"), "").encode("UTF-8") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) self.checkList = self.automounts.keys() if not self.checkList: print("[AutoMount.py] self.automounts without mounts", self.automounts) if callback is not None: callback(True) else: self.CheckMountPoint(self.checkList.pop(), callback)
def getAutoMountPoints(self, callback=None): # Initialize mounts to empty list automounts = [] self.automounts = {} self.activeMountsCounter = 0 if not os.path.exists(XML_FSTAB): return tree = cet_parse(XML_FSTAB).getroot() def enc(val): if six.PY2: return val.encode("UTF-8") return val def getValue(definitions, default): # Initialize Output ret = "" # How many definitions are present Len = len(definitions) if six.PY2: return Len > 0 and definitions[Len - 1].text.encode( "UTF-8") or default.encode("UTF-8") else: return Len > 0 and definitions[Len - 1].text or default # Config is stored in "mountmanager" element # Read out NFS Mounts for nfs in tree.findall("nfs"): for mount in nfs.findall("mount"): data = { 'isMounted': False, 'active': False, 'ip': False, 'host': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mounttype'] = enc('nfs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['host'] = getValue(mount.findall("host"), "") data['sharedir'] = getValue(mount.findall("sharedir"), "/exports/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,nolock,tcp,utf8") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) # Read out CIFS Mounts for nfs in tree.findall("cifs"): for mount in nfs.findall("mount"): data = { 'isMounted': False, 'active': False, 'ip': False, 'host': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mounttype'] = enc('cifs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall("hdd_replacement"), 'False') data['ip'] = getValue(mount.findall("ip"), '') data['host'] = getValue(mount.findall("host"), '') data['sharedir'] = getValue(mount.findall("sharedir"), '/media/') data['sharename'] = getValue(mount.findall("sharename"), 'MEDIA') data['options'] = getValue(mount.findall("options"), "") data['username'] = getValue(mount.findall("username"), 'guest') data['password'] = getValue(mount.findall("password"), 'guest') self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) self.checkList = list(self.automounts.keys()) if not self.checkList: print("[AutoMount.py] self.automounts without mounts", self.automounts) if callback is not None: callback(True) else: self.CheckMountPoint(self.checkList.pop(), callback)
def getAutoMountPoints(self, callback=None, restart=False): automounts = [] self.automounts = {} self.activeMountsCounter = 0 if not os.path.exists(XML_FSTAB): return else: file = open(XML_FSTAB, 'r') tree = cet_parse(file).getroot() file.close() def getValue(definitions, default): ret = '' Len = len(definitions) return Len > 0 and definitions[Len - 1].text or default mountusing = 0 for autofs in tree.findall('autofs'): mountusing = 1 for nfs in autofs.findall('nfs'): for mount in nfs.findall('mount'): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mountusing'] = 'autofs'.encode('UTF-8') data['mounttype'] = 'nfs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data[ 'active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue( mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue( mount.findall('sharedir'), '/media/hdd/').encode('UTF-8') data['sharename'] = getValue( mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue( mount.findall('options'), 'rw,nolock,tcp,utf8').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', e for cifs in autofs.findall('cifs'): for mount in cifs.findall('mount'): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mountusing'] = 'autofs'.encode('UTF-8') data['mounttype'] = 'cifs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data[ 'active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue( mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue( mount.findall('sharedir'), '/media/hdd/').encode('UTF-8') data['sharename'] = getValue( mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue( mount.findall('options'), 'rw,utf8').encode('UTF-8') data['username'] = getValue( mount.findall('username'), 'guest').encode('UTF-8') data['password'] = getValue( mount.findall('password'), '').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', e for fstab in tree.findall('fstab'): mountusing = 2 for nfs in fstab.findall('nfs'): for mount in nfs.findall('mount'): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mountusing'] = 'fstab'.encode('UTF-8') data['mounttype'] = 'nfs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data[ 'active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue( mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue( mount.findall('sharedir'), '/media/hdd/').encode('UTF-8') data['sharename'] = getValue( mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue( mount.findall('options'), 'rw,nolock,tcp,utf8').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', e for cifs in fstab.findall('cifs'): for mount in cifs.findall('mount'): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mountusing'] = 'fstab'.encode('UTF-8') data['mounttype'] = 'cifs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data[ 'active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue( mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue( mount.findall('sharedir'), '/media/hdd/').encode('UTF-8') data['sharename'] = getValue( mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue( mount.findall('options'), 'rw,utf8').encode('UTF-8') data['username'] = getValue( mount.findall('username'), 'guest').encode('UTF-8') data['password'] = getValue( mount.findall('password'), '').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', e for enigma2 in tree.findall('enigma2'): mountusing = 3 for nfs in enigma2.findall('nfs'): for mount in nfs.findall('mount'): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mountusing'] = 'enigma2'.encode('UTF-8') data['mounttype'] = 'nfs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data[ 'active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue( mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue( mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue( mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue( mount.findall('options'), 'rw,nolock,tcp,utf8').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', e for cifs in enigma2.findall('cifs'): for mount in cifs.findall('mount'): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mountusing'] = 'enigma2'.encode('UTF-8') data['mounttype'] = 'cifs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data[ 'active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue( mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue( mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue( mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue( mount.findall('options'), 'rw,utf8').encode('UTF-8') data['username'] = getValue( mount.findall('username'), 'guest').encode('UTF-8') data['password'] = getValue( mount.findall('password'), '').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', e if mountusing == 0: for nfs in tree.findall('nfs'): for mount in nfs.findall('mount'): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mountusing'] = 'old_enigma2'.encode('UTF-8') data['mounttype'] = 'nfs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data[ 'active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue( mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue( mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue( mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue( mount.findall('options'), 'rw,nolock,tcp,utf8').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', e for cifs in tree.findall('cifs'): for mount in cifs.findall('mount'): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } try: data['mountusing'] = 'old_enigma2'.encode('UTF-8') data['mounttype'] = 'cifs'.encode('UTF-8') data['active'] = getValue(mount.findall('active'), False).encode('UTF-8') if data['active'] == 'True' or data[ 'active'] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue( mount.findall('hdd_replacement'), 'False').encode('UTF-8') data['ip'] = getValue( mount.findall('ip'), '192.168.0.0').encode('UTF-8') data['sharedir'] = getValue( mount.findall('sharedir'), '/exports/').encode('UTF-8') data['sharename'] = getValue( mount.findall('sharename'), 'MEDIA').encode('UTF-8') data['options'] = getValue( mount.findall('options'), 'rw,utf8').encode('UTF-8') data['username'] = getValue( mount.findall('username'), 'guest').encode('UTF-8') data['password'] = getValue( mount.findall('password'), '').encode('UTF-8') self.automounts[data['sharename']] = data except Exception as e: print '[MountManager] Error reading Mounts:', e self.checkList = self.automounts.keys() if not self.checkList: if callback is not None: callback(True) else: self.CheckMountPoint(self.checkList.pop(), callback, restart) return
def readXml(self, **kwargs): if "xml_string" in kwargs: # reset time self.configMtime = -1 # Parse Config configuration = cet_fromstring(kwargs["xml_string"]) # TODO : check config and create backup if wrong else: # Abort if no config found if not os_path.exists(XML_CONFIG): print("[AutoTimer] No configuration file present") return # Parse if mtime differs from whats saved mtime = os_path.getmtime(XML_CONFIG) if mtime == self.configMtime: print("[AutoTimer] No changes in configuration, won't parse") return # Save current mtime self.configMtime = mtime # Parse Config try: configuration = cet_parse(XML_CONFIG).getroot() except: try: if os_path.exists(XML_CONFIG + "_old"): os_rename(XML_CONFIG + "_old", XML_CONFIG + "_old(1)") os_rename(XML_CONFIG, XML_CONFIG + "_old") print("[AutoTimer] autotimer.xml is corrupt rename file to /etc/enigma2/autotimer.xml_old") except: pass if Standby.inStandby is None: AddPopup(_("The autotimer file (/etc/enigma2/autotimer.xml) is corrupt. A new and empty config was created. A backup of the config can be found here (/etc/enigma2/autotimer.xml_old) "), type = MessageBox.TYPE_ERROR, timeout = 0, id = "AutoTimerLoadFailed") self.timers = [] self.defaultTimer = preferredAutoTimerComponent( 0, # Id "", # Name "", # Match True # Enabled ) try: self.writeXml() configuration = cet_parse(XML_CONFIG).getroot() except: print("[AutoTimer] fatal error, the autotimer.xml cannot create") return # Empty out timers and reset Ids del self.timers[:] self.defaultTimer.clear(-1, True) parseConfig( configuration, self.timers, configuration.get("version"), 0, self.defaultTimer ) self.uniqueTimerId = len(self.timers)
def readXml(self, **kwargs): if "xml_string" in kwargs: # reset time self.configMtime = -1 # Parse Config configuration = cet_fromstring(kwargs["xml_string"]) # TODO : check config and create backup if wrong else: # Abort if no config found if not os_path.exists(XML_CONFIG): print("[AutoTimer] No configuration file present") return # Parse if mtime differs from whats saved mtime = os_path.getmtime(XML_CONFIG) if mtime == self.configMtime: print("[AutoTimer] No changes in configuration, won't parse") return # Save current mtime self.configMtime = mtime # Parse Config try: configuration = cet_parse(XML_CONFIG).getroot() except: try: if os_path.exists(XML_CONFIG + "_old"): os_rename(XML_CONFIG + "_old", XML_CONFIG + "_old(1)") os_rename(XML_CONFIG, XML_CONFIG + "_old") print( "[AutoTimer] autotimer.xml is corrupt rename file to /etc/enigma2/autotimer.xml_old" ) except: pass if Standby.inStandby is None: AddPopup(_( "The autotimer file (/etc/enigma2/autotimer.xml) is corrupt. A new and empty config was created. A backup of the config can be found here (/etc/enigma2/autotimer.xml_old) " ), type=MessageBox.TYPE_ERROR, timeout=0, id="AutoTimerLoadFailed") self.timers = [] self.defaultTimer = preferredAutoTimerComponent( 0, # Id "", # Name "", # Match True # Enabled ) try: self.writeXml() configuration = cet_parse(XML_CONFIG).getroot() except: print( "[AutoTimer] fatal error, the autotimer.xml cannot create" ) return # Empty out timers and reset Ids del self.timers[:] self.defaultTimer.clear(-1, True) parseConfig(configuration, self.timers, configuration.get("version"), 0, self.defaultTimer) self.nextTimerId = int(configuration.get("nextTimerId", "0")) if not self.nextTimerId: self.nextTimerId = len(self.timers) + 1
def getAutoMountPoints(self, callback=None, restart=False): # Initialize mounts to empty list automounts = [] self.automounts = {} self.activeMountsCounter = 0 if not os.path.exists(XML_FSTAB): return file = open(XML_FSTAB, 'r') tree = cet_parse(file).getroot() file.close() def enc(val): if six.PY2: return val.encode("UTF-8") return val def getValue(definitions, default): # Initialize Output ret = "" # How many definitions are present Len = len(definitions) if six.PY2: return Len > 0 and definitions[Len - 1].text.encode("UTF-8") or default.encode("UTF-8") else: return Len > 0 and definitions[Len - 1].text or default mountusing = 0 # 0=old_enigma2, 1 =fstab, 2=enigma2 # Config is stored in "mountmanager" element # Read out NFS Mounts for autofs in tree.findall("autofs"): mountusing = 1 for nfs in autofs.findall("nfs"): for mount in nfs.findall("mount"): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = enc('autofs') data['mounttype'] = enc('nfs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['sharedir'] = getValue(mount.findall("sharedir"), "/media/hdd/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,nolock,tcp,utf8") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) for cifs in autofs.findall("cifs"): for mount in cifs.findall("mount"): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = enc('autofs') data['mounttype'] = enc('cifs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['sharedir'] = getValue(mount.findall("sharedir"), "/media/hdd/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,utf8") data['username'] = getValue(mount.findall("username"), "guest") data['password'] = getValue(mount.findall("password"), "") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) for fstab in tree.findall("fstab"): mountusing = 2 for nfs in fstab.findall("nfs"): for mount in nfs.findall("mount"): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = enc('fstab') data['mounttype'] = enc('nfs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['sharedir'] = getValue(mount.findall("sharedir"), "/media/hdd/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,nolock,tcp,utf8") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) for cifs in fstab.findall("cifs"): for mount in cifs.findall("mount"): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = enc('fstab') data['mounttype'] = enc('cifs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['sharedir'] = getValue(mount.findall("sharedir"), "/media/hdd/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,utf8") data['username'] = getValue(mount.findall("username"), "guest") data['password'] = getValue(mount.findall("password"), "") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) for enigma2 in tree.findall("enigma2"): mountusing = 3 for nfs in enigma2.findall("nfs"): for mount in nfs.findall("mount"): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = enc('enigma2') data['mounttype'] = enc('nfs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['sharedir'] = getValue(mount.findall("sharedir"), "/exports/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,nolock,tcp,utf8") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) # Read out CIFS Mounts for cifs in enigma2.findall("cifs"): for mount in cifs.findall("mount"): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = enc('enigma2') data['mounttype'] = enc('cifs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['sharedir'] = getValue(mount.findall("sharedir"), "/exports/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,utf8") data['username'] = getValue(mount.findall("username"), "guest") data['password'] = getValue(mount.findall("password"), "") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) if mountusing == 0: for nfs in tree.findall("nfs"): for mount in nfs.findall("mount"): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = enc('old_enigma2') data['mounttype'] = enc('nfs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['sharedir'] = getValue(mount.findall("sharedir"), "/exports/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,nolock,tcp,utf8") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) for cifs in tree.findall("cifs"): for mount in cifs.findall("mount"): data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} try: data['mountusing'] = enc('old_enigma2') data['mounttype'] = enc('cifs') data['active'] = getValue(mount.findall("active"), False) if data["active"] == 'True' or data["active"] == True: self.activeMountsCounter += 1 data['hdd_replacement'] = getValue(mount.findall("hdd_replacement"), "False") data['ip'] = getValue(mount.findall("ip"), "192.168.0.0") data['sharedir'] = getValue(mount.findall("sharedir"), "/exports/") data['sharename'] = getValue(mount.findall("sharename"), "MEDIA") data['options'] = getValue(mount.findall("options"), "rw,utf8") data['username'] = getValue(mount.findall("username"), "guest") data['password'] = getValue(mount.findall("password"), "") self.automounts[data['sharename']] = data except Exception as e: print("[MountManager] Error reading Mounts:", e) self.checkList = list(self.automounts.keys()) if not self.checkList: # print "[NetworkBrowser] self.automounts without mounts",self.automounts if callback is not None: callback(True) else: self.CheckMountPoint(self.checkList.pop(), callback, restart)