Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ PgLOG.pglog("hello", PgLOG.LOGWRN)
python -c "import rda_python_common; print(rda_python_common.__version__)"
```

You should see the installed version (currently `3.0.17`). If the import
You should see the installed version (currently `3.0.18`). If the import
fails, double-check that the active Python environment is the one where you
ran `pip install`.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rda_python_common"
version = "3.0.17"
version = "3.0.18"
authors = [
{ name="Zaihua Ji", email="zji@ucar.edu" },
]
Expand Down
2 changes: 1 addition & 1 deletion src/rda_python_common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from . import PgLOG, PgUtil, PgDBI, PgFile, PgLock, PgCMD, PgSIG, PgOPT, PgSplit

__version__ = "3.0.17"
__version__ = "3.0.18"

__all__ = [
"PgLOG",
Expand Down
18 changes: 13 additions & 5 deletions src/rda_python_common/pg_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,18 @@ def send_customized_email(self, logmsg, emlmsg, logact=None):
msg = emlmsg
for ekey in entries:
entry = entries[ekey][0]
ms = re.search(r'(^|\n)({}: *(.*)\n)'.format(entry), emlmsg, re.I)
ms = re.search(r'(^|\n)({}: *(.*)\n)'.format(entry), msg, re.I)
if ms:
vals = ms.groups()
msg = msg.replace(vals[1], '')
if vals[2]: entries[ekey][2] = vals[2]
# cut out this header line only; a replace() of the matched text would also
# strip an identical line from anywhere in the message body
msg = msg[:ms.start(2)] + msg[ms.end(2):]
if ms.group(3): entries[ekey][2] = ms.group(3)
elif entries[ekey][1]:
return self.pglog("{}Missing Entry '{}' for sending email".format(logmsg, entry), logact|self.ERRLOG)
if not msg.strip():
# send_python_email() mails the buffered EMLMSG when it is given no body, which
# would send an unrelated message to this recipient and empty the buffer
return self.pglog("{}Empty message body for sending email".format(logmsg), logact|self.ERRLOG)
ret = self.send_python_email(entries['sb'][2], entries['to'][2], msg, entries['fr'][2], entries['cc'][2], logact)
if ret == self.SUCCESS or not self.PGLOG['EMLSEND']: return ret
# try commandline sendmail
Expand Down Expand Up @@ -386,7 +391,10 @@ def send_python_email(self, subject=None, receiver=None, msg=None, sender=None,
self.PGLOG['EMLMSG'] = ''
else:
return ''
docc = False if cc else True
# only an omitted cc means 'use CCDADDR and carbon copy the sender'; an explicitly
# empty cc suppresses the Cc entirely, and used to leak the sender into the global
# CCDADDR anyway, carbon copying it on every later email of the same process
docc = True if cc is None else False
if not sender:
sender = self.PGLOG['CURUID']
if sender != self.PGLOG['COMMONUSER']: docc = False
Expand Down
Loading