Advertisement
SharkyEXE

Untitled

Nov 3rd, 2018
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. from enigma import eTimer
  2. from Components.config import config
  3. from Components.Console import Console
  4. from enigma import eTimer, eDVBLocalTimeHandler, eEPGCache
  5. try:
  6. from Tools.StbHardware import setRTCtime
  7. except:
  8. from Tools.DreamboxHardware import setRTCtime
  9. from time import time
  10.  
  11. class NTPSyncPoller:
  12. """Automatically Poll NTP"""
  13. def __init__(self):
  14. self.timer = eTimer()
  15. self.Console = Console()
  16.  
  17. def start(self):
  18. if not self.timer.callback:
  19. self.timer.callback.append(self.NTPStart)
  20. self.timer.startLongTimer(0)
  21.  
  22. def stop(self):
  23. if self.timer.callback:
  24. self.timer.callback.remove(self.NTPStart)
  25. self.timer.stop()
  26.  
  27. def NTPStart(self):
  28. if config.plugins.SetClock.choiceSystemTime.value == "1":
  29. if not config.plugins.SetClock.useNTPminutes.value == "0":
  30. cmd = '/usr/lib/enigma2/python/Plugins/Extensions/SetClock/ntpdate -s -u %s' % config.plugins.SetClock.ip.value
  31. self.Console.ePopen(cmd, self.update_schedule)
  32. self.timer.startLongTimer(int(config.plugins.SetClock.useNTPminutes.value) * 60)
  33.  
  34. def update_schedule(self, result = None, retval = None, extra_args = None):
  35. if eDVBLocalTimeHandler.getInstance().ready():
  36. nowTime = time()
  37. if nowTime > 1388534400:
  38. setRTCtime(nowTime)
  39. if config.plugins.SetClock.choiceSystemTime.value == "0":
  40. eDVBLocalTimeHandler.getInstance().setUseDVBTime(True)
  41. else:
  42. eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
  43. try:
  44. eEPGCache.getInstance().timeUpdated()
  45. except:
  46. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement