Re: %SystemDrive%

2006-02-16 Thread Bryan Olson
Atanas Banov wrote: > Bryan Olson wrote: > >>To get it with the \, you might use: >> >> os.path.abspath(os.environ['SYSTEMDRIVE']) > > > wrong! > the result is incorrect if the current directory is different from the > root. Oops, sorry. I

Re: %SystemDrive%

2006-02-16 Thread Atanas Banov
Bryan Olson wrote: > To get it with the \, you might use: > > os.path.abspath(os.environ['SYSTEMDRIVE']) wrong! the result is incorrect if the current directory is different from the root. >>> os.chdir("c:\\winxp") >>> os.path.abspath(os.env

Re: %SystemDrive%

2006-02-15 Thread Bryan Olson
rtilley wrote: > Carsten Haese wrote: > >> Is there a reason why os.environ['SYSTEMDRIVE'] shouldn't work? > > I didn't know it was in os! It returns C: instead of C:\ like my method. > Other than that, it seems to do the trick. To get it with th

Re: %SystemDrive%

2006-02-15 Thread rtilley
Atanas Banov wrote: > using >os.chdir('/') >os.getcwd() > is plain wrong in Windows. > > what it does is change the current directory to root of the CURRENT > DRIVE (i.e. the drive of the directory where script was started from), > not the system drive. for example, if current directory wa

Re: %SystemDrive%

2006-02-15 Thread Atanas Banov
m drive is d:, this will return c:\ and not d:\. hence chdir doesnt do any good, you can do os.getcwd()[:3] with the same success. os.environ['SYSTEMDRIVE'] is the right way to go. btw it correctly returns just drive letter and colon, a drive name doesnt include [back]slash -- http://mai

Re: %SystemDrive%

2006-02-15 Thread Todd Whiteman
Another hack: drive = os.popen("echo %SYSTEMDRIVE%").readline().strip() rtilley wrote: > Is there a proper way to get this variable from Windows? I know it's in > the registry, but I'd rather not go there. I could not find a CSIDL > shell constant for it

Re: %SystemDrive%

2006-02-15 Thread rtilley
Carsten Haese wrote: > Is there a reason why os.environ['SYSTEMDRIVE'] shouldn't work? > > Hope this helps I didn't know it was in os! It returns C: instead of C:\ like my method. Other than that, it seems to do the trick. Thank you! Brad -- http://mail.pytho

Re: %SystemDrive%

2006-02-15 Thread Carsten Haese
On Wed, 2006-02-15 at 14:07, Todd Whiteman wrote: > Another hack: > drive = os.popen("echo %SYSTEMDRIVE%").readline().strip() > > rtilley wrote: > > Is there a proper way to get this variable from Windows? I know it's in > > the registry, but I'd r

%SystemDrive%

2006-02-15 Thread rtilley
Is there a proper way to get this variable from Windows? I know it's in the registry, but I'd rather not go there. I could not find a CSIDL shell constant for it either. I've been doing this: os.chdir('/') sys_drive = os.getcwd() print sys_drive C:\ This seems too much of a hack and maybe not 1