rda-python-common 1.0.26__py3-none-any.whl → 1.0.28__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.
Potentially problematic release.
This version of rda-python-common might be problematic. Click here for more details.
- rda_python_common/PgDBI.py +14 -9
- rda_python_common/PgLOG.py +5 -2
- rda_python_common/PgOPT.py +21 -11
- {rda_python_common-1.0.26.dist-info → rda_python_common-1.0.28.dist-info}/METADATA +1 -1
- {rda_python_common-1.0.26.dist-info → rda_python_common-1.0.28.dist-info}/RECORD +8 -8
- {rda_python_common-1.0.26.dist-info → rda_python_common-1.0.28.dist-info}/WHEEL +0 -0
- {rda_python_common-1.0.26.dist-info → rda_python_common-1.0.28.dist-info}/licenses/LICENSE +0 -0
- {rda_python_common-1.0.26.dist-info → rda_python_common-1.0.28.dist-info}/top_level.txt +0 -0
rda_python_common/PgDBI.py
CHANGED
|
@@ -105,7 +105,9 @@ SETPGDBI("VWSOCK", '')
|
|
|
105
105
|
PGDBI['DBSHOST'] = PgLOG.get_short_host(PGDBI['DBHOST'])
|
|
106
106
|
PGDBI['DEFSHOST'] = PgLOG.get_short_host(PGDBI['DEFHOST'])
|
|
107
107
|
PGDBI['VWHOST'] = PgLOG.PGLOG['PVIEWHOST']
|
|
108
|
+
PGDBI['MSHOST'] = PgLOG.PGLOG['PMISCHOST']
|
|
108
109
|
PGDBI['VWSHOST'] = PgLOG.get_short_host(PGDBI['VWHOST'])
|
|
110
|
+
PGDBI['MSSHOST'] = PgLOG.get_short_host(PGDBI['MSHOST'])
|
|
109
111
|
PGDBI['VWHOME'] = (VIEWHOMES[PgLOG.PGLOG['HOSTNAME']] if PgLOG.PGLOG['HOSTNAME'] in VIEWHOMES else VIEWHOMES['default'])
|
|
110
112
|
PGDBI['SCPATH'] = None # additional schema path for set search_path
|
|
111
113
|
PGDBI['VHSET'] = 0
|
|
@@ -142,7 +144,7 @@ dssdb_scname = dssdb_dbname
|
|
|
142
144
|
# set default connection for obsua PostgreSQL Server
|
|
143
145
|
#
|
|
144
146
|
def obsua_dbname():
|
|
145
|
-
default_scinfo('upadb', 'obsua',
|
|
147
|
+
default_scinfo('upadb', 'obsua', PgLOG.PGLOG['PMISCHOST'])
|
|
146
148
|
|
|
147
149
|
obsua_scname = obsua_dbname
|
|
148
150
|
|
|
@@ -150,7 +152,7 @@ obsua_scname = obsua_dbname
|
|
|
150
152
|
# set default connection for ivaddb PostgreSQL Server
|
|
151
153
|
#
|
|
152
154
|
def ivaddb_dbname():
|
|
153
|
-
default_scinfo('ivaddb', 'ivaddb',
|
|
155
|
+
default_scinfo('ivaddb', 'ivaddb', PgLOG.PGLOG['PMISCHOST'])
|
|
154
156
|
|
|
155
157
|
ivaddb_scname = ivaddb_dbname
|
|
156
158
|
|
|
@@ -158,7 +160,7 @@ ivaddb_scname = ivaddb_dbname
|
|
|
158
160
|
# set default connection for ispddb PostgreSQL Server
|
|
159
161
|
#
|
|
160
162
|
def ispddb_dbname():
|
|
161
|
-
default_scinfo('ispddb', 'ispddb',
|
|
163
|
+
default_scinfo('ispddb', 'ispddb', PgLOG.PGLOG['PMISCHOST'])
|
|
162
164
|
|
|
163
165
|
ispddb_scname = ispddb_dbname
|
|
164
166
|
|
|
@@ -1843,9 +1845,9 @@ def get_specialist(dsid, logact = PGDBI['ERRLOG']):
|
|
|
1843
1845
|
#
|
|
1844
1846
|
def build_customized_email(table, field, condition, subject, logact = 0):
|
|
1845
1847
|
|
|
1848
|
+
estat = PgLOG.FAILURE
|
|
1846
1849
|
msg = PgLOG.get_email()
|
|
1847
|
-
|
|
1848
|
-
if not msg: return PgLOG.FAILURE
|
|
1850
|
+
if not msg: return estat
|
|
1849
1851
|
|
|
1850
1852
|
sender = PgLOG.PGLOG['CURUID'] + "@ucar.edu"
|
|
1851
1853
|
receiver = PgLOG.PGLOG['EMLADDR'] if PgLOG.PGLOG['EMLADDR'] else (PgLOG.PGLOG['CURUID'] + "@ucar.edu")
|
|
@@ -1855,9 +1857,12 @@ def build_customized_email(table, field, condition, subject, logact = 0):
|
|
|
1855
1857
|
if not subject: subject = "Message from {}-{}".format(PgLOG.PGLOG['HOSTNAME'], PgLOG.get_command())
|
|
1856
1858
|
ebuf += "Subject: {}!\n\n{}\n".format(subject, msg)
|
|
1857
1859
|
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1860
|
+
if PgLOG.PGLOG['EMLSEND']:
|
|
1861
|
+
estat = PgLOG.send_customized_email(f"{table}.{condition}", ebuf, logact)
|
|
1862
|
+
if estat != PgLOG.SUCCESS:
|
|
1863
|
+
estat = cache_customized_email(table, field, condition, ebuf, 0)
|
|
1864
|
+
if estat and logact:
|
|
1865
|
+
PgLOG.pglog("Email {} cached to '{}.{}' for {}, Subject: {}".format(receiver, table, field, condition, subject), logact)
|
|
1861
1866
|
|
|
1862
1867
|
return estat
|
|
1863
1868
|
|
|
@@ -1922,7 +1927,7 @@ def cache_customized_email(table, field, condition, emlmsg, logact = 0):
|
|
|
1922
1927
|
return PgLOG.SUCCESS
|
|
1923
1928
|
else:
|
|
1924
1929
|
msg = "cache email to '{}.{}' for {}".format(table, field, condition)
|
|
1925
|
-
PgLOG.pglog("Error msg, try to send directly now", logact|PgLOG.ERRLOG)
|
|
1930
|
+
PgLOG.pglog(f"Error {msg}, try to send directly now", logact|PgLOG.ERRLOG)
|
|
1926
1931
|
return PgLOG.send_customized_email(msg, emlmsg, logact)
|
|
1927
1932
|
|
|
1928
1933
|
#
|
rda_python_common/PgLOG.py
CHANGED
|
@@ -119,6 +119,7 @@ PGLOG = { # more defined in untaint_suid() with environment variables
|
|
|
119
119
|
'PBSTIME' : 86400, # max runtime for SLURM bath job, (7x24x60x60 seconds)
|
|
120
120
|
'MSSGRP' : None, # set if set to different HPSS group
|
|
121
121
|
'RDAGRP' : "decs",
|
|
122
|
+
'EMLSEND' : None, # path to sendmail, None if not exists
|
|
122
123
|
'DSCHECK' : None, # carry some cached dscheck information
|
|
123
124
|
'PGDBBUF' : None, # reference to a connected database object
|
|
124
125
|
'HPSSLMT' : 10, # up limit of HPSS streams
|
|
@@ -1289,7 +1290,8 @@ def set_common_pglog():
|
|
|
1289
1290
|
SETPGLOG("LOGFILE", "pgdss.log") # log file name
|
|
1290
1291
|
SETPGLOG("EMLFILE", "pgemail.log") # email log file name
|
|
1291
1292
|
SETPGLOG("ERRFILE", '') # error file name
|
|
1292
|
-
|
|
1293
|
+
sm = "/usr/sbin/sendmail"
|
|
1294
|
+
if valid_command(sm): SETPGLOG("EMLSEND", f"{sm} -t") # send email command
|
|
1293
1295
|
SETPGLOG("DBGLEVEL", '') # debug level
|
|
1294
1296
|
SETPGLOG("DBGPATH", PGLOG['DSSDBHM']+"/log") # path to debug log file
|
|
1295
1297
|
SETPGLOG("OBJCTBKT", "rda-data") # default Bucket on Object Store
|
|
@@ -1322,7 +1324,8 @@ def set_common_pglog():
|
|
|
1322
1324
|
SETPGLOG("SLMHOSTS", "cheyenne:casper") # host names for SLURM server
|
|
1323
1325
|
SETPGLOG("PBSHOSTS", "cheyenne:casper") # host names for PBS server
|
|
1324
1326
|
SETPGLOG("CHKHOSTS", "") # host names for dscheck daemon
|
|
1325
|
-
SETPGLOG("PVIEWHOST", "rda-pgdb-02.ucar.edu")
|
|
1327
|
+
SETPGLOG("PVIEWHOST", "rda-pgdb-02.ucar.edu") # host name for view only postgresql server
|
|
1328
|
+
SETPGLOG("PMISCHOST", "rda-pgdb-03.ucar.edu") # host name for misc postgresql server
|
|
1326
1329
|
SETPGLOG("FTPUPLD", PGLOG['TRANSFER']+"/rossby") # ftp upload path
|
|
1327
1330
|
PGLOG['GPFSROOTS'] = "{}|{}|{}".format(PGLOG['DSDHOME'], PGLOG['UPDTWKP'], PGLOG['RQSTHOME'])
|
|
1328
1331
|
|
rda_python_common/PgOPT.py
CHANGED
|
@@ -1684,6 +1684,7 @@ def send_request_email_notice(pgrqst, errmsg, fcount, rstat, readyfile = None, p
|
|
|
1684
1684
|
for ekey in einfo:
|
|
1685
1685
|
ebuf = re.sub(r'<{}>'.format(ekey), einfo[ekey], ebuf)
|
|
1686
1686
|
|
|
1687
|
+
|
|
1687
1688
|
if PgLOG.PGLOG['DSCHECK'] and not pgpart:
|
|
1688
1689
|
tbl = "dscheck"
|
|
1689
1690
|
cnd = "cindex = {}".format(PgLOG.PGLOG['DSCHECK']['cindex'])
|
|
@@ -1691,18 +1692,27 @@ def send_request_email_notice(pgrqst, errmsg, fcount, rstat, readyfile = None, p
|
|
|
1691
1692
|
tbl = "dsrqst"
|
|
1692
1693
|
cnd = "rindex = {}".format(pgrqst['rindex'])
|
|
1693
1694
|
|
|
1694
|
-
if
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1695
|
+
if PgLOG.PGLOG['EMLSEND'] and PgLOG.send_customized_email(f"{tbl}.{cnd}", ebuf, 0):
|
|
1696
|
+
if errmsg:
|
|
1697
|
+
PgLOG.pglog("Error Email sent to {} for {}.{}:\n{}".format(einfo['SENDER'], tbl, cnd, errmsg), PGOPT['errlog'])
|
|
1698
|
+
readyfile = None
|
|
1699
|
+
else:
|
|
1700
|
+
PgLOG.pglog("{}Email sent to {} for {}.{}\nSubset: {}".format(("Customized " if pgrqst['enotice'] else ""), einfo['RECEIVER'], tbl, cnd, einfo['SUBJECT']),
|
|
1701
|
+
PGOPT['wrnlog']|PgLOG.FRCLOG)
|
|
1698
1702
|
else:
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1703
|
+
if not PgDBI.cache_customized_email(tbl, "einfo", cnd, ebuf, 0): return 'E'
|
|
1704
|
+
if errmsg:
|
|
1705
|
+
PgLOG.pglog("Error Email {} cached to {}.einfo for {}:\n{}".format(einfo['SENDER'], tbl, cnd, errmsg), PGOPT['errlog'])
|
|
1706
|
+
readyfile = None
|
|
1707
|
+
else:
|
|
1708
|
+
PgLOG.pglog("{}Email {} cached to {}.einfo for {}\nSubset: {}".format(("Customized " if pgrqst['enotice'] else ""), einfo['RECEIVER'], tbl, cnd, einfo['SUBJECT']),
|
|
1709
|
+
PGOPT['wrnlog']|PgLOG.FRCLOG)
|
|
1710
|
+
|
|
1711
|
+
if readyfile:
|
|
1712
|
+
rf = open(readyfile, 'w')
|
|
1713
|
+
rf.write(ebuf)
|
|
1714
|
+
rf.close()
|
|
1715
|
+
PgFile.set_local_mode(readyfile, 1, PgLOG.PGLOG['FILEMODE'])
|
|
1706
1716
|
|
|
1707
1717
|
return rstat
|
|
1708
1718
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rda_python_common
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.28
|
|
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
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
rda_python_common/PgCMD.py,sha256=EYjG2Z4zEnvsXE1z-jt5UaNoEKxnOYYiMMzvW6HrKA4,20597
|
|
2
|
-
rda_python_common/PgDBI.py,sha256=
|
|
2
|
+
rda_python_common/PgDBI.py,sha256=Q-axfqJ_Ijq2dNcNv5hH63HV_I59pdkM8ZEfZdqri1Q,74480
|
|
3
3
|
rda_python_common/PgFile.py,sha256=756onQnWH_MK8llF0-8b6yV6KC1eY_eCPEkygxeJQQU,98460
|
|
4
|
-
rda_python_common/PgLOG.py,sha256=
|
|
4
|
+
rda_python_common/PgLOG.py,sha256=Tr2YrscqVuvp3LRyaXL1C66TdKcdqqqOgnVaC5cXYM8,54463
|
|
5
5
|
rda_python_common/PgLock.py,sha256=12i84nsGBuifSyPnm8IR63LvHvRuVU573D5QKFlHdOI,22623
|
|
6
|
-
rda_python_common/PgOPT.py,sha256=
|
|
6
|
+
rda_python_common/PgOPT.py,sha256=G2apwdyeLBBXj6i2C1duUtia7KDzxkB1dpor18WYdT8,55946
|
|
7
7
|
rda_python_common/PgSIG.py,sha256=ZVM9Qz6yIFurwIQJtV5-CFbKOTdFsZ-Rs95SEpDFgNk,35795
|
|
8
8
|
rda_python_common/PgSplit.py,sha256=QKPbF55m8KCTGmwVwL3uG_nuylCC4FSVfLuXeLjJHbE,8816
|
|
9
9
|
rda_python_common/PgUtil.py,sha256=OqESKCd72b9g8m8jwjPJhXDtPYlW6G8oSOhwChvz2Cg,48600
|
|
10
10
|
rda_python_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
rda_python_common-1.0.
|
|
12
|
-
rda_python_common-1.0.
|
|
13
|
-
rda_python_common-1.0.
|
|
14
|
-
rda_python_common-1.0.
|
|
15
|
-
rda_python_common-1.0.
|
|
11
|
+
rda_python_common-1.0.28.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
|
|
12
|
+
rda_python_common-1.0.28.dist-info/METADATA,sha256=XAUpZeUylddOW95NWPMqkMTYO0mFvOOxMRQ_2vMchUQ,716
|
|
13
|
+
rda_python_common-1.0.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
rda_python_common-1.0.28.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
|
|
15
|
+
rda_python_common-1.0.28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|