Jack Atkinson added the comment:
Error message from ipython console:
In [28]: mibBuilder2 = builder.MibBuilder().loadModules('ADTRAN-TC')
---
Traceback (most recent call last)
C:\Documents and Settings\Jack Atkinson\ in ()
c:\python25\lib\site-packages\pysnmp\v4\smi\builder.py in
loadModules(self, *mod
Names)
80 del self.__modPathsSeen[modPath]
81 raise error.SmiError(
---> 82 'MIB module \"%s\" load error: %s' %
(modPath, why)
83 )
84
: MIB module
"c:\python25\lib\site-packages\p
ysnmp\v4\smi\mibs\ADTRAN-TC.py" load error: more than 255 arguments
(ADTRAN-TC.p
y, line 33)
Here's the code that loads it:
try:
execfile(modPath, g)
except StandardError,
why: del self.__modPathsSeen[modPath]
raise error.SmiError( 'MIB module \"%s\" load error: %s' % (modPath, why) )
Added file: http://bugs.python.org/file8968/builder.py
__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1636>
__# MIB modules loader
import os
from pysnmp.smi import error
try:
import pysnmp_mibs
except ImportError:
pysnmp_mibs = None
from pysnmp import debug
class MibBuilder:
def __init__(self):
self.lastBuildId = self._autoName = 0L
paths = (
os.path.join(os.path.split(error.__file__)[0], 'mibs','instances'),
os.path.join(os.path.split(error.__file__)[0], 'mibs')
)
if os.environ.has_key('PYSNMP_MIB_DIR'):
paths = paths + (
os.path.join(os.path.split(os.environ['PYSNMP_MIB_DIR'])[0]),
)
if pysnmp_mibs:
paths = paths + (
os.path.join(os.path.split(pysnmp_mibs.__file__)[0]),
)
self.mibSymbols = {}
self.__modSeen = {}
self.__modPathsSeen = {}
apply(self.setMibPath, paths)
# MIB modules management
def setMibPath(self, *mibPaths):
self.__mibPaths = map(os.path.normpath, mibPaths)
debug.logger & debug.flagBld and debug.logger('setMibPath: new MIB path
%s' % (self.__mibPaths,))
def getMibPath(self): return tuple(self.__mibPaths)
def loadModules(self, *modNames):
# Build a list of available modules
if not modNames:
modNames = {}
for mibPath in self.__mibPaths:
try:
for modName in os.listdir(mibPath):
if modName == '__init__.py' or modName[-3:] != '.py':
continue
modNames[modName[:-3]] = None
except OSError:
continue
modNames = modNames.keys()
if not modNames:
raise error.SmiError(
'No MIB module to load at %s' % (self,)
)
for modName in modNames:
for mibPath in self.__mibPaths:
modPath = os.path.join(
mibPath, modName + '.py'
)
debug.logger & debug.flagBld and debug.logger('loadModules:
trying %s' % modPath)
try:
open(modPath).close()
except IOError, why:
debug.logger & debug.flagBld and debug.logger('loadModules:
open() %s' % why)
continue
if self.__modPathsSeen.has_key(modPath):
debug.logger & debug.flagBld and debug.logger('loadModules:
seen %s' % modPath)
continue
else:
self.__modPathsSeen[modPath] = 1
g = { 'mibBuilder': self }
try:
execfile(modPath, g)
except StandardError, why:
del self.__modPathsSeen[modPath]
raise error.SmiError(
'MIB module \"%s\" load error: %s' % (modPath, why)
)
self.__modSeen[modName] = modPath
debug.logger & debug.flagBld and debug.logger('loadModules:
loaded %s' % modPath)
break
if not self.__modSeen.has_key(modName):
raise error.SmiError(
'MIB file \"%s.py\" not found in search path' % modName
)
return self
def unloadModules(self, *modNames):
if not modNames:
modNames = self.mibSymbols.keys()
for modName in modNames:
if not self