upgrade_20180329.py 695 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. #!/usr/bin/env python
  3. import os
  4. import sys
  5. # : current_dir - 2
  6. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  7. sys.path.insert(0, PROJECT_ROOT)
  8. from script.base import init_env
  9. init_env(interactive = True)
  10. from apps.web.agent.models import Agent
  11. from apps.web.device.models import DeviceType
  12. Agent.get_collection().update({}, {'$set': {'managerId': '59974b4b8732d6480fb699e5'}}, multi = True)
  13. types = DeviceType.objects.all()
  14. for tt in types:
  15. tt.managerId = '59974b4b8732d6480fb699e5'
  16. try:
  17. tt.save()
  18. except Exception, e:
  19. continue
  20. print 'execute ok'