rda-python-common 1.0.37__py3-none-any.whl → 1.0.39__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.

@@ -246,12 +246,12 @@ def get_email():
246
246
  #
247
247
  # send a customized email with all entries included
248
248
  #
249
- def send_customized_email(logmsg, emlmsg, logact = 0):
249
+ def send_customized_email(logmsg, emlmsg, logact = LOGWRN):
250
250
 
251
251
  entries = {
252
252
  'fr' : ["From", 1, None],
253
253
  'to' : ["To", 1, None],
254
- 'cc' : ["Cc", 0, None],
254
+ 'cc' : ["Cc", 0, ''],
255
255
  'sb' : ["Subject", 1, None]
256
256
  }
257
257
 
@@ -267,18 +267,20 @@ def send_customized_email(logmsg, emlmsg, logact = 0):
267
267
  vals = ms.groups()
268
268
  msg = msg.replace(vals[1], '')
269
269
  if vals[2]: entries[ekey][2] = vals[2]
270
- elif logact and entries[ekey][1]:
270
+ elif entries[ekey][1]:
271
271
  return pglog("{}Missing Entry '{}' for sending email".format(logmsg, entry), logact|ERRLOG)
272
272
 
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)
273
+ ret = send_python_email(entries['sb'][2], entries['to'][2], msg, entries['fr'][2], entries['cc'][2], logact)
274
+ if ret == SUCCESS or not PGLOG['EMLSEND']: return ret
275
275
 
276
+ # try commandline sendmail
277
+ ret = pgsystem(PGLOG['EMLSEND'], logact, 4, emlmsg)
276
278
  logmsg += "Email " + entries['to'][2]
277
279
  if entries['cc'][2]: logmsg += " Cc'd " + entries['cc'][2]
278
280
  logmsg += " Subject: " + entries['sb'][2]
279
- if ret:
281
+ if ret:
280
282
  log_email(emlmsg)
281
- if logact: pglog(logmsg, logact&(~EXITLG))
283
+ pglog(logmsg, logact&(~EXITLG))
282
284
  else:
283
285
  errmsg = "Error sending email: " + logmsg
284
286
  pglog(errmsg, (logact|ERRLOG)&~EXITLG)
@@ -288,14 +290,15 @@ def send_customized_email(logmsg, emlmsg, logact = 0):
288
290
  #
289
291
  # send an email; if empty msg send email message saved in PGLOG['EMLMSG'] instead
290
292
  #
291
- def send_email(subject = None, receiver = None, msg = None, sender = None, logact = 0):
293
+ def send_email(subject = None, receiver = None, msg = None, sender = None, logact = LOGWRN):
292
294
 
293
295
  return send_python_email(subject, receiver, msg, sender, None, logact)
294
296
 
295
297
  #
296
- # send an email via python module smtplib; if empty msg send email message saved in PGLOG['EMLMSG'] instead
298
+ # send an email via python module smtplib; if empty msg send email message saved
299
+ # in PGLOG['EMLMSG'] instead. pass cc = '' for skipping 'Cc: '
297
300
  #
298
- def send_python_email(subject = None, receiver = None, msg = None, sender = None, cc = None, logact = 0):
301
+ def send_python_email(subject = None, receiver = None, msg = None, sender = None, cc = None, logact = LOGWRN):
299
302
 
300
303
  if not msg:
301
304
  if PGLOG['EMLMSG']:
@@ -321,7 +324,7 @@ def send_python_email(subject = None, receiver = None, msg = None, sender = None
321
324
  emlmsg['From'] = sender
322
325
  emlmsg['To'] = receiver
323
326
  logmsg = "Email " + receiver
324
- if not cc: cc = PGLOG['CCDADDR']
327
+ if cc == None: cc = PGLOG['CCDADDR']
325
328
  if cc:
326
329
  emlmsg['Cc'] = cc
327
330
  logmsg += " Cc'd " + cc
@@ -339,7 +342,7 @@ def send_python_email(subject = None, receiver = None, msg = None, sender = None
339
342
  finally:
340
343
  eml.quit()
341
344
  log_email(str(emlmsg))
342
- if logact: pglog(logmsg, logact&~EXITLG)
345
+ pglog(logmsg, logact&~EXITLG)
343
346
  return SUCCESS
344
347
 
345
348
  #
@@ -414,7 +417,7 @@ def pglog(msg, logact = MSGLOG):
414
417
  if logact&EMLALL:
415
418
  if logact&SNDEML or not msg:
416
419
  title = (msg if msg else "Message from {}-{}".format(PGLOG['HOSTNAME'], get_command()))
417
- msg = title + '\n' + msg
420
+ msg = title
418
421
  send_email(title.rstrip())
419
422
  elif msg:
420
423
  set_email(msg, logact)
@@ -1682,8 +1682,10 @@ def send_request_email_notice(pgrqst, errmsg, fcount, rstat, readyfile = None, p
1682
1682
  einfo['GLOBUS_TASK_URL'] = "https://app.globus.org/activity/" + pgrqst['task_id']
1683
1683
 
1684
1684
  for ekey in einfo:
1685
- ebuf = re.sub(r'<{}>'.format(ekey), einfo[ekey], ebuf)
1686
-
1685
+ if ekey == 'CCD' and not einfo['CCD']:
1686
+ ebuf = re.sub(r'Cc:\s*<CCD>\s*', '', ebuf)
1687
+ else:
1688
+ ebuf = re.sub(r'<{}>'.format(ekey), einfo[ekey], ebuf)
1687
1689
 
1688
1690
  if PgLOG.PGLOG['DSCHECK'] and not pgpart:
1689
1691
  tbl = "dscheck"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_common
3
- Version: 1.0.37
3
+ Version: 1.0.39
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
2
  rda_python_common/PgDBI.py,sha256=12qnRXO7pWv8togtTsOvtVuGtwixnR-s2vLGPpdDfHw,74658
3
3
  rda_python_common/PgFile.py,sha256=gJuzBxLRYo3HQyNW1WNYDsQWRei2cco9bYEb6uOL8Ds,98487
4
- rda_python_common/PgLOG.py,sha256=AxEajxYDOzEEsvCEOCQ-WwKTQvL3ufJcOjCJ9el93lQ,55238
4
+ rda_python_common/PgLOG.py,sha256=aY6EuPaIJlMEdfxR7_amraiwNnaKyU9CgW1LJ0jXWd4,55295
5
5
  rda_python_common/PgLock.py,sha256=12i84nsGBuifSyPnm8IR63LvHvRuVU573D5QKFlHdOI,22623
6
- rda_python_common/PgOPT.py,sha256=zX8lWFdfV6GxjLKfMc9eM76mjIjss_ulPieerejcmks,55936
6
+ rda_python_common/PgOPT.py,sha256=Sf--l5iKY82xF5NbXxEy8PWip7ACpaa3KLdMac7E-oc,56047
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.37.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
12
- rda_python_common-1.0.37.dist-info/METADATA,sha256=1_mZhDeUtUXg7GWnZQQlACo3jF1kHYWn2172h1CSbYo,716
13
- rda_python_common-1.0.37.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- rda_python_common-1.0.37.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
15
- rda_python_common-1.0.37.dist-info/RECORD,,
11
+ rda_python_common-1.0.39.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
12
+ rda_python_common-1.0.39.dist-info/METADATA,sha256=xVyK12SKzrcCt0yyxJ3O8BNTnPongZxU62638IqSHmw,716
13
+ rda_python_common-1.0.39.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ rda_python_common-1.0.39.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
15
+ rda_python_common-1.0.39.dist-info/RECORD,,