PowerTimer.py 文件源码

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

项目:enigma2 作者: OpenLD 项目源码 文件源码
def loadTimer(self):
        # TODO: PATH!
        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 (pm_timers.xml) is corrupt and could not be loaded."), type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed")

            print "pm_timers.xml failed to load!"
            try:
                import os
                os.rename(self.Filename, self.Filename + "_old")
            except (IOError, OSError):
                print "renaming broken timer failed"
            return
        except IOError:
            print "pm_timers.xml not found!"
            return

        root = doc.getroot()

        # put out a message when at least one timer overlaps
        checkit = True
        for timer in root.findall("timer"):
            newTimer = createTimer(timer)
            if (self.record(newTimer, True, dosave=False) is not None) and (checkit == True):
                from Tools.Notifications import AddPopup
                from Screens.MessageBox import MessageBox
                AddPopup(_("Timer overlap in pm_timers.xml detected!\nPlease recheck it!"), type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed")
                checkit = False # at moment it is enough when the message is displayed one time
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号