فهرست منبع

dnet: fix bug that caused lilith info not to be displayed

draoi 2 سال پیش
والد
کامیت
e2a47f99db
1فایلهای تغییر یافته به همراه75 افزوده شده و 31 حذف شده
  1. 75 31
      bin/dnet/src/view.py

+ 75 - 31
bin/dnet/src/view.py

@@ -107,7 +107,9 @@ class View():
     # Render get_info()
     #-----------------------------------------------------------------
     def draw_info(self, node_name, info):
+        logging.debug('draw_info() [START]')
         if 'spawns' in info and info['spawns']:
+            logging.debug(f'drawing lilith {info}')
             self.draw_lilith(node_name, info)
             return
 
@@ -158,6 +160,7 @@ class View():
         node.set_txt(False)
         self.listw.append(node)
         for (i, key) in enumerate(info['spawns'].keys()):
+            logging.debug(f'creating spawn slot {key}')
             slot = Slot(node_name, "spawn-slot")
             slot.set_txt(i, key)
             self.listw.append(slot)
@@ -183,17 +186,53 @@ class View():
                     slot.set_txt(item.i, info)
                     self.listw[index] = slot
 
+    def fill_lilith_right_box(self):
+        self.pile.contents.clear()
+        focus_w = self.list.get_focus()
+        if focus_w[0] is None:
+            return
+        session = focus_w[0].session
+        if session == "spawn-slot":
+            node_name = focus_w[0].node_name
+            spawn_name = focus_w[0].id
+            lilith = self.model.liliths.get(node_name)
+            spawns = lilith.get('spawns')
+            info = spawns.get(spawn_name)
+
+            if info['urls']:
+                urls = info['urls']
+                self.pile.contents.append((urwid.Text(
+                    f"Accept addrs:"),
+                    self.pile.options()))
+                for url in urls:
+                    self.pile.contents.append((urwid.Text(
+                        f"  {url}"),
+                        self.pile.options()))
+
+            if info['hosts']:
+                hosts = info['hosts']
+                self.pile.contents.append((urwid.Text(
+                    f"Hosts:"),
+                    self.pile.options()))
+                for host in hosts:
+                    self.pile.contents.append((urwid.Text(
+                        f"  {host}"),
+                        self.pile.options()))
+
     #-----------------------------------------------------------------
     # Render subscribe_events() (right menu)
     #-----------------------------------------------------------------
     def fill_right_box(self):
+        logging.debug('fill_right_box() [START]')
         self.pile.contents.clear()
         focus_w = self.list.get_focus()
+        logging.debug(f'focus_w: {focus_w}')
         if focus_w[0] is None:
             return
         session = focus_w[0].session
 
         if session == "outbound":
+            logging.debug('outbound slot selected')
             key = (focus_w[0].node_name, "outbound")
             info = self.model.nodes.get(focus_w[0].node_name)
             if key in info['event']:
@@ -204,6 +243,7 @@ class View():
 
         if (session == "outbound-slot" or session == "inbound-slot"
                 or session == "manual-slot" or session == "seed-slot"):
+            logging.debug('other slot selected')
             addr = focus_w[0].addr
             node_name = focus_w[0].node_name
             info = self.model.nodes.get(node_name)
@@ -218,32 +258,33 @@ class View():
                             f"{time}: {event}: {msg}"),
                             self.pile.options()))
 
-        if session == "spawn-slot":
-            node_name = focus_w[0].node_name
-            spawn_name = focus_w[0].id
-            lilith = self.model.liliths.get(node_name)
-            spawns = lilith.get('spawns')
-            info = spawns.get(spawn_name)
-
-            if info['urls']:
-                urls = info['urls']
-                self.pile.contents.append((urwid.Text(
-                    f"Accept addrs:"),
-                    self.pile.options()))
-                for url in urls:
-                    self.pile.contents.append((urwid.Text(
-                        f"  {url}"),
-                        self.pile.options()))
-
-            if info['hosts']:
-                hosts = info['hosts']
-                self.pile.contents.append((urwid.Text(
-                    f"Hosts:"),
-                    self.pile.options()))
-                for host in hosts:
-                    self.pile.contents.append((urwid.Text(
-                        f"  {host}"),
-                        self.pile.options()))
+        #if session == "spawn-slot":
+        #    logging.debug('spawn slot selected')
+        #    node_name = focus_w[0].node_name
+        #    spawn_name = focus_w[0].id
+        #    lilith = self.model.liliths.get(node_name)
+        #    spawns = lilith.get('spawns')
+        #    info = spawns.get(spawn_name)
+
+        #    if info['urls']:
+        #        urls = info['urls']
+        #        self.pile.contents.append((urwid.Text(
+        #            f"Accept addrs:"),
+        #            self.pile.options()))
+        #        for url in urls:
+        #            self.pile.contents.append((urwid.Text(
+        #                f"  {url}"),
+        #                self.pile.options()))
+
+        #    if info['hosts']:
+        #        hosts = info['hosts']
+        #        self.pile.contents.append((urwid.Text(
+        #            f"Hosts:"),
+        #            self.pile.options()))
+        #        for host in hosts:
+        #            self.pile.contents.append((urwid.Text(
+        #                f"  {host}"),
+        #                self.pile.options()))
 
     # Sort nodes into lists.
     def sort(self, nodes):
@@ -260,7 +301,7 @@ class View():
                 self.refresh = True
 
     # Display nodes according to list.
-    async def draw(self, nodes):
+    async def display(self, nodes):
         for name, info in nodes:
             if name in self.live_nodes and name not in self.known_nodes:
                 self.draw_info(name, info)
@@ -279,10 +320,12 @@ class View():
                 logging.debug("Refresh complete.")
 
     # Handle events.
-    def events(self, nodes):
+    def draw_events(self, nodes):
         for name, info in nodes:
             if bool(info) and name in self.known_nodes:
+                logging.debug('fill left box')
                 self.fill_left_box()
+                logging.debug('fill right box')
                 self.fill_right_box()
 
                 if 'inbound' in info:
@@ -341,7 +384,8 @@ class View():
             self.sort(nodes)
             self.sort(liliths)
             
-            await self.draw(nodes)
-            await self.draw(liliths)
+            await self.display(nodes)
+            await self.display(liliths)
 
-            self.events(nodes)
+            self.fill_lilith_right_box()
+            self.draw_events(nodes)