diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/baml.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/python/baml.py b/python/baml.py index 688e1a77..07f3f11c 100644 --- a/python/baml.py +++ b/python/baml.py @@ -17,24 +17,24 @@ def download_messages(em): date = msg.subject.split("-", 1)[1] save_dir = DAILY_DIR / date / "Reports" soup = BeautifulSoup(msg.body, features="lxml") - if title.text == "Proofpoint Encryption": - 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], save_dir, base_url - ) - except ValueError as e: - logger.error(e) - continue - else: - for attach in msg.attachments: - if attach.name.endswith("csv"): - p = save_dir / attach.name - if not p.exists(): - p.write_bytes(attach.content) + if title := soup.find("title"): + if title.text == "Proofpoint Encryption": + 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], save_dir, base_url + ) + except ValueError as e: + logger.error(e) + continue + for attach in msg.attachments: + if attach.name.endswith("csv"): + p = save_dir / attach.name + if not p.exists(): + p.write_bytes(attach.content) def load_cash_report(workdate: datetime.date): |
