Skip to content
Browse files

Added simple WMI example for detecting Windows drive changes

  • Loading branch information...
1 parent d4eec90 commit 0dc11cdeddaebd44cbcc3feaffa0b3beafcfda36 T. Jameson Little committed Feb 5, 2013
Showing with 14 additions and 0 deletions.
  1. +14 −0 detector.py
View
14 detector.py
@@ -0,0 +1,14 @@
+import wmi
+import signal
+
+# fixes problems with Ctrl+C on Windows
+signal.signal(signal.SIGINT, signal.SIG_DFL)
+
+c = wmi.WMI()
+w = c.Win32_CDROMDrive.watch_for()
+while True:
+ e = w()
+ if e.MediaLoaded:
+ print("CD inserted: %s, %s" % (e.Drive, e.VolumeName))
+ else:
+ print("CD removed: %s" % e.Drive)

0 comments on commit 0dc11cd

Please sign in to comment.
Something went wrong with that request. Please try again.