summaryrefslogtreecommitdiff
path: root/pysnmp/debug.py
diff options
context:
space:
mode:
authorelie <elie>2012-06-25 23:48:37 +0000
committerelie <elie>2012-06-25 23:48:37 +0000
commit9ad964b2c60a7a0e1b81249f18c19e952c4b0d27 (patch)
treef70706397c5e63760d976642b5c0f59563fbe2bf /pysnmp/debug.py
parent0ef890c612ca5b04dd737ea5d9fa94d7c564e5c0 (diff)
downloadpysnmp-9ad964b2c60a7a0e1b81249f18c19e952c4b0d27.tar.gz
hex dumps of binary parts of the protocol added to ease system
operations analysis.
Diffstat (limited to 'pysnmp/debug.py')
-rw-r--r--pysnmp/debug.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/pysnmp/debug.py b/pysnmp/debug.py
index 6500e2d..ab826b9 100644
--- a/pysnmp/debug.py
+++ b/pysnmp/debug.py
@@ -1,4 +1,5 @@
import sys
+from pyasn1.compat.octets import octs2ints
from pysnmp import error
flagNone = 0x0000
@@ -58,3 +59,9 @@ logger = 0
def setLogger(l):
global logger
logger = l
+
+def hexdump(octets):
+ return ' '.join(
+ [ '%s%.2X' % (n%16 == 0 and ('\n%.5d: ' % n) or '', x)
+ for n,x in zip(range(len(octets)), octs2ints(octets)) ]
+ )