/usr/share/pyshared/pysnmp/debug.py is in python-pysnmp4 4.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import sys
from pysnmp import error
flagNone = 0x0000
flagIO = 0x0001
flagDsp = 0x0002
flagMP = 0x0004
flagSM = 0x0008
flagBld = 0x0010
flagMIB = 0x0020
flagIns = 0x0040
flagACL = 0x0080
flagPrx = 0x0100
flagApp = 0x0200
flagAll = 0xffff
flagMap = {
'io': flagIO,
'dsp': flagDsp,
'msgproc': flagMP,
'secmod': flagSM,
'mibbuild': flagBld,
'mibview': flagMIB,
'mibinstrum': flagIns,
'acl': flagACL,
'proxy': flagPrx,
'app': flagApp,
'all': flagAll
}
class Debug:
defaultPrinter = sys.stderr.write
def __init__(self, *flags):
self._flags = flagNone
self._printer = self.defaultPrinter
for f in flags:
if f not in flagMap:
raise error.PySnmpError('bad debug flag %s' % f)
self._flags = self._flags | flagMap[f]
self('debug category %s enabled' % f)
def __str__(self):
return 'logger %s, flags %x' % (self._printer, self._flags)
def __call__(self, msg):
self._printer('DBG: %s\n' % msg)
def __and__(self, flag):
return self._flags & flag
def __rand__(self, flag):
return flag & self._flags
# This will yield false from bitwise and with a flag, and save
# on unnecessary calls
logger = 0
def setLogger(l):
global logger
logger = l
|