Skip to content

Instantly share code, notes, and snippets.

@masci
Created March 21, 2016 23:18
Show Gist options
  • Save masci/11f9a49c8a68f831fa10 to your computer and use it in GitHub Desktop.
Save masci/11f9a49c8a68f831fa10 to your computer and use it in GitHub Desktop.
import boto.ses
from collections import defaultdict
REGION='us-east-1'
AWS_KEY='YOUR_KEY'
AWS_SECRET='YOUR_SECRET'
def main():
cses = boto.ses.connect_to_region(REGION, aws_access_key_id=AWS_KEY, aws_secret_access_key=AWS_SECRET)
send_statistics = cses.get_send_statistics()
send_data_points_resp = send_statistics['GetSendStatisticsResponse']
send_data_points = send_data_points_resp['GetSendStatisticsResult']['SendDataPoints']
send_data_points = sorted(send_data_points, key=lambda x: x['Timestamp'])
print('Found {} data points.'.format(len(send_data_points)))
print('Timestamp | Complaints | DeliveryAttempts | Bounces | Rejects')
totals = defaultdict(int)
for p in send_data_points:
print('{0} | {1: <9} | {2: <16} | {3: <7} | {4} '.format(p['Timestamp'], p['Complaints'], p['DeliveryAttempts'], p['Bounces'], p['Rejects']))
for k in ('Complaints', 'DeliveryAttempts', 'Bounces', 'Rejects'):
totals[k] += int(p[k])
print('{0} | {1: <9} | {2: <16} | {3: <7} | {4} '.format(' '*20, totals['Complaints'], totals['DeliveryAttempts'], totals['Bounces'], totals['Rejects']))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment