modify_mqtt_port2.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. import sys
  4. import os
  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. import os
  8. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'configs.production')
  9. from script.base import init_env
  10. init_env(interactive = False)
  11. import time
  12. from apps.web.device.models import Device, DeviceDict
  13. from apps.web.core.networking import MessageSender
  14. dev_no_list = [
  15. '860344041506990',
  16. '860344043042978',
  17. '860344043064717',
  18. '860344044730878',
  19. '860344045585636',
  20. '860344045956068',
  21. '860344046010063',
  22. '860344046077674',
  23. '860344046083706',
  24. '860344046720844',
  25. '860344046751229',
  26. '860344046757168',
  27. '860344046875069',
  28. '860344046910940',
  29. '860344046917556',
  30. '860344047254090',
  31. '860344047303962',
  32. '860344047311072',
  33. '860344047311577',
  34. '860344047317236',
  35. '860344047317657',
  36. '860344047318275',
  37. '860344047348371',
  38. '860344047396990',
  39. '860344047400628',
  40. '860344047400644',
  41. '860344047404547',
  42. '860344047404984',
  43. '860344047405791',
  44. '860344047408290',
  45. '860344049332035',
  46. '860344049351019',
  47. '860344049351217',
  48. '860344049351282',
  49. '860344049361752',
  50. '860344049364178',
  51. '862285036747925',
  52. '865650040602662',
  53. '865650042842597',
  54. '865650042843397',
  55. '865650042845467',
  56. '865650042846663',
  57. '865650042852711',
  58. '865650042853263',
  59. '865650042858759',
  60. '865650042859278',
  61. '865650042872412',
  62. '865650042872743',
  63. '865650042875886',
  64. '865650042877908',
  65. '865650042880290',
  66. '865650042884300',
  67. '865650042884391',
  68. '865650042887303',
  69. '865650042891156',
  70. '865650042894317',
  71. '865650042897781',
  72. '865650042907440',
  73. '865650042907549',
  74. '865650042910428',
  75. '865650042915773',
  76. '865650042917936',
  77. '865650042920237',
  78. '865650042921292',
  79. '865650042923637',
  80. '865650042923660',
  81. '865650042930285',
  82. '865650042931614',
  83. '865650042933040',
  84. '865650042934766',
  85. '865650042955258',
  86. '865650042955290',
  87. '865650042955324',
  88. '866289031562053',
  89. '866289032596407',
  90. '866289033267297',
  91. '866289037644970',
  92. '866289037698471',
  93. '868575025737042',
  94. '868575025782121',
  95. '868575026767311',
  96. '868575029319649',
  97. '868575029322023',
  98. '868575029331552',
  99. '868575029343672',
  100. '869300031758273',
  101. '869300031775210',
  102. '869300033374111',
  103. '869300033392022',
  104. '869300036436537',
  105. '869300036441750',
  106. '869300036446361',
  107. '869300039875731',
  108. '869300039876325',
  109. '869300039885441',
  110. '869300039909258',
  111. '869300039915305',
  112. '869300039922269',
  113. ]
  114. for devNo in dev_no_list:
  115. dev = Device.get_dev(devNo) # type: DeviceDict
  116. if not dev:
  117. continue
  118. if ':1883' in dev['server']:
  119. continue
  120. if dev['driverCode'] == '900100':
  121. continue
  122. if not dev.online:
  123. print '{} is offline.'.format(devNo)
  124. continue
  125. cmd_para = {'IMEI':devNo,'addr_set':{'ip1':'120.27.251.159','port1':1883}}
  126. MessageSender.send(device = dev, cmd = 202, payload = cmd_para, timeout = 15)