# -*- coding: utf-8 -*- # !/usr/bin/env python import sys import os PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + '/..'), '..') sys.path.insert(0, PROJECT_ROOT) import os os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'configs.production') from script.base import init_env init_env(interactive = False) import time from apps.web.device.models import Device, DeviceDict from apps.web.core.networking import MessageSender dev_no_list = [ '860344041506990', '860344043042978', '860344043064717', '860344044730878', '860344045585636', '860344045956068', '860344046010063', '860344046077674', '860344046083706', '860344046720844', '860344046751229', '860344046757168', '860344046875069', '860344046910940', '860344046917556', '860344047254090', '860344047303962', '860344047311072', '860344047311577', '860344047317236', '860344047317657', '860344047318275', '860344047348371', '860344047396990', '860344047400628', '860344047400644', '860344047404547', '860344047404984', '860344047405791', '860344047408290', '860344049332035', '860344049351019', '860344049351217', '860344049351282', '860344049361752', '860344049364178', '862285036747925', '865650040602662', '865650042842597', '865650042843397', '865650042845467', '865650042846663', '865650042852711', '865650042853263', '865650042858759', '865650042859278', '865650042872412', '865650042872743', '865650042875886', '865650042877908', '865650042880290', '865650042884300', '865650042884391', '865650042887303', '865650042891156', '865650042894317', '865650042897781', '865650042907440', '865650042907549', '865650042910428', '865650042915773', '865650042917936', '865650042920237', '865650042921292', '865650042923637', '865650042923660', '865650042930285', '865650042931614', '865650042933040', '865650042934766', '865650042955258', '865650042955290', '865650042955324', '866289031562053', '866289032596407', '866289033267297', '866289037644970', '866289037698471', '868575025737042', '868575025782121', '868575026767311', '868575029319649', '868575029322023', '868575029331552', '868575029343672', '869300031758273', '869300031775210', '869300033374111', '869300033392022', '869300036436537', '869300036441750', '869300036446361', '869300039875731', '869300039876325', '869300039885441', '869300039909258', '869300039915305', '869300039922269', ] for devNo in dev_no_list: dev = Device.get_dev(devNo) # type: DeviceDict if not dev: continue if ':1883' in dev['server']: continue if dev['driverCode'] == '900100': continue if not dev.online: print '{} is offline.'.format(devNo) continue cmd_para = {'IMEI':devNo,'addr_set':{'ip1':'120.27.251.159','port1':1883}} MessageSender.send(device = dev, cmd = 202, payload = cmd_para, timeout = 15)