def readXml(self): # 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 file = open(XML_CONFIG, 'r') configuration = cet_parse(file).getroot() file.close() # 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): # 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 readXml(self, **kwargs): if "xml_string" in kwargs: # reset time self.configMtime = -1 # Parse Config configuration = cet_fromstring(kwargs["xml_string"]) else: # 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 readXml(self): # 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 readXmlTimer(self, xml_string): # Parse xml string configuration = cet_fromstring(xml_string) parseConfig(configuration, self.timers, configuration.get("version"), self.getUniqueId(), self.defaultTimer) # reset time self.configMtime = -1
def readXmlTimer(self, xml_string): # Parse xml string configuration = cet_fromstring(xml_string) parseConfig( configuration, self.timers, configuration.get("version"), self.uniqueTimerId, self.defaultTimer ) self.uniqueTimerId += 1 # reset time self.configMtime = -1
def readXmlTimer(self, xml_string): # Parse xml string try: configuration = cet_fromstring(xml_string) except: doLog("[AutoTimer] fatal error, the xml_string not read") return parseConfig( configuration, self.timers, configuration.get("version"), self.uniqueTimerId, self.defaultTimer ) self.uniqueTimerId += 1 # reset time self.configMtime = -1
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 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)