Skip to content

Commit

Permalink
Release 0.6.3
Browse files Browse the repository at this point in the history
Also bump pysmi requirement due to latest fixes
  • Loading branch information
etingof committed Apr 14, 2019
1 parent a7b499d commit 5d4378a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 36 deletions.
5 changes: 4 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

Revision 0.6.3, released XX-12-2018
Revision 0.6.3, released 14-04-2019
-----------------------------------

- Upper constraint pysnmp to 5.0.0 in setup.py as well
- Upper constraint pysmi to 0.4.0 and lower constraint it to 0.3.4+
- Fixed broken -M and -P options to make non-default MIB paths
operational

Revision 0.6.2, released 30-12-2018
-----------------------------------
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pysmi>=0.3.4,<0.4.0
pysnmp>=4.4.4,<5.0.0
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def howto_install_setuptools():
from setuptools import setup

params = {
'install_requires': ['pysnmp>=4.4.4,<5.0.0'],
'install_requires': ['pysmi>=0.3.4,<0.4.0',
'pysnmp>=4.4.4,<5.0.0'],
'zip_safe': True
}

Expand All @@ -75,7 +76,8 @@ def howto_install_setuptools():
params = {}

if sys.version_info[:2] > (2, 4):
params['requires'] = ['pysnmp(>=4.4.4,<5.0.0)']
params['requires'] = ['pysmi(>=0.3.4,<0.4.0)',
'pysnmp(>=4.4.4,<5.0.0)']

doclines = [x.strip() for x in (__doc__ or '').split('\n') if x]

Expand Down
76 changes: 43 additions & 33 deletions snmpclitools/cli/mibview.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ def getUsage():
return """\
MIB options:
-m MIB[:...] load given list of MIBs (ALL loads all compiled MIBs)
-M DIR[:...] look in given list of directories for MIBs
-P MIBOPTS Toggle various defaults controlling MIB parsing:
XS: search for ASN.1 MIBs in remote directories specified
in URL form. The @mib@ token in the URL is substituted
with actual MIB to be downloaded. Default repository
address is %s
XB: search for pysnmp MIBs in remote directories specified
in URL form. The @mib@ token in the URL is substituted
with actual MIB to be downloaded. Default repository
address is %s
-M DIR[:...] look in given list of directories (not URLs) for MIBs
-P MIBOPTS Toggle various defaults controlling MIB compiler:
XS: search for ASN.1 MIBs in local and/or remote directories
specified in URL form. The @mib@ token in the URL is
substituted by the actual MIB name to be downloaded.
Default repository address is
%s
XB: search for compiled pysnmp (*.py) MIBs in local and/or
remote directories specified in URL form (e.g.
file:///pymibs/@mib@). The @mib@ token in the URL is
substituted by the actual MIB name to be downloaded.
Default repository address is
%s
-O OUTOPTS Toggle various defaults controlling output display:
q: removes the equal sign and type information
Q: removes the type information
Expand Down Expand Up @@ -101,8 +104,6 @@ def p_mibView(self, args):
MibFiles ::= MibFile
MibFile ::= string
ParserOption ::= parseropts string
ParserOption ::= parseropts whitespace string
ParserOption ::= parseropts string whitespace Url
ParserOption ::= parseropts whitespace string whitespace Url
Url ::= string semicolon string
Expand All @@ -121,11 +122,9 @@ class __MibViewGenerator(base.GeneratorTemplate):
# Load MIB modules
def n_MibFile(self, cbCtx, node):
snmpEngine, ctx = cbCtx
mibBuilder = snmpEngine.getMibBuilder()
if node[0].attr.lower() == 'all':
mibBuilder.loadModules()
else:
mibBuilder.loadModules(node[0].attr)
if 'MibFiles' not in ctx:
ctx['MibFiles'] = []
ctx['MibFiles'].append(node[0].attr)

def n_MibDir(self, cbCtx, node):
snmpEngine, ctx = cbCtx
Expand All @@ -140,21 +139,22 @@ def n_Url(self, cbCtx, node):
def n_ParserOption_exit(self, cbCtx, node):
snmpEngine, ctx = cbCtx
opt = node[1].attr or node[2].attr
for c in opt:
if c == 'XS':
if 'MibDir' not in ctx:
ctx['MibDir'] = []
if 'Url' not in ctx:
raise error.PySnmpError('Missing URL for option')
ctx['MibDir'].append(ctx['Url'])
del ctx['Url']
elif c == 'XB':
if 'MibBorrowers' not in ctx:
ctx['MibBorrowers'] = []
if 'Url' not in ctx:
raise error.PySnmpError('Missing URL for option')
ctx['MibBorrowers'].append(ctx['Url'])
del ctx['Url']
if opt == 'XS':
if 'MibDir' not in ctx:
ctx['MibDir'] = []
if 'Url' not in ctx:
raise error.PySnmpError('Missing URL for option')
ctx['MibDir'].append(ctx['Url'])
del ctx['Url']
elif opt == 'XB':
if 'MibBorrowers' not in ctx:
ctx['MibBorrowers'] = []
if 'Url' not in ctx:
raise error.PySnmpError('Missing URL for option')
ctx['MibBorrowers'].append(ctx['Url'])
del ctx['Url']
else:
raise error.PySnmpError('bad -P option arguments: %s' % opt)

def n_OutputOption(self, cbCtx, node):
snmpEngine, ctx = cbCtx
Expand Down Expand Up @@ -233,7 +233,7 @@ def generator(cbCtx, ast):
if 'mibViewProxy' not in ctx:
ctx['mibViewProxy'] = MibViewProxy(ctx['mibViewController'])

compiler.addMibCompiler(snmpEngine.getMibBuilder())
# compiler.addMibCompiler(snmpEngine.getMibBuilder())

snmpEngine, ctx = __MibViewGenerator().preorder((snmpEngine, ctx), ast)

Expand All @@ -245,6 +245,16 @@ def generator(cbCtx, ast):
compiler.addMibCompiler(snmpEngine.getMibBuilder(),
sources=ctx['MibDir'],
borrowers=ctx['MibBorrowers'])

if 'MibFiles' in ctx:
mibBuilder = snmpEngine.getMibBuilder()

for mibFile in ctx['MibFiles']:
if mibFile.lower() == 'all':
mibBuilder.loadModules()
else:
mibBuilder.loadModules(mibFile)

return snmpEngine, ctx


Expand Down

0 comments on commit 5d4378a

Please sign in to comment.