-
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
I'd like to suggest a change to snmpwalk.py to allow it to be used from other programs.
I propose putting everything from snmpEngine = engine.SnmpEngine() to the end of the program in a function called "run()".
e.g.
def run(arg_vector):
snmpEngine = engine.SnmpEngine()
ctx = {}
try:
# Parse c/l into AST
ast = Parser().parse(
Scanner().tokenize(' '.join(arg_vector))
)
main.generator((snmpEngine, ctx), ast)
# etc....
then, at the end,
if __name__ == '__main__':
run(sys.argv[1:])
this allows me to from snmpwalk.py import run in my own code, and use it,
I don't have to make my python code run a subshell to run your python code :-)
e.g.
from snmpwalk import run
run('-v3', '-l', 'authPriv', '-u', 'myuser',
'-a', 'SHA', '-A', 'apasswd12345', '-x', 'AES', '-X', 'prvpass12345',
'127.0.0.1', '.1.3.6.1.2.1.2.2.1.2'])
teeks99
Metadata
Metadata
Assignees
Labels
No labels