def send_email(message): m = json.loads(message.get_body()) source = "*****@*****.**" subject = m["name"] + " filed form " + m["form"] body = "Find the filing at: " + m["link"] AWSUtil.send_email(source, subject, body, m["followers"])
if last_entry_index == 0: print("found at 0 quit..") # found the last entry at the 1st position from this call. # nothing to do break else: # found it at some index other than 0 # print("found it... at ", last_entry_index) latest_filings = latest_filings[0:last_entry_index] # all_latest_filings += latest_filings print_filing(latest_filings) filingsDb.insertRecentFilings(latest_filings) # submit to filings queue AWSUtil.push_to_filings_queue(latest_filings, cik_followers) break except ValueError: # there isn't one found on this batch. filingsDb.insertRecentFilings(latest_filings) # submit to filings queue AWSUtil.push_to_filings_queue(latest_filings, cik_followers) # continue on to next page, but sleep for a quick sec. time.sleep(1) continue else: print("No more entries available") break
# This script will poll for messages in SQS and send messages to email queue. import AWSUtil import time import json def send_email(message): m = json.loads(message.get_body()) source = "*****@*****.**" subject = m["name"] + " filed form " + m["form"] body = "Find the filing at: " + m["link"] AWSUtil.send_email(source, subject, body, m["followers"]) while True: messages = AWSUtil.get_filings_queue_messages() if len(messages): for message in messages: send_email(message) AWSUtil.delete_message_batch(messages) time.sleep(5)