tags:

views:

58

answers:

1

I'm trying to find an equivalent Python function to the Windows function DriveInfo.IsReady. I've spent a while searching through the functions provided by win32api and win32file but I can't find anything (though perhaps that's because I didn't manage to find much useful documentation online, so was simply searching through the listing of functions).

Any help would be gratefully received.

+1  A: 

I've used GetVolumeInformation in the past to determine this. For example, something like:

def is_drive_ready(drive_name):
    try:
        win32api.GetVolumeInformation(drive_name)
        return True
    except:
        return False

print 'ready:', is_drive_ready('c:\\') # true
print 'ready:', is_drive_ready('d:\\') # false (on my system)

You'll need the win32api module.

ars