Преглед изворни кода

made server more stable and minor change

digital пре 8 година
родитељ
комит
fd8c35e77a
1 измењених фајлова са 23 додато и 6 уклоњено
  1. 23 6
      lib/beewatch/server/__init__.py

+ 23 - 6
lib/beewatch/server/__init__.py

@@ -88,12 +88,29 @@ class ConnHandlerBeeWatch(digilib.network.ConnHandlerBase):
             cmd=data_decoded
             args = ()
         kwargs = {}
-        self.call(
-            cmd,
-            respond=self.respond,
-            args=args,
-            kwargs={},
-        )
+        ttf = beewatch._commands
+        if func_name in ttf.keys():
+            try:
+                task = curio.run(
+                    ttf[func_name](
+                        # self.bee_api,
+                        *args,
+                        command=cmd,
+                        respond=respond,
+                    )
+                )
+            except Exception as e:
+                lserver.error("Error while calling api func",exc_info=e)
+                tb = traceback.format_exc()
+                respond(tb)
+        else:
+            respond("Unknown command")
+        # self.call(
+        #     cmd,
+        #     respond=self.respond,
+        #     args=args,
+        #     kwargs={},
+        # )
     def do(self,func_num,*args,respond):
         arg_to_func = {
             "1":self.bee_api.do_something_1,