[Tutor] CD ROM Drive
Tim Golden
mail at timgolden.me.uk
Wed Jul 16 14:09:06 CEST 2008
Neven Goršić wrote:
> That is OK. But when I run program with that single command
> from Windows Explorer I get Windows alert Window:
>
> "No disk! Please insert a disk into drive F:"
>
> That alert stops program and I must respond with: Cancel, Try again or Continue.
> The alert remains even with try, except(WindowsError)
>
> Interesting point is that that alert doesn't pop up before I open DVD
> for the first time.
> After first inserting and ejecting DVD media alert is here!
>
> It seems that information that is DVD no longer avilable is not
> updated accordingly.
>
> How can I avoid that?
Ah. Sorry. I just re-read your question. I think you can do what
you want by querying the .MediaLoaded attribute of the
Win32_CDROMDrive WMI class.
<code>
import wmi
c = wmi.WMI ()
for cdrom in c.Win32_CDROMDrive ():
print "Drive", cdrom.Drive, "is loaded" if cdrom.MediaLoaded else "is empty"
</code>
TJG
More information about the Tutor
mailing list