update
This commit is contained in:
parent
28a86212f2
commit
d034547fac
6
ceshi.py
6
ceshi.py
|
@ -15,13 +15,13 @@ import paho.mqtt.client as mqtt
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
global times
|
global times
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
print("连接成功,执行数据推送和本地存储")
|
# print("连接成功,执行数据推送和本地存储")
|
||||||
subprocess.Popen(['/usr/bin/bash start_data_upload.sh'], shell=True)
|
subprocess.Popen(['/usr/bin/bash start_data_upload.sh'], shell=True)
|
||||||
times = 3
|
times = 3
|
||||||
|
|
||||||
|
|
||||||
def on_connect_fail(client, userdata):
|
def on_connect_fail(client, userdata):
|
||||||
print("失败,执行本地存储")
|
# print("失败,执行本地存储")
|
||||||
subprocess.Popen(['/usr/bin/bash stop_data_upload.sh'], shell=True)
|
subprocess.Popen(['/usr/bin/bash stop_data_upload.sh'], shell=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ if __name__ == '__main__':
|
||||||
# Publish a message
|
# Publish a message
|
||||||
client.loop_forever()
|
client.loop_forever()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("等待5秒重新连接客户端")
|
# print("等待5秒重新连接客户端")
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
if times != 0:
|
if times != 0:
|
||||||
times -= 1
|
times -= 1
|
||||||
|
|
Loading…
Reference in New Issue