File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 4
4
import logging
5
5
import os
6
6
import mamonsu .lib .platform as platform
7
+ if platform .WINDOWS :
8
+ import win32api
9
+ else :
10
+ import getpass
7
11
8
12
9
13
class PgsqlConfig (object ):
10
14
11
15
@staticmethod
12
16
def default_user ():
13
- user = os .environ .get ('PGUSER' ) or os .getlogin () or 'postgres'
17
+ if platform .WINDOWS :
18
+ username = win32api .GetUserName ()
19
+ else :
20
+ username = getpass .getuser ()
21
+
22
+ user = os .environ .get ('PGUSER' ) or username or 'postgres'
14
23
return user
15
24
16
25
@staticmethod
@@ -40,7 +49,12 @@ def default_app():
40
49
41
50
@staticmethod
42
51
def default_db ():
43
- database = os .environ .get ('PGDATABASE' ) or os .environ .get ('PGUSER' ) or os .getlogin ()
52
+ if platform .WINDOWS :
53
+ username = win32api .GetUserName ()
54
+ else :
55
+ username = getpass .getuser ()
56
+
57
+ database = os .environ .get ('PGDATABASE' ) or os .environ .get ('PGUSER' ) or username
44
58
database = database or 'postgres'
45
59
return database
46
60
You can’t perform that action at this time.
0 commit comments