From c634af0fecbf66c7e0187b49e54f6501fb2e88b0 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Tue, 12 Feb 2008 22:16:58 +0000 Subject: [PATCH] handle broken timers.xml gracefully --- RecordTimer.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/RecordTimer.py b/RecordTimer.py index de4f6cc1..cf900170 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)) -- 2.30.2