pg_slythe
Adrian Klaver
aklaver at comcast.net
Fri May 12 14:12:57 UTC 2006
On Thursday 11 May 2006 06:59 pm, James William Pye wrote:
> On Thu, May 11, 2006 at 12:30:35PM -0700, Adrian Klaver wrote:
> > Failure:
> > aklaver at tucker:~> export -n PGUSER='aklaver'
> > aklaver at tucker:~> pg_python -d business_app -h localhost -U postgres
> > Traceback (most recent call last):
> > File "/usr/local/bin/pg_python", line 254, in ?
> > main(sys.argv)
> > File "/usr/local/bin/pg_python", line 143, in main
> > from postgresql.utility.client import option
> > File
> > "/usr/local/lib/python2.4/site-packages/postgresql/utility/client/option.
> >py", line 34, in ?
> > default = os.environ.get('PGUSER') or os.getlogin() or None,
> > OSError: [Errno 2] No such file or directory
>
> Does python -c 'from os import getlogin; print getlogin()' show your
> username?
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
>
> 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.
I guess the question is if I supply a username with the -U option why do the
defaults even come into play?
--
Adrian Klaver
aklaver at comcast.net
More information about the Python-general
mailing list