Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.69 KB | None | 0 0
  1.     def loadModule(self, modName, **userCtx):
  2.         for mibSource in self.__mibSources:
  3.             debug.logger & debug.flagBld and debug.logger('loadModule: trying %s at %s' % (modName, mibSource))
  4.             try:
  5.                 modData, sfx = mibSource.read(modName)
  6.             except IOError:
  7.                 debug.logger & debug.flagBld and debug.logger(
  8.                     'loadModule: read %s from %s failed: %s' % (modName, mibSource, sys.exc_info()[1]))
  9.                 continue
  10.  
  11.             modPath = mibSource.fullPath(modName, sfx)
  12.  
  13.             if modPath in self.__modPathsSeen:
  14.                 debug.logger & debug.flagBld and debug.logger('loadModule: seen %s' % modPath)
  15.                 break
  16.             else:
  17.                 self.__modPathsSeen[modPath] = 1
  18.  
  19.             debug.logger & debug.flagBld and debug.logger('loadModule: evaluating %s' % modPath)
  20.  
  21.             g = {'mibBuilder': self, 'userCtx': userCtx}
  22.  
  23.             try:
  24.                 exec (modData, g)
  25.  
  26.             except Exception:
  27.                 del self.__modPathsSeen[modPath]
  28.                 raise error.MibLoadError(
  29.                     'MIB module \"%s\" load error: %s' % (modPath, traceback.format_exception(*sys.exc_info()))
  30.                 )
  31.  
  32.             self.__modSeen[modName] = modPath
  33.  
  34.             debug.logger & debug.flagBld and debug.logger('loadModule: loaded %s' % modPath)
  35.  
  36.             break
  37.  
  38.         if modName not in self.__modSeen:
  39.             raise error.MibNotFoundError(
  40.                 'MIB file \"%s\" not found in search path (%s)' % (
  41.                     modName and modName + ".py[co]", ', '.join([str(x) for x in self.__mibSources]))
  42.             )
  43.  
  44.         return self
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement