diff options
author | Ilya Etingof <etingof@gmail.com> | 2016-07-03 10:28:12 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2016-07-03 10:28:12 +0200 |
commit | 9b43cb8cf32f896b0cffd368f8b2b3cb5aefadd7 (patch) | |
tree | a6ae1c12d8d65126cd36b553bd5a20539509c8f8 /pysnmp/smi/builder.py | |
parent | 960e39c6770aa1be50f07d2920592d166d2dabcf (diff) | |
download | pysnmp-git-9b43cb8cf32f896b0cffd368f8b2b3cb5aefadd7.tar.gz |
fix to pythonnized MIB loading when only .pyc files are present
Diffstat (limited to 'pysnmp/smi/builder.py')
-rw-r--r-- | pysnmp/smi/builder.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/pysnmp/smi/builder.py b/pysnmp/smi/builder.py index bee2bcfc..abee7ccf 100644 --- a/pysnmp/smi/builder.py +++ b/pysnmp/smi/builder.py @@ -72,13 +72,17 @@ class __AbstractMibSource(object): return self._listdir() def read(self, f): + pycTime = pyTime = -1 + for pycSfx, pycSfxLen, pycMode in self.__sfx[imp.PY_COMPILED]: try: pycData = self._getData(f + pycSfx, pycMode) except IOError: why = sys.exc_info()[1] - if why.errno == ENOENT or ENOENT == -1: - pycTime = -1 + if ENOENT == -1 or why.errno == ENOENT: + debug.logger & debug.flagBld and debug.logger( + 'file %s access error: %s' % (f + pycSfx, why) + ) else: raise error.MibLoadError('MIB file %s access error: %s' % (f + pycSfx, why)) else: @@ -86,35 +90,32 @@ class __AbstractMibSource(object): pycData = pycData[4:] pycTime = struct.unpack('<L', pycData[:4])[0] pycData = pycData[4:] + debug.logger & debug.flagBld and debug.logger( + 'file %s mtime %d' % (f + pycSfx, pycTime) + ) break else: debug.logger & debug.flagBld and debug.logger( 'bad magic in %s' % (f + pycSfx,) ) - pycTime = -1 - - # noinspection PyUnboundLocalVariable - debug.logger & debug.flagBld and debug.logger( - 'file %s mtime %d' % (f + pycSfx, pycTime) - ) for pySfx, pySfxLen, pyMode in self.__sfx[imp.PY_SOURCE]: try: pyTime = self._getTimestamp(f + pySfx) except IOError: why = sys.exc_info()[1] - if why.errno == ENOENT or ENOENT == -1: - pyTime = -1 + if ENOENT == -1 or why.errno == ENOENT: + debug.logger & debug.flagBld and debug.logger( + 'file %s access error: %s' % (f + pySfx, why) + ) else: raise error.MibLoadError('MIB file %s access error: %s' % (f + pySfx, why)) else: + debug.logger & debug.flagBld and debug.logger( + 'file %s mtime %d' % (f + pySfx, pyTime) + ) break - # noinspection PyUnboundLocalVariable - debug.logger & debug.flagBld and debug.logger( - 'file %s mtime %d' % (f + pySfx, pyTime) - ) - if pycTime != -1 and pycTime >= pyTime: # noinspection PyUnboundLocalVariable return marshal.loads(pycData), pycSfx |