diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-02-27 07:44:31 +0100 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-02-27 07:44:31 +0100 |
commit | 5a1cb3ff2851018d7569008d4055eb5204b08cb7 (patch) | |
tree | deae68be798b2515671e345cd16a00d6248a7719 | |
parent | 7c71fc46d4b949bdbfd425f75d3ef667df96846d (diff) | |
download | pysnmp-git-5a1cb3ff2851018d7569008d4055eb5204b08cb7.tar.gz |
Fix `MibBuilder.loadModules()` no respect missing MIB failure
Missing MIB condition has been ignored if MIB compiler is not
configured.
-rw-r--r-- | pysnmp/smi/builder.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/pysnmp/smi/builder.py b/pysnmp/smi/builder.py index 513bc19a..e2d8d42f 100644 --- a/pysnmp/smi/builder.py +++ b/pysnmp/smi/builder.py @@ -419,23 +419,25 @@ class MibBuilder(object): self.loadModule(modName, **userCtx) except error.MibNotFoundError: - if self._mibCompiler: - debug.logger & debug.FLAG_BLD and debug.logger( - 'loadModules: calling MIB compiler for %s' % modName) + if not self._mibCompiler: + raise + + debug.logger & debug.FLAG_BLD and debug.logger( + 'loadModules: calling MIB compiler for %s' % modName) - status = self._mibCompiler.compile(modName, genTexts=self.loadTexts) + status = self._mibCompiler.compile(modName, genTexts=self.loadTexts) - errs = '; '.join( - hasattr(x, 'error') and str(x.error) or x - for x in status.values() - if x in ('failed', 'missing')) + errs = '; '.join( + hasattr(x, 'error') and str(x.error) or x + for x in status.values() + if x in ('failed', 'missing')) - if errs: - raise error.MibNotFoundError( - '%s compilation error(s): %s' % (modName, errs)) + if errs: + raise error.MibNotFoundError( + '%s compilation error(s): %s' % (modName, errs)) - # compilation succeeded, MIB might load now - self.loadModule(modName, **userCtx) + # compilation succeeded, MIB might load now + self.loadModule(modName, **userCtx) return self |