wxPython and disk drive letters

Is there a method in wxPython that returns a list of all disk drive letters under Windows?

All non-GUI capabilities generally concern Python, not wxPython.

import win32api

drives = win32api.GetLogicalDriveStrings()
drives = drives.split('\000')[:-1]
print drives

This is only one way. I'm sure MSW has a dozen more.

Another interesting question is: How can drives (formatted, mounted
partitions) be separated into hard drives, optical drives, Flash
drives, etc.

Ray

···

On Feb 19, 7:01 am, Boštjan Mejak <bostjan.me...@gmail.com> wrote:

Is there a method in wxPython that returns a list of all disk drive letters
under Windows?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is there a method in wxPython that returns a list of all disk drive
letters under Windows? --
To unsubscribe, send email to
wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

# Note this will only find drives that currently have media in
# WINDOWS like only
from os.path import exists
base = ord('A')
found =
for C in range(0,26):
    DL = chr(base+C)
    Path = ''.join([DL,':\\'])
    if exists(Path):
        found.append(Path)
print 'Drives Found', found

Gadget/Steve

···

On 19/02/2011 12:01 PM, Bo?tjan Mejak wrote:

...

Another interesting question is: How can drives (formatted, mounted
partitions) be separated into hard drives, optical drives, Flash
drives, etc.

win32file.GetDriveType(drive) returns the drive type, but, floppy disks and USB disk returns both as removable. Distinguish between them is more complicated. :frowning:

···

El 19/02/2011 17:45, Ray Pasco escribió:

--
Oswaldo Hernández

...

Another interesting question is: How can drives (formatted, mounted
partitions) be separated into hard drives, optical drives, Flash
drives, etc.

win32file.GetDriveType() returns the drive type, but, floppy disks and USB disk returns both as removable. Distinguish between them is more complicated. :frowning:

···

El 19/02/2011 17:45, Ray Pasco escribió:

--
Oswaldo Hernández

I like the idea of

import win32api
drives = win32api.GetLogicalDriveStrings()

which enables me the use of

if ‘C:\’ in drives:

# do something if 'C:\\' found

But the module win32api is not included with Python so I need something that is available via “batteries included”. Something Pythonic. Got any idea?

activestate’s build of python contains it, I haven’t used it, but it seems like it would your best bet.

···


Hi, I will kill all ads in google gmail.
They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!

Did you ment to say that ActivePython includes the win32api module?

It does indeed.

On Windows, I always prefer ActivePython.

···

On Sun, 20 Feb 2011, Bo?tjan Mejak wrote:

Did you ment to say that ActivePython includes the win32api module?

The "batteries included" is called ctypes.
Search: ctypes [and] windll.kernel32.GetLogicalDrives()

jmf

···

On Feb 19, 9:36 pm, Boštjan Mejak <bostjan.me...@gmail.com> wrote:

I like the idea of

import win32api
drives = win32api.GetLogicalDriveStrings()

which enables me the use of

if 'C:\\' in drives:
# do something if 'C:\\' found

But the module win32api is not included with Python so I need something that
is available via "batteries included". Something Pythonic. Got any idea?

Pick one, any one…

Ray Pasco

List_Disk_Drives_Demo.py (3.33 KB)

Drive_Stats_Demo.py (2.07 KB)

···

On Sat, Feb 19, 2011 at 7:01 AM, Boštjan Mejak bostjan.mejak@gmail.com wrote:

Is there a method in wxPython that returns a list of all disk drive letters under Windows?

I do too, as it sets the PATH variable correctly

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

···


Hi, I will kill all ads in google gmail.

They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!

Bo�tjan Mejak wrote:

I like the idea of

import win32api

      drives = win32api.GetLogicalDriveStrings()
      which enables me the

use of

if ‘C:\’ in drives:

      �� �# do something

if ‘C:\’ found

      But the module

win32api is not included with Python so I need something that
is available via “batteries included”. Something Pythonic. Got
any idea?

The whole "drive letter" concept is Windows-specific, and thus will

not be part of base Python.

In my view, a Windows Python implementation must always include

PyWin32.

···
-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com