Browse Source

oneshot +options

David 10 years atrás
parent
commit
a2e3516f4d
2 changed files with 16 additions and 5 deletions
  1. 14 4
      pmanager/pmanager.py
  2. 2 1
      pmanager/rpi.json

+ 14 - 4
pmanager/pmanager.py

@@ -66,13 +66,16 @@ class PManager:
         
             #log(j)
             if j["command"] == "oneshot":
-                self.oneshot(j["key"])
+                opts = None
+                if "options" in j:
+                    opts = j["options"]
+                self.oneshot(j["key"], opts)
 
             if j["command"] == "launch":
                 opts = None
                 if "options" in j:
                     opts = j["options"]
-                self.launch(j["key"],opts)
+                self.launch(j["key"], opts)
         
             if j["command"] == "kill":
                 self.stop(j["key"])
@@ -137,13 +140,20 @@ class PManager:
         del self.p_list[key]
         self.sendstatus()
             
-    def oneshot(self, key):
+    def oneshot(self, key, options=None):
         if key not in self.ptable:
             log("This process (%s) is not on my table!" % key)
             return
         log("Oneshotting! key: %s" % key)
+        tolaunch = self.ptable[key]
+        if options is not None:
+            options = [ o for o in options if type(o) is str ]
+            tolaunch = tolaunch + options
+
+        log(tolaunch)
+
         try:
-            proc = subprocess.Popen(self.ptable[key], preexec_fn=os.setsid)
+            proc = subprocess.Popen(tolaunch, preexec_fn=os.setsid)
         except Exception as e:
             log(e)
 

+ 2 - 1
pmanager/rpi.json

@@ -2,6 +2,7 @@
 	"name": "pi",
 	"data": {
 		"piaudio" : [ "/home/curso/code/snowmix/camera1/mic-to-udp.sh", "192.168.1.120" ],
-		"pivideo" : [ "/home/curso/code/snowmix/camera1/cam-to-udp.sh", "192.168.1.120" ]
+		"pivideo" : [ "/home/curso/code/snowmix/camera1/cam-to-udp.sh", "192.168.1.120" ],
+		"servo" : [ "/home/curso/code/snowmix/camera1/rotate-servo.py" ]
 	}
 }