pg_slythe

James William Pye pgsql at jwp.name
Fri May 12 18:32:05 UTC 2006


On Fri, May 12, 2006 at 07:12:57AM -0700, Adrian Klaver wrote:
> No I get the following.
> aklaver at tucker:~> python -c 'from os import getlogin; print getlogin()'
> Traceback (most recent call last):
>   File "<string>", line 1, in ?
> OSError: [Errno 2] No such file or directory

Yeah, seems like something is broken on your system. Does your distro do some
Python patching(or, perhaps, the lack thereof)? ie, os.getlogin() should work.

[yes, I am going to fix my code so it's not so breakable]

> > In any case, I think I'm going to change that default. If you sudo to
> > another user, os.getlogin() will return the user name that you logged in
> > as, which I don't think is actually desirable.
> Using os.environ['LOGNAME'] or pwd.getpwuid(os.getuid())[0]  does return the 
> correct username.

k, I think I'll take some more careful steps when identifying the default for the
user. I'll incorporate those in my default user detection. Thanks.

> I guess the question  is if I supply a username with the -U option why do the 
> defaults even come into play?

The option's default is set regardless; this is normal. And, AFAIK, I can't pass
a callable so that it would resolve the default when requested, so laziness here
would be difficult.

Patch to layout coming soon.


More information about the Python-general mailing list