Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It has crashed since the "oid" AttributeError: 'str' object has no attribute 'prettyPrint' #158

Open
Joan00 opened this issue Jun 12, 2018 · 1 comment

Comments

@Joan00
Copy link

Joan00 commented Jun 12, 2018

Code references example "Listen for notifications at IPv4 & IPv6 interfaces" as:
http://snmplabs.com/pysnmp/examples/v1arch/asyncore/manager/ntfrcv/transport-tweaks.html
+++
if reqPDU.isSameTypeWith(pMod.TrapPDU()):
if msgVer == api.protoVersion1:

            varBinds = pMod.apiTrapPDU.getVarBindList(reqPDU)
        else:
            varBinds = pMod.apiPDU.getVarBindList(reqPDU)
        
        for oid, val in varBinds:
            
            info_oid = oid.prettyPrint()

+++

error occurred:
++++
Exception in thread t1:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:/SPLXAuto_Dev/SPLXAuto/SPLXTestResource/Script/python/splx_snmp.py", line 28, in run
transportDispatcher.runDispatcher()
File "C:\Python27\lib\site-packages\pysnmp-4.2.5-py2.7.egg\pysnmp\carrier\asynsock\dispatch.py", line 41, in runDispatcher
raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())))
PySnmpError: poll error: Traceback (most recent call last):
; File "C:\Python27\lib\site-packages\pysnmp-4.2.5-py2.7.egg\pysnmp\carrier\asynsock\dispatch.py", line 37, in runDispatcher
use_poll=True, map=self.__sockMap, count=1)
; File "C:\Python27\lib\asyncore.py", line 220, in loop
poll_fun(timeout, map)
; File "C:\Python27\lib\asyncore.py", line 156, in poll
read(obj)
; File "C:\Python27\lib\asyncore.py", line 87, in read
obj.handle_error()
; File "C:\Python27\lib\asyncore.py", line 83, in read
obj.handle_read_event()
; File "C:\Python27\lib\asyncore.py", line 449, in handle_read_event
self.handle_read()
; File "C:\Python27\lib\site-packages\pysnmp-4.2.5-py2.7.egg\pysnmp\carrier\asynsock\dgram\base.py", line 83, in handle_read
self._cbFun(self, transportAddress, incomingMessage)
; File "C:\Python27\lib\site-packages\pysnmp-4.2.5-py2.7.egg\pysnmp\carrier\base.py", line 52, in _cbFun
self, transportDomain, transportAddress, incomingMessage
; File "C:/SPLXAuto_Dev/SPLXAuto/SPLXTestResource/Script/python/splx_snmp.py", line 69, in cbFun
info_oid = oid.prettyPrint()
;AttributeError: 'str' object has no attribute 'prettyPrint'
++++

pysnmp version: 4.2.5
Any suggestion to fix this error?

@etingof
Copy link
Owner

etingof commented Jul 3, 2018

Could you please paste more of your code? From the snippet you've posted it's not clear what is happening here...

It seems that the oid variable turns from ASN.1 object into Python string at some point in your script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants