From: Felix Domke Date: Tue, 12 Feb 2008 22:16:58 +0000 (+0000) Subject: handle broken timers.xml gracefully X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=commitdiff_plain;h=c634af0fecbf66c7e0187b49e54f6501fb2e88b0 handle broken timers.xml gracefully --- diff --git a/RecordTimer.py b/RecordTimer.py index de4f6cc..cf90017 100644 --- a/RecordTimer.py +++ b/RecordTimer.py @@ -393,8 +393,22 @@ class RecordTimer(timer.Timer): def loadTimer(self): # TODO: PATH! - doc = xml.dom.minidom.parse(self.Filename) - + try: + doc = xml.dom.minidom.parse(self.Filename) + except xml.parsers.expat.ExpatError: + from Tools.Notifications import AddPopup + from Screens.MessageBox import MessageBox + + AddPopup(_("The timer file (timers.xml) is corrupt and could not be loaded."), type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed") + + print "timers.xml failed to load!" + try: + import os + os.rename(self.Filename, self.Filename + "_old") + except IOError: + print "renaming broken timer failed" + return + root = doc.childNodes[0] for timer in elementsWithTag(root.childNodes, "timer"): self.record(createTimer(timer))