What's the best way to invoke a method in a running Python 3 application when a USB input device is plugged in?
Asked
Active
Viewed 166 times
0
-
Probably depends on your operating system – Patrick Haugh Apr 15 '18 at 15:20
-
Linux and Windows 10. – Atalanttore Apr 15 '18 at 15:24
-
1See: https://stackoverflow.com/questions/4273252/detect-inserted-usb-on-windows – Patrick Haugh Apr 15 '18 at 15:24
-
Thanks for the link, but this seems to be for Windows only. Is there a more platform-independent way to do this? – Atalanttore Apr 15 '18 at 15:28
-
1One of the comments there includes a link to [How can I listen for USB device inserted events in Linux in Python?](https://stackoverflow.com/questions/469243/how-can-i-listen-for-usb-device-inserted-events-in-linux-in-python/471099#471099) – Patrick Haugh Apr 15 '18 at 15:29
-
Thanks again for the link, but this seems to be for Linux only. – Atalanttore Apr 15 '18 at 21:07
-
There isn't going to be a one-size fits all solution. You'll likely have to implement a different version for evey operating system you want to target, and then have the program select the correct one once it is running. Or write some installer that selects the correct implementation. – Patrick Haugh Apr 15 '18 at 21:17
-
That's a pity, but obviously necessary. Thanks! – Atalanttore Apr 16 '18 at 16:28