rda-python-common 1.0.27__tar.gz → 1.0.28__tar.gz

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.

Files changed (21) hide show
  1. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/PKG-INFO +1 -1
  2. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/pyproject.toml +1 -1
  3. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgDBI.py +9 -6
  4. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgLOG.py +3 -1
  5. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgOPT.py +21 -11
  6. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common.egg-info/PKG-INFO +1 -1
  7. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/LICENSE +0 -0
  8. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/README.md +0 -0
  9. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/setup.cfg +0 -0
  10. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgCMD.py +0 -0
  11. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgFile.py +0 -0
  12. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgLock.py +0 -0
  13. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgSIG.py +0 -0
  14. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgSplit.py +0 -0
  15. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/PgUtil.py +0 -0
  16. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common/__init__.py +0 -0
  17. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common.egg-info/SOURCES.txt +0 -0
  18. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common.egg-info/dependency_links.txt +0 -0
  19. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common.egg-info/requires.txt +0 -0
  20. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/src/rda_python_common.egg-info/top_level.txt +0 -0
  21. {rda_python_common-1.0.27 → rda_python_common-1.0.28}/test/test_common.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_common
3
- Version: 1.0.27
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rda_python_common"
7
- version = "1.0.27"
7
+ version = "1.0.28"
8
8
  authors = [
9
9
  { name="Zaihua Ji", email="zji@ucar.edu" },
10
10
  ]
@@ -1845,9 +1845,9 @@ def get_specialist(dsid, logact = PGDBI['ERRLOG']):
1845
1845
  #
1846
1846
  def build_customized_email(table, field, condition, subject, logact = 0):
1847
1847
 
1848
+ estat = PgLOG.FAILURE
1848
1849
  msg = PgLOG.get_email()
1849
-
1850
- if not msg: return PgLOG.FAILURE
1850
+ if not msg: return estat
1851
1851
 
1852
1852
  sender = PgLOG.PGLOG['CURUID'] + "@ucar.edu"
1853
1853
  receiver = PgLOG.PGLOG['EMLADDR'] if PgLOG.PGLOG['EMLADDR'] else (PgLOG.PGLOG['CURUID'] + "@ucar.edu")
@@ -1857,9 +1857,12 @@ def build_customized_email(table, field, condition, subject, logact = 0):
1857
1857
  if not subject: subject = "Message from {}-{}".format(PgLOG.PGLOG['HOSTNAME'], PgLOG.get_command())
1858
1858
  ebuf += "Subject: {}!\n\n{}\n".format(subject, msg)
1859
1859
 
1860
- estat = cache_customized_email(table, field, condition, ebuf, logact)
1861
- if estat and logact:
1862
- PgLOG.pglog("Email {} cached to '{}.{}' for {}, Subject: {}".format(receiver, table, field, condition, subject), logact)
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)
1863
1866
 
1864
1867
  return estat
1865
1868
 
@@ -1924,7 +1927,7 @@ def cache_customized_email(table, field, condition, emlmsg, logact = 0):
1924
1927
  return PgLOG.SUCCESS
1925
1928
  else:
1926
1929
  msg = "cache email to '{}.{}' for {}".format(table, field, condition)
1927
- 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)
1928
1931
  return PgLOG.send_customized_email(msg, emlmsg, logact)
1929
1932
 
1930
1933
  #
@@ -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
- SETPGLOG("EMLSEND", "/usr/lib/sendmail -t") # send email command
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
@@ -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 not PgDBI.cache_customized_email(tbl, "einfo", cnd, ebuf, 0): return 'E'
1695
- if errmsg:
1696
- PgLOG.pglog("Error Email {} cached to {}.einfo for {}:\n{}".format(einfo['SENDER'], tbl, cnd, errmsg),
1697
- PGOPT['errlog'])
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
- PgLOG.pglog("{}Email {} cached to {}.einfo for {}\nSubset: {}".format(("Customized " if pgrqst['enotice'] else ""), einfo['RECEIVER'], tbl, cnd, einfo['SUBJECT']),
1700
- PGOPT['wrnlog']|PgLOG.FRCLOG)
1701
- if readyfile:
1702
- rf = open(readyfile, 'w')
1703
- rf.write(ebuf)
1704
- rf.close()
1705
- PgFile.set_local_mode(readyfile, 1, PgLOG.PGLOG['FILEMODE'])
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.27
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