core.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. from demeter.core import *
  3. class Core(object):
  4. def init(self):
  5. # 注册
  6. zeus = Demeter.config['zeus']['host']
  7. url = zeus + 'interface/init'
  8. farm = Demeter.config['setting']['farm']
  9. ip = '192.168.33.10'
  10. data = Demeter.curl(url, {'id':farm,'ip':ip}, 'post')
  11. # 保存需要同步的数据,定时同步
  12. def save(self):
  13. pass
  14. # 实时同步
  15. def rsync(self, table, id):
  16. command = Demeter.path + 'sync.py -t ' + table + ' -i ' + id
  17. Shell.popen("python3 " + command, bg=True)
  18. #self.sync(table)
  19. # 远程同步
  20. def sync(self, table, search={}):
  21. zeus = Demeter.config['zeus']['host']
  22. url = zeus + 'interface/sync'
  23. farm = Demeter.config['setting']['farm']
  24. data = Demeter.service('common').list(table, search=search)
  25. param = {}
  26. param['data'] = json.dumps(data)
  27. param['table'] = table
  28. param['farm'] = farm
  29. Demeter.curl(url, param, 'post')