Esempio n. 1
0
 def _on_packet(self, packet):
   source = _to_hex(packet['source_addr_long'])
   if not source in self.sources:
     self.sources[source] = {'source_addr_long': packet['source_addr_long'], 'source_addr': packet['source_addr']}
     events.fire('xbee.new', {'source': source, 'samples': packet.get('samples', [])})
   if packet.has_key('samples'):
     data = {"source": source, "samples": packet['samples'], 'source_addr': _to_hex(packet['source_addr'])}
     return events.fire('xbee.data', data)
Esempio n. 2
0
 def test_listen_and_fire(self):
   mock = Mock()
   events.listen_to('test', mock)
   d = events.fire('test', 'hello world')
   d.addCallback(lambda i: mock.assert_called_with('test', 'hello world'))
   return d