Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def loadModule(self, modName, **userCtx):
- for mibSource in self.__mibSources:
- debug.logger & debug.flagBld and debug.logger('loadModule: trying %s at %s' % (modName, mibSource))
- try:
- modData, sfx = mibSource.read(modName)
- except IOError:
- debug.logger & debug.flagBld and debug.logger(
- 'loadModule: read %s from %s failed: %s' % (modName, mibSource, sys.exc_info()[1]))
- continue
- modPath = mibSource.fullPath(modName, sfx)
- if modPath in self.__modPathsSeen:
- debug.logger & debug.flagBld and debug.logger('loadModule: seen %s' % modPath)
- break
- else:
- self.__modPathsSeen[modPath] = 1
- debug.logger & debug.flagBld and debug.logger('loadModule: evaluating %s' % modPath)
- g = {'mibBuilder': self, 'userCtx': userCtx}
- try:
- exec (modData, g)
- except Exception:
- del self.__modPathsSeen[modPath]
- raise error.MibLoadError(
- 'MIB module \"%s\" load error: %s' % (modPath, traceback.format_exception(*sys.exc_info()))
- )
- self.__modSeen[modName] = modPath
- debug.logger & debug.flagBld and debug.logger('loadModule: loaded %s' % modPath)
- break
- if modName not in self.__modSeen:
- raise error.MibNotFoundError(
- 'MIB file \"%s\" not found in search path (%s)' % (
- modName and modName + ".py[co]", ', '.join([str(x) for x in self.__mibSources]))
- )
- return self
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement