From f85258431e765a9bef7abb809150846f968e9c08 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Mon, 11 Dec 2023 14:45:46 +0800 Subject: [PATCH] update --- data_upload.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data_upload.py b/data_upload.py index 05e9d88..2895826 100644 --- a/data_upload.py +++ b/data_upload.py @@ -5,6 +5,7 @@ import paho.mqtt.client as mqtt from device import device_name from tool import * + config = configparser.ConfigParser() config.read('/home/pi/lot_manager/conf/main/config.conf') times = 6 @@ -18,6 +19,7 @@ class DataUploadClient: self.username = username self.password = password self.client = mqtt.Client(client_id=device_name) + self.client.username_pw_set(self.username, self.password) self.client.on_connect = self.on_connect self.client.on_disconnect = self.on_disconnect @@ -32,7 +34,6 @@ class DataUploadClient: subprocess.Popen(['/usr/bin/bash /home/pi/lot_manager/bash/stop_data_upload.sh'], shell=True) def start(self): - self.client.username_pw_set(self.username, self.password) self.client.connect(self.broker, self.port) @@ -53,4 +54,4 @@ if __name__ == '__main__': time.sleep(10) if times == 0: MQTT.on_disconnect(None, None, None) - times -= 1 \ No newline at end of file + times -= 1