py-junos-eznc icon indicating copy to clipboard operation
py-junos-eznc copied to clipboard

passing 'sleep' arg to StartShell run() results in NameError exception due to missing import of 'time'

Open ipmonk opened this issue 2 years ago • 1 comments

PyEZ version 2.6.5

#!/usr/bin/env python3
from jnpr.junos import Device
from jnpr.junos.utils.start_shell import StartShell

def try_run():
    dev = Device("foobar", user="foo", passwd="bar",port=22)
    with StartShell(dev) as ss:
        result = ss.run("hostname", sleep=2)
        print(result)
if __name__ == "__main__":
    try_run()

// result

Traceback (most recent call last):
  File "repro.py", line 26, in <module>
    try_run()
  File "repro.py", line 23, in try_run
    result = ss.run("hostname", sleep=2)
  File "/Users/foobar/scripts/pyez_test_scripts/venv/lib/python3.6/site-packages/jnpr/junos/utils/start_shell.py", line 195, in run
    got = "".join(self.wait_for(this, timeout, sleep=sleep))
  File "/Users/foobar/scripts/pyez_test_scripts/venv/lib/python3.6/site-packages/jnpr/junos/utils/start_shell.py", line 88, in wait_for
    time.sleep(sleep)
NameError: name 'time' is not defined

ipmonk avatar Aug 26 '22 06:08 ipmonk

fix is under review - https://github.com/Juniper/py-junos-eznc/pull/1205

chidanandpujar avatar Aug 30 '22 07:08 chidanandpujar

fixed https://github.com/Juniper/py-junos-eznc/pull/1205

chidanandpujar avatar Oct 17 '22 06:10 chidanandpujar