I 'm deploying a Python application to a Verdin IMX8MM using the VSC extension and I want to get some user input from the command line as part of the application but the input() function throws the EOFError exception. When I SSH to the host, enter the container and run the application it works fine. Is there a way to get it to work in VSC as well? I think this is because stdin is being redirected to a file instead of the terminal but I can’t figure out if there is a setting to fix it.
When we debug a Python (or C/C++) application with Torizon Extension, the console I/O is processed by the debugger and stdin is not accessible by default, and we don’t redirect it through docker.
Our suggestion is for you to read info from a regular file instead or, if you have a menu or something like this, expose it via socket for the testing.
I have attached here, it should work for Windows or Linux but I have not tried on Windows for a while. It has been working ok for me in debug mode on Torizon. Of course you don’t really need it in release builds as I can just attach to the running container from SSH but it does still work as well.
The print menu function I pass just prints some text. Socket will redirect stdio for you once someone connects on a raw 65432 port. And will return control when they disconnect. Only remaining todo is to add a timeout to detect a badly behaved disconnection. At the moment it just waits for ever.