On 14 Jan 2006 16:52:33 -0800, "Claude Henchoz" <[EMAIL PROTECTED]> wrote:

>Hi
>
>Is there any way of listing partitions on a (win32) computer without
>using WMI?
>
Maybe this will work (I skipped A: and B:, but you can include them if
you want to catch floppy drives with something in them). The 'xxx' is just so as
not to get a full directory's worth of useless text. If xxx happens to be 
defined
it doesn't hurt anything. It's not going to be as fast as using one of the
win32 api packages to get at GetLogicalDriveStrings, but this works on my NT4:
(error messages apparently go to stderr, so stdout gets '' which makes the if 
fail)

 >>> def fakeGetLogicalDriveStrings():
 ...     return [c+':' for c in (chr(n) for n in xrange(ord('A'), ord('Z')+1))
 ...                   if os.popen('dir %s:\\xxx'%c).read()]
 ...
 >>> fakeGetLogicalDriveStrings()
 ['C:', 'D:', 'E:', 'V:', 'W:']

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to