-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessage Size Optimizer.py
29 lines (27 loc) · 1 KB
/
Message Size Optimizer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# pyinstaller --onefile --console --name="MQTT Message Size Optimizer" "Message Size Optimizer.py" --specpath=build
from MQTT import MQTT
import pandas as pd
import sys
from time import sleep
from constants import *
def main():
Mqtt = MQTT(on_connect_funcs=['subscribe'], on_message_funcs=['message_size_monitor'])
Mqtt.subscribe_topic = input("Topic to Subscribe: ")
try:
standard_point = pd.read_csv(f"{ASSETS_PATH}{STANDARD_POINT_FILE}")
Mqtt.point_shorten = standard_point.set_index(POINT_NAME_COLUMN).to_dict(orient='dict')[POINT_SHORTEN_COLUMN]
except Exception as e:
print(f"Message Size Optimizer ::: Error ::: {e}")
sleep(5)
sys.exit()
Mqtt.module_shorten = MODULE_SHORTEN
print("\nPress Ctrl+C to stop\n")
try:
Mqtt.connect()
Mqtt.client.loop_forever()
except KeyboardInterrupt:
print("Stopping")
Mqtt.client.disconnect()
Mqtt.client.loop_stop()
if __name__ == "__main__":
main()