#!/usr/bin/env python3 import paho.mqtt.client as mqtt import threading import json import subprocess from time import sleep from os import path p = None # The callback for when the client receives a CONNACK response from the server. def on_connect(client, userdata, flags, rc): print("Connected with result code "+str(rc)) # Subscribing in on_connect() means that if we lose the connection and # reconnect then subscriptions will be renewed. client.subscribe("video/slidesyncer/#") # The callback for when a PUBLISH message is received from the server. def on_message(client, userdata, msg): global p print(msg.topic+" "+str(msg.payload)) if msg.topic == "video/slidesyncer/sync": p = subprocess.Popen(["/home/curso/code/snowmix/camera1/slide_syncer.sh"]) print(p.communicate()) client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message client.connect("192.168.2.123", 1883, 60) t = threading.Thread(target=client.loop_forever) t.start() t.join()