فهرست منبع

add oneshot+status reporting

David 10 سال پیش
والد
کامیت
303697efa1
1فایلهای تغییر یافته به همراه14 افزوده شده و 1 حذف شده
  1. 14 1
      pmanager/pmanager.py

+ 14 - 1
pmanager/pmanager.py

@@ -65,6 +65,9 @@ class PManager:
                 continue
         
             #log(j)
+            if j["command"] == "oneshot":
+                self.oneshot(j["key"])
+
             if j["command"] == "launch":
                 opts = None
                 if "options" in j:
@@ -77,7 +80,7 @@ class PManager:
             if j["command"] == "netcat":
                 sendmsg(j["key"])
             if j["command"] == "status": #and j["key"] == self.name:
-                self.send({"name": self.name, "data":self.p_list})
+                self.send({"type": "snowmix", "name": self.name, "data":self.p_list})
 
     def send(self, data):
         try:
@@ -130,6 +133,16 @@ class PManager:
     
         del self.p_list[key]
             
+    def oneshot(self, key):
+        if key not in self.ptable:
+            log("This process (%s) is not on my table!" % key)
+            return
+        log("Oneshotting! key: %s" % key)
+        try:
+            proc = subprocess.Popen(self.ptable[key], preexec_fn=os.setsid)
+        except Exception as e:
+            log(e)
+
     def launch(self, key, options=None):
         if key in self.p_list:
             log("key %s exist! not running!" % (key))