{
- "success": true,
- "value": {
- "_id": "diadaq13",
- "name": "diadaq13",
- "description": "Testing the DAQ system software of the instrument",
- "instrument": "DIA",
- "registration_time": "2013-05-24T03:52:25+00:00",
- "start_time": "2013-05-24T03:50:49+00:00",
- "end_time": "2013-05-24T03:50:50+00:00",
- "leader_account": "gapon",
- "contact_info": "Igor Gaponenko (gapon@slac.stanford.edu)",
- "posix_group": "diadaq13",
- "params": {
- "DATA_PATH": "/reg/data/ana01/",
- "dm_locations": "NERSC"
- }
- }
-}
- {
+ "success": true,
+ "value": {
+ "_id": "diadaq13",
+ "name": "diadaq13",
+ "description": "Testing the DAQ system software of the instrument",
+ "instrument": "DIA",
+ "registration_time": "2013-05-24T03:52:25+00:00",
+ "start_time": "2013-05-24T03:50:49+00:00",
+ "end_time": "2013-05-24T03:50:50+00:00",
+ "leader_account": "gapon",
+ "contact_info": "Igor Gaponenko (gapon@slac.stanford.edu)",
+ "posix_group": "diadaq13",
+ "params": {
+ "DATA_PATH": "/reg/data/ana01/",
+ "dm_locations": "NERSC"
+ }
+ }
+ }
+ By:{0} at:{1}
\n".format(*msg_by_at) - + elog_doc["content"], subtype='html') + "By:{0} at:{1}
\n".format( + *msg_by_at + ) + + elog_doc["content"], + subtype="html", + ) msg.attach(htmlmsg) else: - msg.set_content("By: {0} at: {1}\n\n".format(*msg_by_at) + elog_doc["content"]) + msg.set_content( + "By: {0} at: {1}\n\n".format(*msg_by_at) + elog_doc["content"] + ) msg.make_mixed() for attachment in elog_doc.get("attachments", []): - if 'type' in attachment and '/' in attachment['type']: - maintype, subtype = attachment['type'].split('/', 1) + if "type" in attachment and "/" in attachment["type"]: + maintype, subtype = attachment["type"].split("/", 1) else: maintype, subtype = "application", "data" - with parseImageStoreURL(attachment["url"]).return_url_contents(experiment_name, attachment["url"]) as imgget: - msg.add_attachment(imgget.read(), maintype=maintype, subtype=subtype, filename=attachment['name']) + with parseImageStoreURL(attachment["url"]).return_url_contents( + experiment_name, attachment["url"] + ) as imgget: + msg.add_attachment( + imgget.read(), + maintype=maintype, + subtype=subtype, + filename=attachment["name"], + ) return msg msg = generateEMailMsgFromELogDoc(elog_doc) - msg['Subject'] = '' + "Elog message for " + experiment_name + " " + ("run {0} ".format(elog_doc["run_num"]) if elog_doc.get("run_num", None) else "") + elog_doc.get("title", "") - msg['From'] = 'exp_logbook_robot@slac.stanford.edu' - msg['To'] = ", ".join(full_email_addresses) + msg["Subject"] = ( + "" + + "Elog message for " + + experiment_name + + " " + + ( + "run {0} ".format(elog_doc["run_num"]) + if elog_doc.get("run_num", None) + else "" + ) + + elog_doc.get("title", "") + ) + msg["From"] = "exp_logbook_robot@slac.stanford.edu" + msg["To"] = ", ".join(full_email_addresses) parent_msg = msg while elog_doc.get("parent", None): elog_doc = get_specific_elog_entry(experiment_name, elog_doc["parent"]) @@ -1248,23 +1811,31 @@ def generateEMailMsgFromELogDoc(elog_doc): parent_msg.attach(child_message) parent_msg = child_message - with smtplib.SMTP(os.environ.get("EMAIL_SERVER_HOST", "smtp.slac.stanford.edu"), int(os.environ.get("EMAIL_SERVER_PORT", "25"))) as s: - mailstatus = s.sendmail(msg['From'], full_email_addresses, msg.as_string()) + with smtplib.SMTP( + os.environ.get("EMAIL_SERVER_HOST", "smtp.slac.stanford.edu"), + int(os.environ.get("EMAIL_SERVER_PORT", "25")), + ) as s: + mailstatus = s.sendmail(msg["From"], full_email_addresses, msg.as_string()) if mailstatus: logger.warn(mailstatus) s.quit() except Exception: - logger.exception("Exception sending elog emails for experiment " + experiment_name) + logger.exception( + "Exception sending elog emails for experiment " + experiment_name + ) return True -@explgbk_blueprint.route("/lgbk/