-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.py
More file actions
27 lines (21 loc) · 679 Bytes
/
Copy pathsend.py
File metadata and controls
27 lines (21 loc) · 679 Bytes
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
import paho.mqtt.client as mqtt
import os
import sys
topic = "suchit/image"
# Hide traceback
sys.tracebacklimit=0
SHOW_STACK_TRACE=False
def on_connect(client, userdata, flags, rc):
print(f"Connected with result code {rc}")
f=open("./img/intruder_compressed.jpeg", "rb")
fileContent = f.read()
byteArr = bytearray(fileContent)
#print(byteArr)
client.publish(topic, byteArr, 2)
print("Published")
print("Redirecting to numpad.py")
os.system("venv/bin/python3 numpad.py") #Anything after this line does not execute.
client = mqtt.Client()
client.on_connect = on_connect
client.connect("test.mosquitto.org", 1883, 60)
client.loop_forever()