Example #1
0
def run():
		
     # local heartbeat and Aggregator
     if options.aggregator:

          aggregator = Aggregator(options.agconfig)
          portal = create_portal(aggregator)
          
          heartbeat = Heartbeat(address=options.group, port=options.port)
          localip = socket.gethostbyname(socket.gethostname())
          heartbeat.setMessage(encode(options.id, localip, options.agport, aggregator.getPassword()))
          
          reactor.listenTCP(options.agport, pb.PBServerFactory(portal))
          aggregator.notifyOnMapped(heartbeat.start)

     # heartbeat monitor
     monitor = Monitor(address=options.group, port=options.port)

     # wx-twisted communication bridge (mediator)
     global twistedbridge
     twistedbridge = TwistedBridge(monitor)

     # monitor reports to the bridge via callbacks
     monitor.newHeartbeat(twistedbridge.newHeartbeat)
     monitor.lostHeartbeat(twistedbridge.lostHeartbeat)

     monitor.start()

     app = MyApp(redirect=False)
     app.MainLoop()
    def test_codec(self):
        """FIXME: this is a crude inflexible payload format"""

        name = 'localhost'
        ip = '127.0.0.1'
        port = 12345
        s = encode(name, ip, port, 'bkurk')

        assert type(s) == type('')

        dname, dip, dport, dpasswd = decode(s)
        assert dname == name
        assert dip == ip
        assert dport == port
        assert dpasswd == 'bkurk'