def loadTimer(self):
try:
file = open(self.Filename, 'r')
doc = xml.etree.cElementTree.parse(file)
file.close()
except SyntaxError:
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 "[RecordTimer] timers.xml failed to load!"
try:
os.rename(self.Filename, self.Filename + "_old")
except (IOError, OSError):
print "[RecordTimer] renaming broken timer failed"
return
except IOError:
print "[RecordTimer] timers.xml not found!"
return
root = doc.getroot()
# put out a message when at least one timer overlaps
checkit = False
timer_text = ""
for timer in root.findall("timer"):
newTimer = createTimer(timer)
conflict_list = self.record(newTimer, ignoreTSC=True, dosave=False, loadtimer=True)
if conflict_list:
checkit = True
if newTimer in conflict_list:
timer_text += _("\nTimer '%s' disabled!") % newTimer.name
if checkit:
from Tools.Notifications import AddPopup
from Screens.MessageBox import MessageBox
AddPopup(_("Timer overlap in timers.xml detected!\nPlease recheck it!") + timer_text, type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed")
评论列表
文章目录