jshardlow
2012-10-29 15:52:47 UTC
jshardlow [http://community.zenoss.org/people/jshardlow] created the discussion
"Testing for Event Class Key in transform"
To view the discussion, visit: http://community.zenoss.org/message/69604#69604
--------------------------------------------------------------
Hi,
I'm after a bit of help with my Python in testing if an event has an Event Class Key via a defaultmapping (long story). Basically my snippet of code used to work in 2.5.2 (Python 2.4.3), but in 4 (Python 2.6.6) it doesn't with rather disasterous effects.
# In case there is no Event Class Key
try:
 evt.eventClassKey
except Exception:
 eck = 'UNKNOWN'
else:
 eck = evt.eventClassKey
...
if ( "gtr" in eck ) or ( "GTR" in eck ) or ( "exp" in evt.device ):
The problem I have is that sometimes an event comes in with no Event Class Key, the exception doesn't get it and the transform bombs out at the if statement. This in turn throws out thousands of errors:
zeneventd.log:
2012-10-29 15:44:23,119 WARNING zen.Events: Error processing transform/mapping on Event Class /instances/DEFAULTMAPPING
And from the actual event that appears thousands of times:
messageProblem with line 28: if ( "gtr" in eck ) or ( "GTR" in eck ) or ( "exp" in evt.device ):
exceptionTypeError: argument of type 'NoneType' is not iterable
Can anyone help point me in the right direction on how to deal with this? Should I be using exception AttributeError or exception TypeError or even something else? Thanks in advance!
--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69604#69604]
Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
"Testing for Event Class Key in transform"
To view the discussion, visit: http://community.zenoss.org/message/69604#69604
--------------------------------------------------------------
Hi,
I'm after a bit of help with my Python in testing if an event has an Event Class Key via a defaultmapping (long story). Basically my snippet of code used to work in 2.5.2 (Python 2.4.3), but in 4 (Python 2.6.6) it doesn't with rather disasterous effects.
# In case there is no Event Class Key
try:
 evt.eventClassKey
except Exception:
 eck = 'UNKNOWN'
else:
 eck = evt.eventClassKey
...
if ( "gtr" in eck ) or ( "GTR" in eck ) or ( "exp" in evt.device ):
The problem I have is that sometimes an event comes in with no Event Class Key, the exception doesn't get it and the transform bombs out at the if statement. This in turn throws out thousands of errors:
zeneventd.log:
2012-10-29 15:44:23,119 WARNING zen.Events: Error processing transform/mapping on Event Class /instances/DEFAULTMAPPING
And from the actual event that appears thousands of times:
messageProblem with line 28: if ( "gtr" in eck ) or ( "GTR" in eck ) or ( "exp" in evt.device ):
exceptionTypeError: argument of type 'NoneType' is not iterable
Can anyone help point me in the right direction on how to deal with this? Should I be using exception AttributeError or exception TypeError or even something else? Thanks in advance!
--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69604#69604]
Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]