Skip to content

Commit 510ee43

Browse files
author
zaihuaji
committed
call send_python_email() first
1 parent 59ea821 commit 510ee43

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "rda_python_common"
7-
version = "1.0.33"
7+
version = "1.0.34"
88
authors = [
99
{ name="Zaihua Ji", email="zji@ucar.edu" },
1010
]

src/rda_python_common/PgLOG.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,25 +259,23 @@ def send_customized_email(logmsg, emlmsg, logact = 0):
259259
logmsg += ': '
260260
else:
261261
logmsg = ''
262+
msg = emlmsg
262263
for ekey in entries:
263264
entry = entries[ekey][0]
264-
if re.search(r'(^|\n){}:\s*\n'.format(entry), emlmsg, re.I):
265-
ms = None
266-
else:
267-
ms = re.search(r'(^|\n){}:\s*(.+)\n'.format(entry), emlmsg, re.I)
265+
ms = re.search(r'(^|\n)({}: *(.*)\n)'.format(entry), emlmsg, re.I)
268266
if ms:
269-
entries[ekey][2] = ms.group(2)
267+
vals = ms.groups()
268+
msg = re.sub(vals[1], '', msg)
269+
if vals[2]: entries[ekey][2] = vals[2]
270270
elif logact and entries[ekey][1]:
271271
return pglog("{}Missing Entry '{}' for sending email".format(logmsg, entry), logact|ERRLOG)
272272

273+
ret = send_python_email(entries['sb'][2], entries['to'][2], msg, entries['fr'][2], entries['cc'][2])
274+
if ret != SUCCESS and PGLOG['EMLSEND']: ret = pgsystem(PGLOG['EMLSEND'], logact, 4, emlmsg)
275+
273276
logmsg += "Email " + entries['to'][2]
274277
if entries['cc'][2]: logmsg += " Cc'd " + entries['cc'][2]
275278
logmsg += " Subject: " + entries['sb'][2]
276-
277-
ret = FAILURE
278-
if PGLOG['EMLSEND']: ret = pgsystem(PGLOG['EMLSEND'], logact, 4, emlmsg)
279-
if not ret: ret = send_python_email(entries['sb'][2], entries['to'][2], emlmsg, entries['fr'][2], entries['cc'][2], logact)
280-
281279
if ret:
282280
log_email(emlmsg)
283281
if logact: pglog(logmsg, logact&(~EXITLG))

0 commit comments

Comments
 (0)