diff options
author | elie <elie> | 2010-12-13 15:26:22 +0000 |
---|---|---|
committer | elie <elie> | 2010-12-13 15:26:22 +0000 |
commit | 5c4be382dec6b7c777af2ac3e5902ae210da1ece (patch) | |
tree | 581d0ddc632aaafe6f62c6e3fbd930b8d8bc0995 /README | |
parent | 5131d20dc0c28cea05b32e9475666e7cbe3ef11d (diff) | |
download | pysnmp-5c4be382dec6b7c777af2ac3e5902ae210da1ece.tar.gz |
minor example improvement
Diffstat (limited to 'README')
-rw-r--r-- | README | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -20,7 +20,7 @@ FEATURES * IPv6 transport support * Python eggs and py2exe friendly * 100% Python, works with Python 1.5 though 2.x -* MT-safe +* MT-safe (only if run locally to a thread) Features, specific to SNMPv3 model include: @@ -66,18 +66,21 @@ userData = cmdgen.UsmUserData('test-user', 'authkey1', 'privkey1') targetAddr = cmdgen.UdpTransportTarget(('localhost', 161)) errorIndication, errorStatus, \ - errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( - userData, targetAddr, (('SNMPv2-MIB', 'sysDescr'), 0) + errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( + userData, targetAddr, (('SNMPv2-MIB', 'sysDescr'), 0) ) if errorIndication: # SNMP engine errors print errorIndication else: if errorStatus: # SNMP agent errors - print '%s at %s\n' % (errorStatus, varBinds[int(errorIndex)-1]) + print '%s at %s\n' % ( + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex)-1] or '?') + ) else: - for varBind in varBinds: # SNMP agent values - print '%s = %s' % varBind + for oid, val in varBinds: # SNMP agent values + print '%s = %s' % (oid.prettyPrint(), val.prettyPrint()) 8X---------------- cut here -------------------- |