validate.notify#

Email the user when a run finishes, through the machine’s own mail system (sendmail).

The email carries only the run’s status and duration and where to find its files: the settings file (analysis.yaml), the folder holding it and the run’s outputs, and the error log when there were errors. No patient data or results. The address isn’t saved.

Functions

findSendmail()

Path to sendmail, or None if this machine has none.

formatDuration(seconds)

e.g. "1 h 12 min 5 s", "3 min 20 s", "42 s".

isValidAddress(address)

True if address is a single plain email address (e.g. name@example.org).

runEmail(address, tab, succeeded, reason, ...)

The notification email for a finished run.

sendEmail(message[, timeout])

Hand message to the machine's mail system (sendmail).

validate.notify.isValidAddress(address)[source]#

True if address is a single plain email address (e.g. name@example.org).

validate.notify.findSendmail()[source]#

Path to sendmail, or None if this machine has none.

validate.notify.formatDuration(seconds)[source]#

e.g. “1 h 12 min 5 s”, “3 min 20 s”, “42 s”.

validate.notify.runEmail(address, tab, succeeded, reason, seconds, analysisDir, settingsFile, errorLogPath=None)[source]#

The notification email for a finished run.

Parameters:
  • address (str) – recipient.

  • tab (str) – the run’s tab, e.g. “Segment”.

  • succeeded (bool) – True if the run finished with no errors.

  • reason (str or None) – why the status is error (e.g. “2 of 20 patients failed”).

  • seconds (float) – run time.

  • analysisDir (str) – the analysis folder.

  • settingsFile (str) – file name of the settings in analysisDir (analysis.yaml).

  • errorLogPath (str or None) – the run’s error log, listed when the status is error.

Returns:

email.message.EmailMessage

validate.notify.sendEmail(message, timeout=30)[source]#

Hand message to the machine’s mail system (sendmail).

Delivery depends on the machine’s mail set-up: sendmail accepting the message doesn’t mean it was delivered.

Raises:

RuntimeError – there’s no sendmail, or it refused the message.