Python Forum
How would I use Watchdog to get triggered when DVD is inserted?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How would I use Watchdog to get triggered when DVD is inserted?
#11
(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.
Reply
#12
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/
Daring_T likes this post
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#13
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Halting if command if gpio triggered event triggered knoxvilles_joker 7 885 Jun-21-2021, 01:27 AM
Last Post: knoxvilles_joker
  How to make input come after input if certain line inserted and if not runs OtherCode Adrian_L 6 1,079 Apr-04-2021, 06:10 PM
Last Post: Adrian_L
  Picture changing triggered by GPIO q_nerk 2 712 Dec-14-2020, 03:32 PM
Last Post: DeaD_EyE
  lxml - etree/lxml need help storing variable for most inserted element goeb 0 1,255 Apr-01-2019, 03:09 AM
Last Post: goeb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020