diff options
Diffstat (limited to 'python/report_ops')
| -rw-r--r-- | python/report_ops/status.py | 15 | ||||
| -rw-r--r-- | python/report_ops/utils.py | 5 |
2 files changed, 12 insertions, 8 deletions
diff --git a/python/report_ops/status.py b/python/report_ops/status.py index 040431ce..2e91adea 100644 --- a/python/report_ops/status.py +++ b/python/report_ops/status.py @@ -58,10 +58,10 @@ class QuantifiRemote( def process(cls, fname): if fname.startswith("kickout"): # We only want to process status messages here return - file_io = BytesIO() - cls._client.client.retrbinary(f"RETR /OUTGOING/status/{fname}", file_io.write) - file_io.seek(0) - parse = ET.parse(file_io) + buf = BytesIO() + cls._client.client.retrbinary(f"RETR /OUTGOING/status/{fname}", buf.write) + buf.seek(0) + parse = ET.parse(buf) data = {key: value for key, value in parse.getroot().items()} data = data | { "uploadtime": cls.extract_ts(fname), @@ -76,8 +76,11 @@ class QuantifiRemote( item._conn.rollback() else: QuantifiMonitor.stage(data) - QuantifiMonitor.email(fname.removesuffix(".xml"), int(data["errors"]) > 0) - QuantifiMonitor().clear() + buf.seek(0) + QuantifiMonitor.email( + fname.removesuffix(".xml"), int(data["errors"]) > 0, buf.getvalue() + ) + QuantifiMonitor._staging_queue.clear() finally: item._insert_queue.clear() diff --git a/python/report_ops/utils.py b/python/report_ops/utils.py index 5b0c14a7..b1135810 100644 --- a/python/report_ops/utils.py +++ b/python/report_ops/utils.py @@ -5,7 +5,7 @@ from typing import Literal, ClassVar import datetime import csv from serenitas.ops.trade_dataclasses import Deal -from serenitas.utils.exchange import ExchangeMessage +from serenitas.utils.exchange import ExchangeMessage, FileAttachment from serenitas.utils.remote import SftpClient from exchangelib import HTMLBody from tabulate import tabulate @@ -515,7 +515,7 @@ class QuantifiMonitor( num_format=[], ): @classmethod - def email(cls, filename, errors): + def email(cls, filename, errors, buf): if not cls._staging_queue: return cls._em.send_email( @@ -539,6 +539,7 @@ class QuantifiMonitor( "ghorel@lmcg.com", "etsui@lmcg.com", ), + attach=[FileAttachment(name=filename + ".xml", content=buf)], ) |
