diff --git a/MQTT.py b/MQTT.py index 6168895..e333e58 100644 --- a/MQTT.py +++ b/MQTT.py @@ -5,9 +5,7 @@ import paho.mqtt.client as mqtt from tool import push_stream, close_stream, update, exec_sh, get_record, get_list_record, get_status -import os -device_name = os.getenv('device_name') def on_connect(client, userdata, flags, rc): @@ -16,6 +14,8 @@ def on_connect(client, userdata, flags, rc): def valid(msg, client): + import os + device_name = os.getenv('device_name') origin_data = json.loads(msg.payload.decode('utf-8')) if 'msg' not in origin_data: client.publish('error', payload='msg must be supplied', qos=0)