Pārlūkot izejas kodu

Removed object instance count checking. (!)

We are doing it correctly now.  Instead of checking
to see if an object is active or not.  (Which is
the wrong way to do it.)
Steve Thielemann 5 gadi atpakaļ
vecāks
revīzija
ca79199cef
1 mainītis faili ar 6 papildinājumiem un 18 dzēšanām
  1. 6 18
      tcp-proxy.py

+ 6 - 18
tcp-proxy.py

@@ -168,10 +168,7 @@ class PlayerInput(object):
         return line
         return line
 
 
 class ProxyMenu(object):
 class ProxyMenu(object):
-    count = 0
-
     def __init__(self, game):
     def __init__(self, game):
-        ProxyMenu.count += 1
         self.nl = "\n\r"
         self.nl = "\n\r"
         self.c = merge(Style.BRIGHT + Fore.YELLOW + Back.BLUE)
         self.c = merge(Style.BRIGHT + Fore.YELLOW + Back.BLUE)
         self.r = Style.RESET_ALL
         self.r = Style.RESET_ALL
@@ -192,13 +189,8 @@ class ProxyMenu(object):
         self.keepalive.start(30)
         self.keepalive.start(30)
         self.menu()
         self.menu()
 
 
-    @classmethod
-    def total(cls):
-        return cls.count
-
     def __del__(self):
     def __del__(self):
         log.msg("ProxyMenu {0} RIP".format(self))
         log.msg("ProxyMenu {0} RIP".format(self))
-        ProxyMenu.count -= 1
 
 
     def whenDone(self):
     def whenDone(self):
         self.defer = defer.Deferred()
         self.defer = defer.Deferred()
@@ -878,9 +870,7 @@ class Player(protocol.Protocol):
             self.queue_player.put(chunk)
             self.queue_player.put(chunk)
         
         
         else:
         else:
-            # If there's an observer -- should I continue here?
-            log.msg("I'm being watched...")
-            # TIAS.
+            # There's an observer.  Don't continue.
             return
             return
 
 
         if chunk == b"~":
         if chunk == b"~":
@@ -898,14 +888,12 @@ class Player(protocol.Protocol):
 
 
         if chunk == b"|":
         if chunk == b"|":
             # how can I tell if this is active or not?
             # how can I tell if this is active or not?
-            log.msg(pformat(self.observer.dispatch))
+            # I no longer see a 'player' observer.  GOOD!
+            # log.msg(pformat(self.observer.dispatch))
 
 
-            if ProxyMenu.total() == 0:
-                # prompt = self.game.getPrompt()
-                # if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
-                menu = ProxyMenu(self.game)
-            else:
-                log.msg("The menu is already active!")
+            # prompt = self.game.getPrompt()
+            # if re.match(r"Command \[TL=.* \(\?=Help\)\? :", prompt):
+            menu = ProxyMenu(self.game)