Commits

Anonymous committed a59610b

refactoring of the stompengine and overall cleanups

Comments (0)

Files changed (3)

common/boincvm_common/stomp/BaseStompEngine.py

 
 import stomper
 import logging
-import netifaces
 
 class BaseStompEngine(stomper.Engine):
   """
     stomper.Engine.__init__(self)
     self._msgInterpreter = msgInterpreter
 
-  def _initId(self, iface):
-    networkInterfaceData = netifaces.ifaddresses(iface)
-    self._id, self._ip = [ networkInterfaceData[af][0]['addr'] for af in (netifaces.AF_LINK, netifaces.AF_INET) ]
-    self._id = self._id.upper()
-    self.logger.debug("Engine instantiated with id/ip %s/%s" % (self._id, self._ip) )
-
-  @property
-  def id(self):
-    return self._id
-
-  @property
-  def ip(self):
-    return self._ip
-
 
   def ack(self, msg):
     """Called when a MESSAGE message is received"""

common/boincvm_common/stomp/StompProtocol.py

   def __init__(self, stompEngine, username, password):
     self._username = username
     self._password = password
-    self._myEngine = stompEngine() #construct the engine
-    self._myEngine.protocol = self #inject ourselves into the engine
+    self._myEngine = stompEngine
+    self._myEngine.protocol = self #inject ourselves into the engine, FIXME
 
   def connectionMade(self):
     """
   logger = logging.getLogger( support.discoverCaller() )
 
   def __init__(self, engine, username, password):
-    self._engine = engine
-    self._username = username
-    self._password = password
-    self.protocol = lambda: StompProtocol(self._engine, self._username, self._password)
+    self.protocol = lambda: StompProtocol(engine, username, password)
 
     self.delay = 5.0 #XXX: this isn't a public attribute, working around a twisted bug
     self.factor = 1.0
 
   def buildProtocol(self, addr):
     try:
+      #will create a protocol of the class given in self.protocol (set in the ctor)
       p = ReconnectingClientFactory.buildProtocol(self, addr)
     except Exception, e:
       #this could happen if, for instance, we can't start a helper prog (such as vboxwebsrv)

common/boincvm_common/stomp/protocol/words.py

 import fnmatch
 
 
-logger = logging.getLogger(support.discoverCaller())
+logger = logging.getLogger('words')
 
 class BaseWord(object):
   """ Initializes the Frame object with the inheriting class' name """
 #because ain't ain't a word!
 class AINT(BaseWord):
   @classmethod
-  def listenAndAct(cls, *msg):
-    logger.warn("Unknown message type. Data = %s" % str(msg))
+  def listenAndAct(cls, requester, msg):
+    logger.warn("Unknown message type received. Data = '%s'" % str(msg))