Python Forum
How would I use Watchdog to get triggered when DVD is inserted? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How would I use Watchdog to get triggered when DVD is inserted? (/thread-34619.html)

Pages: 1 2


RE: How would I use Watchdog to get triggered when DVD is inserted? - Daring_T - Aug-17-2021

(Aug-16-2021, 08:50 PM)deanhystad Wrote: Is the DVD going to show up as D: or does it show up in D:? If it shows up as D: I don't think you can use watchdog to see when a DVD is installed. Sure, you can keep trying to start the observer and it will fail until a DVD is installed, but you get the same info trying to read the D:\\ folder.

In a windows program you would use the RegisterDeviceNotification call. I don't know of any python wrapper library for this system call.

So Python does have ways to access dll functions with ctypes. I may just make a wrapper myself but will see. I might even write this trigger in C or C++ just to learn these languages. I do know I'm going to need a lot more research before I figure this one out.


RE: How would I use Watchdog to get triggered when DVD is inserted? - DeaD_EyE - Aug-17-2021

I think you can't use the Watchdog to observe media Changes.
Polling the directory the whole time is ineffective and if a CD is in your drive, it will always spin up during polling. This can be very annoying.

You have to use the win32 subsystem and a guy made already the work: https://abdus.dev/posts/python-monitor-usb/


RE: How would I use Watchdog to get triggered when DVD is inserted? - Daring_T - Aug-17-2021

(Aug-17-2021, 08:15 AM)DeaD_EyE Wrote: I think you can't use the Watchdog to observe media Changes.
Polling the directory the whole time is ineffective and if a CD is in your drive, it will always spin up during polling. This can be very annoying.

You have to use the win32 subsystem and a guy made already the work: https://abdus.dev/posts/python-monitor-usb/

Thank you DeaD_EyE, this should work very well for what I am trying to do. It's weird, he's already has written half the functions & classes I have already wrote.