how to find the drive in python/cygwin?

Kristian Zoerhoff kristian.zoerhoff at gmail.com
Tue Apr 26 14:33:58 EDT 2005


On 26 Apr 2005 11:29:26 -0700, Mayer <gmayer at cs.bgu.ac.il> wrote:
> Hello:
> 
> I'm running python under cygwin and need to find the drive letter.
> Cygwin has a way of calling my drives by a name relative to the Cygwin
> directory, so I get things like /home/user rather than
> /cygdrive/g/cygwin/home/usr, etc. How can I find the letter of the
> drive, or in the above example, the letter 'g'?

Generally, drive N gets mapped to /cygdrive/n/ but you could call the
'mount' command and parse the output to see what drive letter got
assigned to a given path. On my system, mount returns:

$ mount
C:\cygwin\usr\X11R6\lib\X11\fonts on /usr/X11R6/lib/X11/fonts type
system (binmode)
C:\cygwin\bin on /usr/bin type system (binmode)
C:\cygwin\lib on /usr/lib type system (binmode)
C:\cygwin on / type system (binmode)
c: on /cygdrive/c type user (binmode,noumount)
d: on /cygdrive/d type user (binmode,noumount)
g: on /cygdrive/g type user (binmode,noumount)
x: on /cygdrive/x type user (binmode,noumount)
z: on /cygdrive/z type user (binmode,noumount)
 
> My program needs to run on an external media that comes with Cygwin on
> it. I have no control over what drive is assigned to that media, but
> for some reason, I do need to know the letter.

Why?

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org



More information about the Python-list mailing list