RecordTimer.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:enigma2 作者: OpenLD 项目源码 文件源码
def loadTimer(self):
        if not Directories.fileExists(self.Filename):
            return
        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 "timers.xml failed to load!"
            try:
                os.rename(self.Filename, self.Filename + "_old")
            except (IOError, OSError):
                print "renaming broken timer failed"
            return
        except IOError:
            print "timers.xml not found!"
            return

        root = doc.getroot()

        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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号