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 should know better than to code from what I think 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.environ['SYSTEMDRIVE']) 'c:\\winxp' if you really wan

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 the \, you might use: os.path.abspath(os.envi

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
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 was c:\myscripts and system drive is d

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 either. I've been doing this: > > os.chdi

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.python.org/mailman/listinfo/python-lis

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 rather not go there. I could not find a CSIDL > >