record.py 491 B

12345678910111213141516171819
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter service
  5. name:record.py 用于记录设备过来的数据
  6. author:rabin
  7. """
  8. from demeter import *
  9. class Record(object):
  10. def topic(self, key):
  11. array = key.split('/')
  12. return {'method':array[0], 'type':array[1], 'parent':array[2], 'child':array[3]}
  13. def push(self, key, value):
  14. config = self.topic(key)
  15. method = 'record_' + config['method']
  16. cls = Demeter.getClass(method, 'service.')
  17. cls().handle(config, value)