rda-python-common 2.1.8__py3-none-any.whl → 2.1.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rda_python_common/__init__.py +1 -1
- rda_python_common/pgpassword.py +24 -19
- rda_python_common/pgpassword.usg +57 -0
- {rda_python_common-2.1.8.dist-info → rda_python_common-2.1.9.dist-info}/METADATA +2 -2
- {rda_python_common-2.1.8.dist-info → rda_python_common-2.1.9.dist-info}/RECORD +9 -8
- {rda_python_common-2.1.8.dist-info → rda_python_common-2.1.9.dist-info}/WHEEL +0 -0
- {rda_python_common-2.1.8.dist-info → rda_python_common-2.1.9.dist-info}/entry_points.txt +0 -0
- {rda_python_common-2.1.8.dist-info → rda_python_common-2.1.9.dist-info}/licenses/LICENSE +0 -0
- {rda_python_common-2.1.8.dist-info → rda_python_common-2.1.9.dist-info}/top_level.txt +0 -0
rda_python_common/__init__.py
CHANGED
rda_python_common/pgpassword.py
CHANGED
|
@@ -64,23 +64,29 @@ class PgPassword(PgDBI):
|
|
|
64
64
|
Parse ``sys.argv`` and apply CLI overrides.
|
|
65
65
|
|
|
66
66
|
Recognized options:
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
67
|
+
-? / --help -- show usage and exit
|
|
68
|
+
-l URL -- OpenBao URL (stored in self.PGDBI['BAOURL'])
|
|
69
|
+
-k TOKEN -- OpenBao token name (stored in self.PGDBI['BAOTOKEN'])
|
|
70
|
+
-d NAME -- PostgreSQL database name
|
|
71
|
+
-c NAME -- PostgreSQL schema name
|
|
72
|
+
-u NAME -- PostgreSQL login user name
|
|
73
|
+
-h HOST -- PostgreSQL server host name
|
|
74
|
+
-p PORT -- PostgreSQL port number
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
With no arguments, all defaults inherited from PgDBI/PgLOG are
|
|
77
|
+
used and the password lookup proceeds. Unknown options, stray
|
|
78
|
+
values, or an option without its required value cause an
|
|
79
|
+
immediate error exit via ``self.pglog(..., LGEREX)``.
|
|
78
80
|
"""
|
|
79
81
|
argv = sys.argv[1:]
|
|
80
82
|
opt = None
|
|
81
|
-
dohelp = True
|
|
82
83
|
for arg in argv:
|
|
83
|
-
if
|
|
84
|
+
if arg in ('-?', '-help', '--help'):
|
|
85
|
+
self.set_help_path(__file__)
|
|
86
|
+
self.show_usage("pgpassword")
|
|
87
|
+
elif re.match(r'^-[a-zA-Z]$', arg):
|
|
88
|
+
if opt:
|
|
89
|
+
self.pglog("-" + opt + ": missing option value", self.LGEREX)
|
|
84
90
|
opt = arg[1:]
|
|
85
91
|
elif opt:
|
|
86
92
|
if opt == 'l':
|
|
@@ -91,13 +97,12 @@ class PgPassword(PgDBI):
|
|
|
91
97
|
self.dbopt = True
|
|
92
98
|
self.DBINFO[self.DBFLDS[opt]] = arg
|
|
93
99
|
else:
|
|
94
|
-
self.pglog(
|
|
95
|
-
|
|
100
|
+
self.pglog("-" + opt + ": Unknown option", self.LGEREX)
|
|
101
|
+
opt = None
|
|
96
102
|
else:
|
|
97
|
-
self.pglog(arg + ":
|
|
98
|
-
if
|
|
99
|
-
self.
|
|
100
|
-
self.show_usage("pgpassword")
|
|
103
|
+
self.pglog(arg + ": value provided without option", self.LGEREX)
|
|
104
|
+
if opt:
|
|
105
|
+
self.pglog("-" + opt + ": missing option value", self.LGEREX)
|
|
101
106
|
|
|
102
107
|
# get the pgpassword
|
|
103
108
|
def start_actions(self):
|
|
@@ -114,7 +119,7 @@ class PgPassword(PgDBI):
|
|
|
114
119
|
self.password = self.get_baopassword()
|
|
115
120
|
if not self.password: self.password = self.get_pgpassword()
|
|
116
121
|
|
|
117
|
-
# main function to
|
|
122
|
+
# main function to execute this script
|
|
118
123
|
def main():
|
|
119
124
|
"""Entry point for the ``pgpassword`` console script: print the retrieved password to stdout."""
|
|
120
125
|
object = PgPassword()
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
Retrieve a PostgreSQL login password for use by RDA python applications.
|
|
3
|
+
The password is looked up first from OpenBao (using the URL and token
|
|
4
|
+
configured in PgDBI) and, if not found there, from the user's .pgpass
|
|
5
|
+
file. The retrieved password is printed to stdout so that shell
|
|
6
|
+
wrappers and other RDA utilities can capture it.
|
|
7
|
+
|
|
8
|
+
Usage: pgpassword [-?] [-l OpenBaoURL] [-k TokenName] [-d DBNAME] \
|
|
9
|
+
[-c SCHEMA] [-u USName] [-h DBHOST] [-p DBPORT]
|
|
10
|
+
|
|
11
|
+
With no options, pgpassword retrieves the password using all defaults
|
|
12
|
+
inherited from PgDBI/PgLOG (see per-option defaults below).
|
|
13
|
+
|
|
14
|
+
- Option -?, show this usage information and exit (also -help
|
|
15
|
+
and --help);
|
|
16
|
+
|
|
17
|
+
- Option -l, OpenBao URL used to retrieve passwords. Overrides
|
|
18
|
+
the BAOURL value from the PgDBI configuration.
|
|
19
|
+
Default: https://bao.k8s.ucar.edu/
|
|
20
|
+
|
|
21
|
+
- Option -k, OpenBao token name used to authenticate the password
|
|
22
|
+
lookup. Overrides the BAOTOKEN value from the PgDBI
|
|
23
|
+
configuration.
|
|
24
|
+
|
|
25
|
+
- Option -d, PostgreSQL database name.
|
|
26
|
+
Default: rdadb
|
|
27
|
+
|
|
28
|
+
- Option -c, PostgreSQL schema name.
|
|
29
|
+
Default: dssdb
|
|
30
|
+
|
|
31
|
+
- Option -u, PostgreSQL login user name.
|
|
32
|
+
Default: dssdb (same as the -c default)
|
|
33
|
+
|
|
34
|
+
- Option -h, PostgreSQL server host name.
|
|
35
|
+
Default: value of the DSSDBHOST environment variable, or
|
|
36
|
+
rda-db.ucar.edu if DSSDBHOST is not set.
|
|
37
|
+
|
|
38
|
+
- Option -p, PostgreSQL server port number.
|
|
39
|
+
Default: 5432
|
|
40
|
+
|
|
41
|
+
If any of -d, -c, -u, -h, or -p is supplied, the values are applied
|
|
42
|
+
via default_scinfo() before the password lookup is performed.
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
|
|
46
|
+
1. Retrieve the password for the default database/user configured
|
|
47
|
+
in PgDBI:
|
|
48
|
+
|
|
49
|
+
pgpassword
|
|
50
|
+
|
|
51
|
+
2. Retrieve the password for a specific database, schema and user:
|
|
52
|
+
|
|
53
|
+
pgpassword -d rdadb -c dssdb -u metauser
|
|
54
|
+
|
|
55
|
+
3. Retrieve the password from a custom OpenBao endpoint:
|
|
56
|
+
|
|
57
|
+
pgpassword -l https://bao.example.org -k my-token -d rdadb
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rda_python_common
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.9
|
|
4
4
|
Summary: RDA Python common library codes shared by other RDA python packages
|
|
5
5
|
Author-email: Zaihua Ji <zji@ucar.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/NCAR/rda-python-common
|
|
@@ -92,7 +92,7 @@ PgLOG.pglog("hello", PgLOG.LOGWRN)
|
|
|
92
92
|
python -c "import rda_python_common; print(rda_python_common.__version__)"
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
You should see the installed version (currently `2.1.
|
|
95
|
+
You should see the installed version (currently `2.1.9`). If the import
|
|
96
96
|
fails, double-check that the active Python environment is the one where you
|
|
97
97
|
ran `pip install`.
|
|
98
98
|
|
|
@@ -7,7 +7,7 @@ rda_python_common/PgOPT.py,sha256=Kn4JYezZhZwAn2usiIYHoHiymGHRgsN299dxyXbKwkI,56
|
|
|
7
7
|
rda_python_common/PgSIG.py,sha256=eTJJ3XxutsQ3JSg6uYRpH26ZmrVUup3ShqDFLWXLruA,35803
|
|
8
8
|
rda_python_common/PgSplit.py,sha256=SSg5_Qu5PqP44EkqebO-V_cErNcdE2QtORgFHQ7RqlQ,8822
|
|
9
9
|
rda_python_common/PgUtil.py,sha256=OqESKCd72b9g8m8jwjPJhXDtPYlW6G8oSOhwChvz2Cg,48600
|
|
10
|
-
rda_python_common/__init__.py,sha256=
|
|
10
|
+
rda_python_common/__init__.py,sha256=_zWhlp02qZlgMlsox5HGR_mmXRjyQSHIo__v_hTW2rY,994
|
|
11
11
|
rda_python_common/pg_cmd.py,sha256=hQZaW80eFqEUoF0vZHtGuvBEWXbXdY0Nvj6rFIQGboo,32856
|
|
12
12
|
rda_python_common/pg_dbi.py,sha256=q6LT4a4lwo-sM2LEqgrEVkAlh886xeKiz4feqRKw-7c,116238
|
|
13
13
|
rda_python_common/pg_file.py,sha256=RzQTxnht4bFOVty4qoYPREawMCUsnFIbWm2pfEez1fE,161993
|
|
@@ -18,10 +18,11 @@ rda_python_common/pg_password.py,sha256=X-eIDwdqBhtrhrbDTNWle-0JtWsyIVZdDOZaBu7c
|
|
|
18
18
|
rda_python_common/pg_sig.py,sha256=wLKBmFNWAmxWJFC2L3SLsD4n464kzzHbIFFNBlCW6kI,52759
|
|
19
19
|
rda_python_common/pg_split.py,sha256=aAWKUZPmZ-LQ_fJ3DSKzPKxJw0fMDJ2fgP8ZT629M30,16375
|
|
20
20
|
rda_python_common/pg_util.py,sha256=bjp2civRIhqaBSR8oOtyRzYIZBdwB90SzmJLjRIA7fc,87280
|
|
21
|
-
rda_python_common/pgpassword.py,sha256=
|
|
22
|
-
rda_python_common
|
|
23
|
-
rda_python_common-2.1.
|
|
24
|
-
rda_python_common-2.1.
|
|
25
|
-
rda_python_common-2.1.
|
|
26
|
-
rda_python_common-2.1.
|
|
27
|
-
rda_python_common-2.1.
|
|
21
|
+
rda_python_common/pgpassword.py,sha256=aTQaO59QokWrv2EKom4TvKhNW2Mr6aFMMBVG4DCbcKI,5023
|
|
22
|
+
rda_python_common/pgpassword.usg,sha256=Wrle6A8sdlMGx3ZEAmE6TNDPOlG84Whe0T3rCNFzPfY,2013
|
|
23
|
+
rda_python_common-2.1.9.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
|
|
24
|
+
rda_python_common-2.1.9.dist-info/METADATA,sha256=RCXhbSP_OnuQyIUUa5h67nFYjzElGU2uDBMXoH5wFcY,11090
|
|
25
|
+
rda_python_common-2.1.9.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
26
|
+
rda_python_common-2.1.9.dist-info/entry_points.txt,sha256=pZgVNWspcK-F1TbPav7C3C9NdeHDZMm_25fW9weix00,65
|
|
27
|
+
rda_python_common-2.1.9.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
|
|
28
|
+
rda_python_common-2.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|