John J. Lee
jjl at pobox.com
Thu Aug 14 14:05:21 CEST 2003
Syver Enstad <syver at inout.no> writes:
> cartermark46 at ukmail.com (Mark Carter) writes:
> > I am using Windows 98, python 2.3, ClientCookie 0.4.3a.
> > When I do:
> > import ClientCookie
> > import os
> > c = ClientCookie.MSIECookieJar(delayload=1)
> > c.load_from_registry()
> > I get the response:
> > KeyError: 'USERNAME'
> > Basically, it doesn't like USERNAME as an environment variable.
> I suspect this only works on "real" win32 (the NT family) operating
> systems, which define USERNAME, and not hybrid dos/win32 systems like
> the win9x family.
Anybody know the best way to get the username without win32all
Mark: I don't have a win9x box, but try replacing that
os.environ['USERNAME'] with getpass.getuser(). You'll need to stick
an import getpass in there too, of course. Let me know if that works.
The rest of the code should work OK on win9x.
More information about the Python-list