ELM-Python-Client icon indicating copy to clipboard operation
ELM-Python-Client copied to clipboard

Cannot use elmclient in Docker when no tty attached to stdin

Open wulmer opened this issue 1 year ago • 1 comments

Hi, we were trying to use the elmclient inside a Docker container, but it crashed on the first use of termios.tcgetattr, because there was no tty attached to stdin.

The error message shown is:

termios.error: (25, 'Inappropriate ioctl for device')

The error lies in the assumption that there is always a tty on stdin, so that you can check for key presses in https://github.com/IBM/ELM-Python-Client/blob/master/elmclient/oslcqueryapi.py#L682 .

You can reproduce the error by running the following command:

docker run --rm python:3 /bin/python3 -c 'import termios, sys; termios.tcgetattr(sys.stdin.fileno())'

This recreates exactly the case where the kbhit function crashes.

I'll submit a PR in a second.

wulmer avatar Aug 28 '24 14:08 wulmer

Hi Wolfgang

Thanks for your PR, that's a scenario I've never tried. And it's always nice to hear that elmclient is being used :-)

Your solution looks good, it will get accepted but could be a few weeks due to vacation.

Regards Ian

barny avatar Sep 02 '24 09:09 barny

it will get accepted but could be a few weeks due to vacation.

Hi Ian (@barny), the few weeks should be over by now, any chance to get the PR #69 merged? BTW: there is another PR #67 from me.

wulmer avatar Nov 18 '24 17:11 wulmer

Hi - I incorporated your changes, thanks!

barny avatar Dec 03 '24 12:12 barny