Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from enigma import eTimer
- from Components.config import config
- from Components.Console import Console
- from enigma import eTimer, eDVBLocalTimeHandler, eEPGCache
- try:
- from Tools.StbHardware import setRTCtime
- except:
- from Tools.DreamboxHardware import setRTCtime
- from time import time
- class NTPSyncPoller:
- """Automatically Poll NTP"""
- run_num = 0
- def __init__(self):
- NTPSyncPoller.run_num += 1
- self.timer = eTimer()
- self.Console = Console()
- def start(self):
- if not self.timer.callback:
- self.timer.callback.append(self.NTPStart)
- self.timer.startLongTimer(0)
- def stop(self):
- if self.timer.callback:
- self.timer.callback.remove(self.NTPStart)
- self.timer.stop()
- def NTPStart(self):
- if (NTPSyncPoller.run_num == "1" or NTPSyncPoller.run_num == "2"):
- self.timer.startLongTimer(int(config.plugins.SetClock.useNTPminutes.value) * 60)
- else:#2
- if config.plugins.SetClock.choiceSystemTime.value == "1":
- if not config.plugins.SetClock.useNTPminutes.value == "0":
- cmd = '/usr/lib/enigma2/python/Plugins/Extensions/SetClock/ntpdate -s -u %s' % config.plugins.SetClock.ip.value
- self.Console.ePopen(cmd, self.update_schedule)
- self.timer.startLongTimer(int(config.plugins.SetClock.useNTPminutes.value) * 60)
- def update_schedule(self, result = None, retval = None, extra_args = None):
- if eDVBLocalTimeHandler.getInstance().ready():
- nowTime = time()
- if nowTime > 1388534400:
- setRTCtime(nowTime)
- if config.plugins.SetClock.choiceSystemTime.value == "0":
- eDVBLocalTimeHandler.getInstance().setUseDVBTime(True)
- else:
- eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
- try:
- eEPGCache.getInstance().timeUpdated()
- except:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement