Skip to content

Commit

Permalink
Be lenient to BFMR failures
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrodman committed Jul 8, 2021
1 parent 722da50 commit bbe2a3d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lib/group_site_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,17 +717,21 @@ def _get_bfmr_costs(self) -> TrackingInfoDict:
msg = email.message_from_string(email_str)
date = datetime.datetime.strptime(
msg['Date'], '%a, %d %b %Y %H:%M:%S %z').strftime('%Y-%m-%d') if msg['Date'] else ''
email_str = email_tracking_retriever.clean_email_content(email_str)
soup = BeautifulSoup(email_str, features="html.parser")

body = soup.find(id='email_body')
if not body:
continue
tables = body.find_all('table')
if not tables or len(tables) < 2:
continue
table = tables[1]
fill_busted_bfmr_costs(result, table, date)
fill_standard_bfmr_costs(result, table, date)
fill_2020_12_22_bfmr_costs(result, table, date)
try:
email_str = email_tracking_retriever.clean_email_content(email_str)
soup = BeautifulSoup(email_str, features="html.parser")

body = soup.find(id='email_body')
if not body:
continue
tables = body.find_all('table')
if not tables or len(tables) < 2:
continue
table = tables[1]
fill_busted_bfmr_costs(result, table, date)
fill_standard_bfmr_costs(result, table, date)
fill_2020_12_22_bfmr_costs(result, table, date)
except:
tqdm.write(f"Error checking BFMR email with date {date}, ignoring...")

return result

0 comments on commit bbe2a3d

Please sign in to comment.