convert.py 589 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. import sys
  3. sys.getdefaultencoding()
  4. reload(sys)
  5. sys.setdefaultencoding('UTF-8')
  6. from demeter.core import *
  7. import time
  8. # 测试命令行传参 python convert.py -f file.doc
  9. param = {}
  10. param['file'] = 'f'
  11. Demeter.getopt(param)
  12. file = Demeter.option['file']
  13. convert = Demeter.service('convert')
  14. if file:
  15. id = int(file)
  16. convert.handle(id)
  17. else:
  18. model = Demeter.model('convert')
  19. model.status = 3
  20. info = model.select(type='fetchall')
  21. if info:
  22. for i in info:
  23. redis = Demeter.redis()
  24. config = Demeter.config['redis']
  25. redis.rpush(config['name'], i['id'])