Skip to content

Commit 91fcd54

Browse files
committed
Update postgresql/clientparameters.py
Alterations made to supportuse in win32 service (forced getuser() to return 'postgres')
1 parent 82e9740 commit 91fcd54

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

postgresql/clientparameters.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ class ClientParameterError(Error):
4646
class ServiceDoesNotExistError(ClientParameterError):
4747
code = '-*srv'
4848

49-
try:
50-
from getpass import getuser, getpass
51-
except ImportError:
52-
getpass = raw_input
53-
def getuser():
54-
return 'postgres'
49+
# on win32 when program is run as windows service, getuser falls back to pwn which is not implemented
50+
# therefore it is better to resign from getting default username, which allows service operation
51+
52+
getpass = raw_input
53+
54+
def getuser():
55+
return 'postgres'
5556

5657
default_host = 'localhost'
5758
default_port = 5432
@@ -141,6 +142,9 @@ def defaults(environ = os.environ):
141142
if appdata:
142143
pgdata = os.path.join(appdata, pg_appdata_directory)
143144
pgpassfile = os.path.join(pgdata, pg_appdata_passfile)
145+
else:
146+
pgdata = ''
147+
pgpassfile = ''
144148
else:
145149
pgpassfile = os.path.join(userdir, pg_home_passfile)
146150

0 commit comments

Comments
 (0)