py-junos-eznc: IO Exception Over Serial On Windows

I cannot get PyEZ to connect to my juniper switch on Windows using the serial port. For my application I cannot use SSH/telnet and I need it to work over the serial port.

On login I get an error in tty_netconf._receive() with the usage of select.

According to the official python docs the select operation is not supported on Windows for file objects (https://docs.python.org/3/library/select.html?highlight=select#select.select).

Is there something else than the select than can be used to wait on the IO under Windows ?

Thanks

Here is the command and the output with the error.

Using Windows 10 1809 Python 3.6.8 junos-eznc 2.2.1

To Replicate

import sys
import logging
import time
from jnpr.junos import Device
from jnpr.junos.utils.config import Config

logging.basicConfig(level=logging.DEBUG)

dev = Device(mode='serial', port='COM4', user='root', passwd=None)
dev.open()

Output

INFO:jnpr.junos.tty:TTY: connecting to TTY:COM4 ...
INFO:jnpr.junos.tty:TTY: OK.....starting NETCONF
WRITExml-mode netconf need-trailer
ERROR:jnpr.junos.console:Exception occurred: login:fileno

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\console.py", line 221, in open
    raise ex
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\console.py", line 211, in open
    self._tty_login()
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\console.py", line 316, in _tty_login
    self._tty.login()
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\transport\tty.py", line 115, in login
    self.nc.open(at_shell=self.at_shell)
  File "C:\Users\uesr\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 68, in open
    self.hello = self._receive()
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 142, in _receive
    raise err
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 140, in _receive
    rd, wt, err = select.select([self._tty._rx], [], [], 0.1)
io.UnsupportedOperation: fileno

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (12 by maintainers)

Most upvoted comments

console.log

@moophat How about going from 1 to 2. If 1 doesn’t work, I can work with remote access.

Hi @vnitinv , apolozies for the late reply, there was an power issue with our lab so I have to turn off some device during the weekends.

But good new is that the updated code seem to work, even when the console session was currently in a logged in prompt, which is great. I’ll need to test further functionality with the tableview retrieval and setting new configuration before confirming that everything work as expected. But for now thank you for the update

Attached is the log file (logging output is wrapped in my own custom log format handler ), the only time it produce an error is when another process has already occupied the COM port - which is totally expected and should not be considered a code error.