timesync.py 402 B

1234567891011121314151617181920212223
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web
  4. name:admin.py
  5. author:rabin
  6. """
  7. import time
  8. from demeter.core import *
  9. from demeter.mqtt import *
  10. timeSleep = 3600*24
  11. # 同步时间,24小时同步一次
  12. class Timesync(object):
  13. def run(self):
  14. self.handle()
  15. time.sleep(timeSleep)
  16. def handle(self):
  17. pub = Pub()
  18. key = 'time/bh'
  19. value = Demeter.date(Demeter.time())
  20. pub.push(key, value)