rda-python-common 2.0.0__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/PgCMD.py +603 -0
- rda_python_common/PgDBI.py +2306 -0
- rda_python_common/PgFile.py +3118 -0
- rda_python_common/PgLOG.py +1689 -0
- rda_python_common/PgLock.py +640 -0
- rda_python_common/PgOPT.py +1740 -0
- rda_python_common/PgSIG.py +1164 -0
- rda_python_common/PgSplit.py +299 -0
- rda_python_common/PgUtil.py +1854 -0
- rda_python_common/__init__.py +0 -0
- rda_python_common/pg_cmd.py +493 -0
- rda_python_common/pg_dbi.py +1885 -0
- rda_python_common/pg_file.py +2462 -0
- rda_python_common/pg_lock.py +533 -0
- rda_python_common/pg_log.py +1352 -0
- rda_python_common/pg_opt.py +1447 -0
- rda_python_common/pg_pass.py +92 -0
- rda_python_common/pg_sig.py +879 -0
- rda_python_common/pg_split.py +260 -0
- rda_python_common/pg_util.py +1534 -0
- rda_python_common/pgpassword.py +92 -0
- rda_python_common-2.0.0.dist-info/METADATA +20 -0
- rda_python_common-2.0.0.dist-info/RECORD +27 -0
- rda_python_common-2.0.0.dist-info/WHEEL +5 -0
- rda_python_common-2.0.0.dist-info/entry_points.txt +3 -0
- rda_python_common-2.0.0.dist-info/licenses/LICENSE +21 -0
- rda_python_common-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
##################################################################################
|
|
4
|
+
#
|
|
5
|
+
# Title: pgpassword
|
|
6
|
+
# Author: Zaihua Ji, zji@ucar.edu
|
|
7
|
+
# Date: 2025-10-27
|
|
8
|
+
# Purpose: python script to retrieve passwords for postgrsql login to connect a
|
|
9
|
+
# gdex database from inside an python application
|
|
10
|
+
#
|
|
11
|
+
# Github: https://github.com/NCAR/rda-python-common.git
|
|
12
|
+
#
|
|
13
|
+
##################################################################################
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import sys
|
|
17
|
+
import re
|
|
18
|
+
import pwd
|
|
19
|
+
import hvac
|
|
20
|
+
from . import PgLOG
|
|
21
|
+
from . import PgDBI
|
|
22
|
+
|
|
23
|
+
DBFLDS = {
|
|
24
|
+
'd' : 'dbname',
|
|
25
|
+
'c' : 'scname',
|
|
26
|
+
'h' : 'dbhost',
|
|
27
|
+
'p' : 'dbport',
|
|
28
|
+
'u' : 'lnname'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
DBINFO = {
|
|
32
|
+
'dbname' : "",
|
|
33
|
+
'scname' : "",
|
|
34
|
+
'lnname' : "",
|
|
35
|
+
'dbhost' : "",
|
|
36
|
+
'dbport' : 5432
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# main function to excecute this script
|
|
41
|
+
#
|
|
42
|
+
def main():
|
|
43
|
+
|
|
44
|
+
permit = False
|
|
45
|
+
aname = 'pgpassword'
|
|
46
|
+
argv = sys.argv[1:]
|
|
47
|
+
opt = None
|
|
48
|
+
dohelp = True
|
|
49
|
+
dbopt = False
|
|
50
|
+
|
|
51
|
+
for arg in argv:
|
|
52
|
+
if re.match(r'^-\w+$', arg):
|
|
53
|
+
opt = arg[1:]
|
|
54
|
+
elif opt:
|
|
55
|
+
if opt == 'l':
|
|
56
|
+
PgDBI.PGDBI['BAOURL'] = arg
|
|
57
|
+
elif opt == 'k':
|
|
58
|
+
PgDBI.PGDBI['BAOTOKEN'] = arg
|
|
59
|
+
elif opt in DBFLDS:
|
|
60
|
+
dbopt = True
|
|
61
|
+
DBINFO[DBFLDS[opt]] = arg
|
|
62
|
+
else:
|
|
63
|
+
PgLOG.pglog(arg + ": Unknown option", PgLOG.LGEREX)
|
|
64
|
+
dohelp = False
|
|
65
|
+
else:
|
|
66
|
+
PgLOG.pglog(arg + ": Value provided without option", PgLOG.LGEREX)
|
|
67
|
+
|
|
68
|
+
if dohelp:
|
|
69
|
+
print("Usage: pgpassword [-l OpenBaoURL] [-k TokenName] [-d DBNAME] \\")
|
|
70
|
+
print(" [-c SCHEMA] [-u USName] [-h DBHOST] [-p DBPORT]")
|
|
71
|
+
print(" -l OpenBao URL to retrieve passwords")
|
|
72
|
+
print(" -k OpenBao Token Name to retrieve passwords")
|
|
73
|
+
print(" -d PostgreSQL Database Name")
|
|
74
|
+
print(" -c PostgreSQL Schema Name")
|
|
75
|
+
print(" -u PostgreSQL Login User Name")
|
|
76
|
+
print(" -h PostgreSQL Server Host Name")
|
|
77
|
+
print(" -p PostgreSQL Port Number")
|
|
78
|
+
sys.exit(0)
|
|
79
|
+
|
|
80
|
+
if dbopt:
|
|
81
|
+
PgDBI.default_scinfo(DBINFO['dbname'], DBINFO['scname'], DBINFO['dbhost'],
|
|
82
|
+
DBINFO['lnname'], None, DBINFO['dbport'])
|
|
83
|
+
|
|
84
|
+
pwname = PgDBI.get_baopassword()
|
|
85
|
+
if not pwname: pwname = PgDBI.get_pgpassword()
|
|
86
|
+
print(pwname)
|
|
87
|
+
sys.exit(0)
|
|
88
|
+
|
|
89
|
+
#
|
|
90
|
+
# call main() to start program
|
|
91
|
+
#
|
|
92
|
+
if __name__ == "__main__": main()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rda_python_common
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: RDA Python common library codes shared by other RDA python packages
|
|
5
|
+
Author-email: Zaihua Ji <zji@ucar.edu>
|
|
6
|
+
Project-URL: Homepage, https://github.com/NCAR/rda-python-common
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: psycopg2-binary
|
|
15
|
+
Requires-Dist: rda-python-globus
|
|
16
|
+
Requires-Dist: unidecode
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# rda-python-common
|
|
20
|
+
Python common library codes to be shared by other RDA python utility programs.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
rda_python_common/PgCMD.py,sha256=EYjG2Z4zEnvsXE1z-jt5UaNoEKxnOYYiMMzvW6HrKA4,20597
|
|
2
|
+
rda_python_common/PgDBI.py,sha256=b445vUuwY-okCITUJ6lD7Y6Q4Fmm5yYFdCOY0AW9WAs,76214
|
|
3
|
+
rda_python_common/PgFile.py,sha256=obl9Pj3yFnjrOJUTFiEHK7ZbG2Ic_m3dT0NqO7rGvOs,99370
|
|
4
|
+
rda_python_common/PgLOG.py,sha256=h0Kzocqc3XWdFoeEa4if72EZ5UgnHBMxdszE06GGCf4,55428
|
|
5
|
+
rda_python_common/PgLock.py,sha256=12i84nsGBuifSyPnm8IR63LvHvRuVU573D5QKFlHdOI,22623
|
|
6
|
+
rda_python_common/PgOPT.py,sha256=Kn4JYezZhZwAn2usiIYHoHiymGHRgsN299dxyXbKwkI,56244
|
|
7
|
+
rda_python_common/PgSIG.py,sha256=eTJJ3XxutsQ3JSg6uYRpH26ZmrVUup3ShqDFLWXLruA,35803
|
|
8
|
+
rda_python_common/PgSplit.py,sha256=SSg5_Qu5PqP44EkqebO-V_cErNcdE2QtORgFHQ7RqlQ,8822
|
|
9
|
+
rda_python_common/PgUtil.py,sha256=OqESKCd72b9g8m8jwjPJhXDtPYlW6G8oSOhwChvz2Cg,48600
|
|
10
|
+
rda_python_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
rda_python_common/pg_cmd.py,sha256=XyQ9-p4Wx2aHeySG7pQIPmcJG62Mpf_5kpTj18-1MX4,21984
|
|
12
|
+
rda_python_common/pg_dbi.py,sha256=4MgQaESYrLJ_GoRy-aOLII6pGsn5L6oZOClVJ_j69yY,84153
|
|
13
|
+
rda_python_common/pg_file.py,sha256=FoBC5GyLrXcSewUC6dfTj_QeDO1HTFDeF15CdTfXH_c,108143
|
|
14
|
+
rda_python_common/pg_lock.py,sha256=BsyPebNOKtui0Wf_JCmIm89wrH5EUQfTD_vr8HcQ3wo,24098
|
|
15
|
+
rda_python_common/pg_log.py,sha256=JKPROE--8XIDQo0YQEucsHhcg0clITu-aO16bF26koA,60114
|
|
16
|
+
rda_python_common/pg_opt.py,sha256=yqOrTrDjq0sEQiN5uCR1mhfwwEqTc99qi0u0kmkk5dg,62707
|
|
17
|
+
rda_python_common/pg_pass.py,sha256=k-p8HBMHDz4AiN3hG0SiAMtg_KQzCEcdN_xbZt6ISz8,2925
|
|
18
|
+
rda_python_common/pg_sig.py,sha256=_NBXhjB-4_rJEgj8UUmOq52IUXNINld_iICsRrdztso,36782
|
|
19
|
+
rda_python_common/pg_split.py,sha256=v3xufJ1_CiFHR4wejLm5k0TDKJmeKPqu0kdLEBoWe-A,10057
|
|
20
|
+
rda_python_common/pg_util.py,sha256=12a0z9zMBo2aZWYS-j0vQvnFDHhdkmMwcPxtHxRvEjE,54868
|
|
21
|
+
rda_python_common/pgpassword.py,sha256=coppnpJ86Rs02025W-4j63z0IUIVlRNcnbrXz6dUL_o,2364
|
|
22
|
+
rda_python_common-2.0.0.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
|
|
23
|
+
rda_python_common-2.0.0.dist-info/METADATA,sha256=LwiGkcY7N0bjipf1qVDEaCrZmM_UwvNamfDkTD4-WxY,740
|
|
24
|
+
rda_python_common-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
rda_python_common-2.0.0.dist-info/entry_points.txt,sha256=ALhRZ6NbX43Fxi8iUPM_xu1b0ZCfBFuvQBBTxFybTfs,106
|
|
26
|
+
rda_python_common-2.0.0.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
|
|
27
|
+
rda_python_common-2.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 National Center for Atmospheric Research
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rda_python_common
|