Esempio n. 1
0
 def __init__(self, logMessages=False):
     super(GuiProcess, self).__init__()
     self.pid = Process.attach("GUI", self)
     self.messages = PatternMatcher()
     self.isOpen = True
     self.logger = Process.logger()
     self.logMessages = logMessages
Esempio n. 2
0
 def event(self, ev):
     """ Handle events sent to the object. """
     if ev.type() == MessageReceivedEvent.Type:
         if self.logMessages:
             self.logger.info("Received message %s.", repr(ev.m))
         try:
             self.messages.match(ev.m)
         except Exception:
             Process.logger().exception("An exception was raised by the process")
         return True
     else:
         return False
Esempio n. 3
0
 def testClientServerNegociation(self):
     """ Negociation should work out with client and server using the same negociation code. """
     pid = Process.current()
     c, s = Pipe.create()
     def server():
         name = negociateProtocol(s, False)
         Process.send(pid, name)
     def client():
         name = negociateProtocol(c, True)
         Process.send(pid, name)
     Process.spawn(server)
     Process.spawn(client)
     firstName = Process.receive()
     secondName = Process.receive()
     for name in (firstName, secondName):
         self.assertTrue(name in Supported)
     self.assertEqual(firstName, secondName)
Esempio n. 4
0
 def client():
     name = negociateProtocol(c, True)
     Process.send(pid, name)
Esempio n. 5
0
 def server():
     name = negociateProtocol(s, False)
     Process.send(pid, name)
Esempio n. 6
0
 def __exit__(self, type, e, traceback):
     Process.detach()