Advertisement
SharkyEXE

Untitled

Nov 3rd, 2018
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 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. run_num = 0
  14. def __init__(self):
  15. NTPSyncPoller.run_num += 1
  16. self.timer = eTimer()
  17. self.Console = Console()
  18.  
  19. def start(self):
  20. if not self.timer.callback:
  21. self.timer.callback.append(self.NTPStart)
  22. self.timer.startLongTimer(0)
  23.  
  24. def stop(self):
  25. if self.timer.callback:
  26. self.timer.callback.remove(self.NTPStart)
  27. self.timer.stop()
  28.  
  29. def NTPStart(self):
  30. if (NTPSyncPoller.run_num == "1" or NTPSyncPoller.run_num == "2"):
  31. self.timer.startLongTimer(int(config.plugins.SetClock.useNTPminutes.value) * 60)
  32. else:#2
  33. if config.plugins.SetClock.choiceSystemTime.value == "1":
  34. if not config.plugins.SetClock.useNTPminutes.value == "0":
  35. cmd = '/usr/lib/enigma2/python/Plugins/Extensions/SetClock/ntpdate -s -u %s' % config.plugins.SetClock.ip.value
  36. self.Console.ePopen(cmd, self.update_schedule)
  37. self.timer.startLongTimer(int(config.plugins.SetClock.useNTPminutes.value) * 60)
  38.  
  39. def update_schedule(self, result = None, retval = None, extra_args = None):
  40. if eDVBLocalTimeHandler.getInstance().ready():
  41. nowTime = time()
  42. if nowTime > 1388534400:
  43. setRTCtime(nowTime)
  44. if config.plugins.SetClock.choiceSystemTime.value == "0":
  45. eDVBLocalTimeHandler.getInstance().setUseDVBTime(True)
  46. else:
  47. eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
  48. try:
  49. eEPGCache.getInstance().timeUpdated()
  50. except:
  51. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement