Question

Can anyone see what the problem is here? I am new to python and I need some guidance. I'm running Python 2.7.3 in 32-bit mode on a mac with Lion. Dependencies include

pyOSC pyserial 2.6 python-xbee-api 2.00 optparse_gui 0.2 wxPython 2.8

I would appreciate any help!

OSCServer: KeyError on request from home.gateway:60537: 0
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 638, in __init__
    self.handle()
  File "/Library/Python/2.7/site-packages/OSC.py", line 1770, in handle
    self._unbundle(decoded)
  File "/Library/Python/2.7/site-packages/OSC.py", line 1761, in _unbundle
    self._unbundle(msg)
  File "/Library/Python/2.7/site-packages/OSC.py", line 1752, in _unbundle
    self.replies += self.server.dispatchMessage(decoded[0], decoded[1][1:], decoded[2:], self.client_address)
  File "/Library/Python/2.7/site-packages/OSC.py", line 1714, in dispatchMessage
    reply = self.callbacks[addr](pattern, tags, data, client_address)
  File "minihiveosc.py", line 74, in handler_output
    self.setOutput( args[0], args[1:] )
  File "minihiveosc.py", line 178, in setOutput
    self.hive.oscToMiniBee( mid, data )
  File "minihiveosc.py", line 330, in oscToMiniBee
    self.hive.bees[ nid ].send_output( self.hive.serial, data )
KeyError: 0
Was it helpful?

Solution

The KeyError exception is most commonly raised when you do a dictionary lookup with a key that isn't in the dictionary. In this case, it looks like that would be on that last line:

self.hive.bees[ nid ].send_output( self.hive.serial, data )

..specifically, the self.hive.bees[ nid ] part. nid apparently holds a value of 0, and your self.hive.bees dictionary doesn't have a 0 key in it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top