n1ywb/webdlmon-backend — pull request #1 by geoffdavis (2012-11-17 01:55:05+00:00)
Title: Fix KeyError on dict due to missing opt key

Fixes problem where datalogger doesn't have an opt channel. The checking if the value is null isn't enough - the dict actually is missing the 'opt' key.

source orb is iggprt:status

webapps@anfwebl ~/webdlmon-backend $ ./runit.sh
2012-11-16 16:59:18-0800 [-] Log opened.
2012-11-16 16:59:19-0800 [-] New dlstatus: anza
2012-11-16 16:59:19-0800 [-] Build as site object:
2012-11-16 16:59:19-0800 [-] => OK
2012-11-16 16:59:19-0800 [-] Setup TCP port:
2012-11-16 16:59:19-0800 [-] twisted.web.server.Site starting on 7000
2012-11-16 16:59:19-0800 [-] Starting factory
2012-11-16 16:59:19-0800 [-] => OK
2012-11-16 16:59:19-0800 [-] Run reactor:
2012-11-16 16:59:19-0800 [-] Calling into c orbreap_timeout
2012-11-16 16:59:21-0800 [-] in reap_eb
2012-11-16 16:59:21-0800 [-] Calling into c orbreap_timeout
2012-11-16 16:59:23-0800 [-] in reap_eb
2012-11-16 16:59:23-0800 [-] Calling into c orbreap_timeout
2012-11-16 16:59:24-0800 [-] in reap_cb
DEBUG:root:orbreap packet #1: 472 bytes
DEBUG:root:calling stock.pfget(packet.pfptr, '')
2012-11-16 16:59:24-0800 [-] in reap_eb
2012-11-16 16:59:24-0800 [-] Unhandled error in Deferred:
2012-11-16 16:59:24-0800 [-] Unhandled Error
Traceback (most recent call last):
File "/opt/antelope/python2.7.2-64/lib/python2.7/site-packages/twisted/internet/base.py", line 1167, in mainLoop
self.runUntilCurrent()
File "/opt/antelope/python2.7.2-64/lib/python2.7/site-packages/twisted/internet/base.py", line 762, in runUntilCurrent
f(*a, **kw)
File "/opt/antelope/python2.7.2-64/lib/python2.7/site-packages/twisted/internet/defer.py", line 361, in callback
self._startRunCallbacks(result)
File "/opt/antelope/python2.7.2-64/lib/python2.7/site-packages/twisted/internet/defer.py", line 455, in _startRunCallbacks
self._runCallbacks()
--- ---
File "/opt/antelope/python2.7.2-64/lib/python2.7/site-packages/twisted/internet/defer.py", line 542, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/export/home/webapps/webdlmon-backend/dlstatus.py", line 77, in reap_cb
sink(pfdict)
File "/export/home/webapps/webdlmon-backend/dlstatus.py", line 103, in update_status
pfdict = self.pfmorph(pfdict)
File "/export/home/webapps/webdlmon-backend/dlstatus.py", line 131, in pfmorph
if dls[sta]['opt'] is not None and dls[sta]['opt'] != "-":
exceptions.KeyError: 'opt'