update_assigned.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. import os
  4. import sys
  5. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  6. sys.path.insert(0, PROJECT_ROOT)
  7. from script.base import init_env
  8. init_env(interactive = True)
  9. from apps.web.core.networking import MessageSender
  10. from apps.web.device.models import Device
  11. from apps.web.constant import DeviceOnlineStatus, DeviceCmdCode
  12. url = 'https://resource.washpayer.com/versions/one/V3037_V4013_4gcat1_6.1.161_100259.bin'
  13. filter = {
  14. "driverCode": "100259",
  15. "driverVersion": {"$ne": "v5.1.5"},
  16. 'coreVer': 'Luat_V3037_RDA8910',
  17. 'ownerId': {'$nin': [None, '']}
  18. }
  19. for device in Device.objects(__raw__ = filter):
  20. dev = Device.get_dev(device.devNo)
  21. if dev.online != DeviceOnlineStatus.DEV_STATUS_ONLINE:
  22. print '{} is offline.'.format(device.devNo)
  23. continue
  24. cmdPara = {'cmd': DeviceCmdCode.SET_DEVINFO, 'IMEI': device.devNo, 'ota_set': {'fw_url': url}}
  25. print cmdPara
  26. result = MessageSender.send(device = dev, cmd = DeviceCmdCode.SET_DEVINFO, payload = cmdPara, timeout = 15)