# -*- 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 = [ '860344041594467', '860344041594608', '860344041594657', '860344041594699', '860344041594756', '860344041594780', '860344041594889', '860344041594905', '860344041594947', '860344041595498', '860344041595514', '860344041595530', '860344041595571', '860344041595597', '860344041595613', '860344041595662', '860344041595761', '860344041595779', '860344041595795', '860344041595894', '860344041596926', '860344041596942', '860344041596967', '860344041597007', '860344041597106', '860344041597122', '860344041597239', '860344041597296', '860344041597338', '860344041597353', '860344041610420', '860344041610883', '860344041611121', '860344041611204', '860344041611295', '860344041613713', '860344041613747', '860344041613788', '860344041613804', '860344041613861', '860344041613887', '860344041613929', '860344041613986', '860344041614034', '860344041614117', '860344041614133', '860344041614984', '860344041615049', '860344041619017', '860344041619058', '860344041619090', '860344041622847', '860344041622920', '860344041622946', '860344041623035', '860344041623050', '860344041623092', '860344041623134', '860344041623175', '860344041623209', '860344041623290', '860344041624751', '860344041624769', '860344041624785', '860344041624801', '860344041624868', '860344041624884', '860344041625014', '860344041625139', '860344041625154', '860344041625170', '860344041625212', '860344041625246', '860344041625303', '860344041625345', '860344041625360', '860344041625493', '860344041625535', '860344041625550', '860344041625626', '860344041625642', '860344041627630', '860344041627663', '860344041627689', '860344041627705', '860344041627788', '860344041627895', '860344041627937', '860344041627952', '860344041628000', '860344041628026', '860344041628091', '860344041629123', '860344041629263', '860344041629354', '860344041629370', '860344041629453', '860344041629479', '860344041629495', '860344041629511', '860344041629537', '860344041629552', '860344041629586', '860344041629669', '860344041629685', '860344041629776', '860344041629818', '860344041629834', '860344041629909', '860344041629925', '860344041629941', '860344041629982', '860344041633398', '860344041633406', '860344041633422', '860344041633547', '860344041633562', '860344041633588', '860344041633695', '860344041633752', '860344041633810', '860344041633885', '860344041633901', '860344041634032', '860344041634115', '860344041634131', '860344041634156', '860344041634172', '860344041634198', '860344041634313', '860344041634453', '860344041634495', '860344041634560', '860344041634669', '860344041634768', '860344041634800', '860344041637712', '860344041637720', '860344041637746', '860344041637860', '860344041637977', '860344041638017', '860344041638033', '860344041638066', '860344041638108', '860344041638124', '860344041638199', '860344041638207', '860344041638223', '860344041638249', '860344041638280', '860344041638348', '860344041638439', '860344041638611', '860344041639080', '860344041639122', '860344041639262', '860344041639288', '860344041639304', '860344041639312', '860344041639395', '860344041639403', '860344041639429', '860344041639445', '860344041639486', '860344041639502', '860344041639643', '860344041639668', '860344041639700', '860344041639833', '860344041639932', '860344041639957', '860344041640039', '860344041640153', '860344041640179', '860344041640195', '860344041640211', '860344041640534', '860344041640559', '860344041640567', '860344041640591', '860344041640609', '860344041640799', '860344041640849', '860344041640922', '860344041640948', '860344041641060', '860344041643587', '860344041643629', '860344041643660', '860344041643694', '860344041643710', '860344041643777', '860344041643975', '860344041643991', '860344041644056', '860344041644098', '860344041644130', '860344041644155', '860344041644171', '860344041644205', '860344041644221', '860344041644247', '860344041644320', '860344041644361', '860344041644387', '860344041644403', '860344041644429', '860344041645053', '860344041645533', '860344041645681', '860344041645723', '860344041645764', '860344041645780', '860344041645848', '860344041647828', '860344041647869', '860344041647901', '860344041647976', '860344041648057', '860344041648099', '860344041648180', '860344041648222', '860344041648255', '860344041648263', '860344041648297', '860344041648313', '860344041648461', '860344041648487', '860344041648644', '860344041648727', '860344041648743', '860344041650673', '860344041650707', '860344041650855', '860344041650871', '860344041650913', '860344041650939', '860344041650954', '860344041650970', '860344041651036', '860344041651051', '860344041651093', '860344041651176', '860344041651234', '860344041651259', '860344041651275', '860344041651317', '860344041651333', '860344041651358', '860344041651366', '860344041651440', '860344041651465', '860344041651507', '860344041651523', '860344041651564', '860344041651606', '860344041651622', '860344041655011', '860344041655052', '860344041655110', '860344041655136', '860344041655177', '860344041655219', '860344041655235', '860344041655284', '860344041655326', '860344041655342', '860344041655466', '860344041656449', '860344041656480', '860344041656563', '860344041656597', '860344041656654', '860344041656720', '860344041656738', '860344041656746', '860344041656761', '860344041656803', '860344041656837', '860344041656845', '860344041656860', '860344041656886', '860344041658874', '860344041658890', '860344041658916', '860344041658932', '860344041658973', '860344041659013', '860344041659062', '860344041659104', '860344041659120', '860344041659278', '860344041660029', '860344041660060', '860344041660128', '860344041662207', '860344041662280', '860344041662306', '860344041662363', '860344041662538', '860344041662579', '860344041662595', '860344041670366', '860344041670408', '860344041670424', '860344041670440', '860344041670465', '860344041670507', '860344041670572', '860344041670598', '860344041670630', '860344041670655', '860344041670671', '860344041670721', '860344041670747', '860344041670754', '860344041670770', '860344041670796', '860344041670812', '860344041671331', '860344041671356', '860344041671406', '860344041671422', '860344041671448', '860344041671489', '860344041671505', '860344041671521', '860344041671612', '860344041671653', '860344041671679', '860344041671778', '860344041671786', '860344041671794', '860344041671802', '860344041671943', '860344041672008', '860344041672024', '860344041672065', '860344041672081', '860344041672115', '860344041672750', '860344041672768', '860344041672826', '860344041672842', '860344041672917', '860344041672990', '860344041673014', '860344041673030', '860344041673071', '860344041673097', '860344041673113', '860344041673170', '860344041673725', '860344041673824', '860344041673865', '860344041673899', '860344041673915', '860344041674012', '860344041674046', '860344041674103', '860344041674178', '860344041677593', '860344041677676', '860344041677866', '860344041678146', '860344041678153', '860344041678179', '860344041678195', '860344041678211', '860344041678229', '860344041678237', '860344041678245', '860344041678252', '860344041678260', '860344041678310', '860344041678336', '860344041678344', '860344041678369', '860344041678401', '860344041678427', '860344041678435', '860344041678450', '860344041678492', '860344041678765', '860344041678799', '860344041678823', '860344041678849', '860344041678856', '860344041678930', '860344041679813', '860344041679854', '860344041679904', '860344041679912', '860344042478124', '860344042490939', '860344042492448', '860344042500828', '860344042507419', '860344042513557', '860344042514027', '860344042523127', '860344042523366', '860344042523374', '860344042523416', '860344042523499', '860344042523861', '860344042523960', '860344042523978', '860344042524331', '860344042528431', '860344042530353', '860344042531336', '860344042533902', '860344042535030', '860344042536418', '860344042536616', '860344042536756', '860344042536814', '860344042536855', '860344042536863', '860344042536871', '860344042536905', '860344042536913', '860344042536947', '860344042538257', '860344042539206', '860344042539214', '860344042539222', '860344042539230', '860344042539248', '860344042539255', '860344042539263', '860344042539297', '860344042539313', '860344042539321', '860344042539354', '860344042539404', '860344042539412', '860344042539446', '860344042539461', '860344042539479', '860344042539552', '860344042539578', '860344042539594', '860344042539628', '860344042539719', '860344042539925', '860344042539933', '860344042540402', '860344042540410', '860344042540618', '860344042540634', '860344042540642', '860344042540790', '860344042540907', '860344042541004', '860344042541053', '860344042541061', '860344042541087', '860344042541517', '860344042541871', '860344042541962', '860344042542325', '860344042543794', '860344042544271', '860344042544297', '860344042544529', '860344042544636', '860344042544966', '860344042545773', '860344042546433', '860344042546599', '860344042546656', '860344042547779', '860344042548124', '860344042548231', '860344042548546', '860344042548553', '860344042548561', '860344042548587', '860344042548595', '860344042548603', '860344042548629', '860344042548637', '860344042548645', '860344042548652', '860344042548660', '860344042548678', '860344042548694', '860344042548710', '860344042548751', '860344042548769', '860344042549031', '860344042549049', '860344042549056', '860344042549064', '860344042549072', '860344042549106', '860344042549122', ] for devNo in dev_no_list: dev = Device.get_dev(devNo) # type: DeviceDict 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) time.sleep(1)