detecting drives for windows and linux

Tim Golden tim.golden at viacom-outdoor.co.uk
Sat Mar 25 15:18:56 EST 2006


BWill wrote:
> Hi, I'm writing a file browser, but I'm not sure how I could go about
> detecting the drives available on windows and linux systems (preferably
> using the standard modules if possible). I guess I could just try to
> list root on each letter of the alphabet for windows and see if it
> works, but that seems crude; besides, I want to know what kind of drive
> each drive/partition is (i.e. is it local and is it a harddrive or
> optical drive).

I'm not aware of any cross-platform way of doing this.
On Windows you have a few options, but I'd go down
the WMI route; it just makes life easier for doing this
kind of thing. You might want to start by adapting this
example:

http://tgolden.sc.sabren.com/python/wmi_cookbook.html#percentage_free

by removing the restriction to fixed disk (DriveType=3)

TJG




More information about the Python-list mailing list