From 5c4be382dec6b7c777af2ac3e5902ae210da1ece Mon Sep 17 00:00:00 2001 From: elie Date: Mon, 13 Dec 2010 15:26:22 +0000 Subject: minor example improvement --- README | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'README') diff --git a/README b/README index 5cf6a57..e989a08 100644 --- a/README +++ b/README @@ -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 -------------------- -- cgit v1.2.1