diff options
author | elie <elie> | 2012-06-25 23:48:37 +0000 |
---|---|---|
committer | elie <elie> | 2012-06-25 23:48:37 +0000 |
commit | 92841c8dff3611c9aefd6c69f86e496e438bcf3a (patch) | |
tree | 3d27aa2b15536932293c638227fe4c3f90229c3c /pysnmp/debug.py | |
parent | 91d3d54b53ec6c2089b03b279f39fd2505b2897b (diff) | |
download | pysnmp-git-92841c8dff3611c9aefd6c69f86e496e438bcf3a.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.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pysnmp/debug.py b/pysnmp/debug.py index 6500e2d6..ab826b9a 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)) ] + ) |