# -*- coding: utf-8 -*- #!/usr/bin/env python import os import sys # : current_dir - 2 PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..') sys.path.insert(0, PROJECT_ROOT) from script.base import init_env init_env(interactive = True) from apps.web.agent.models import Agent from apps.web.device.models import DeviceType Agent.get_collection().update({}, {'$set': {'managerId': '59974b4b8732d6480fb699e5'}}, multi = True) types = DeviceType.objects.all() for tt in types: tt.managerId = '59974b4b8732d6480fb699e5' try: tt.save() except Exception, e: continue print 'execute ok'