diff options
| -rw-r--r-- | python/baml.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/python/baml.py b/python/baml.py index 45d41cf9..61c17589 100644 --- a/python/baml.py +++ b/python/baml.py @@ -27,13 +27,18 @@ def download_messages(em): path=["SercgmastOps", "Reports"], subject__startswith="Positions-" ): if msg.sender == "mercury-reports@baml.com": - for attach in msg.attachments: - fname = attach.name - if fname.endswith("html"): - # Need to figure out how to access secure id and brand - pass - - return secure_id, brand + soup = BeautifulSoup(msg.body, features="lxml") + a = soup.find("a") + url = urlsplit(a["href"]) + query = parse_qs(url.query) + base_url = urlunsplit(url[:2] + ("",) * 3) + try: + download_from_secure_id( + query["id"][0], query["brand"][0], DATA_DIR, base_url + ) + except ValueError as e: + logger.error(e) + continue def download_from_secure_id( @@ -122,10 +127,7 @@ if __name__ == "__main__": DAILY_DIR / str(args.workdate) / "Reports" - / f"Settled Cash Statement_SERCGMAST_{args.workdate:%d %b %Y}.csv" + / f"Positions_{args.workdate:%d %b %Y}.csv" ) - - secure_id, brand = download_messages(em) - download_from_secure_id(secure_id, brand, p) - + download_messages(em) load_cash_report(args.workdate, p) |
