本文整理汇总了Python中boto.ses.SESConnection.get_send_statistics方法的典型用法代码示例。如果您正苦于以下问题:Python SESConnection.get_send_statistics方法的具体用法?Python SESConnection.get_send_statistics怎么用?Python SESConnection.get_send_statistics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.ses.SESConnection
的用法示例。
在下文中一共展示了SESConnection.get_send_statistics方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dashboard
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import get_send_statistics [as 别名]
def dashboard(request):
"""
Graph SES send statistics over time.
"""
cache_key = 'vhash:django_ses_stats'
cached_view = cache.get(cache_key)
if cached_view:
return cached_view
region = RegionInfo(
name=getattr(settings, 'AWS_SES_REGION_NAME',
SESConnection.DefaultRegionName),
endpoint=getattr(settings, 'AWS_SES_REGION_ENDPOINT',
SESConnection.DefaultRegionEndpoint))
ses_conn = SESConnection(
aws_access_key_id=getattr(settings, 'AWS_ACCESS_KEY_ID', None),
aws_secret_access_key=getattr(settings, 'AWS_SECRET_ACCESS_KEY', None),
region=region)
quota_dict = ses_conn.get_send_quota()
verified_emails_dict = ses_conn.list_verified_email_addresses()
stats = ses_conn.get_send_statistics()
quota = quota_parse(quota_dict)
verified_emails = emails_parse(verified_emails_dict)
ordered_data = stats_to_list(stats)
summary = sum_stats(ordered_data)
extra_context = {
'title': 'SES Statistics',
'datapoints': ordered_data,
'24hour_quota': quota['Max24HourSend'],
'24hour_sent': quota['SentLast24Hours'],
'24hour_remaining': float(quota['Max24HourSend']) -
float(quota['SentLast24Hours']),
'persecond_rate': quota['MaxSendRate'],
'verified_emails': verified_emails,
'summary': summary,
'access_key': ses_conn.gs_access_key_id,
'local_time': True if pytz else False,
}
response = render_to_response(
'django_ses/send_stats.html',
extra_context,
context_instance=RequestContext(request))
cache.set(cache_key, response, 60 * 15) # Cache for 15 minutes
return response
示例2: dashboard
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import get_send_statistics [as 别名]
def dashboard(request):
"""
Graph SES send statistics over time.
"""
cache_key = 'vhash:django_ses_stats'
cached_view = cache.get(cache_key)
if cached_view:
return cached_view
region = RegionInfo(
name=settings.AWS_SES_REGION_NAME,
endpoint=settings.AWS_SES_REGION_ENDPOINT)
ses_conn = SESConnection(
aws_access_key_id=settings.ACCESS_KEY,
aws_secret_access_key=settings.SECRET_KEY,
region=region,
proxy=settings.AWS_SES_PROXY,
proxy_port=settings.AWS_SES_PROXY_PORT,
)
quota_dict = ses_conn.get_send_quota()
verified_emails_dict = ses_conn.list_verified_email_addresses()
stats = ses_conn.get_send_statistics()
quota = quota_parse(quota_dict)
verified_emails = emails_parse(verified_emails_dict)
ordered_data = stats_to_list(stats)
summary = sum_stats(ordered_data)
extra_context = {
'title': 'SES Statistics',
'datapoints': ordered_data,
'24hour_quota': quota['Max24HourSend'],
'24hour_sent': quota['SentLast24Hours'],
'24hour_remaining': float(quota['Max24HourSend']) -
float(quota['SentLast24Hours']),
'persecond_rate': quota['MaxSendRate'],
'verified_emails': verified_emails,
'summary': summary,
'access_key': ses_conn.gs_access_key_id,
'local_time': True,
}
response = render(request, 'django_ses/send_stats.html', extra_context)
cache.set(cache_key, response, 60 * 15) # Cache for 15 minutes
return response
示例3: dashboard
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import get_send_statistics [as 别名]
def dashboard(request):
"""
Graph SES send statistics over time.
"""
cache_key = "vhash:django_ses_stats"
cached_view = cache.get(cache_key)
if cached_view:
return cached_view
region = RegionInfo(name=settings.AWS_SES_REGION_NAME, endpoint=settings.AWS_SES_REGION_ENDPOINT)
ses_conn = SESConnection(
aws_access_key_id=settings.ACCESS_KEY,
aws_secret_access_key=settings.SECRET_KEY,
region=region,
boto_profile_name=settings.BOTO_PROFILE_NAME,
)
quota_dict = ses_conn.get_send_quota()
verified_emails_dict = ses_conn.list_verified_email_addresses()
stats = ses_conn.get_send_statistics()
quota = quota_parse(quota_dict)
verified_emails = emails_parse(verified_emails_dict)
ordered_data = stats_to_list(stats)
summary = sum_stats(ordered_data)
extra_context = {
"title": "SES Statistics",
"datapoints": ordered_data,
"24hour_quota": quota["Max24HourSend"],
"24hour_sent": quota["SentLast24Hours"],
"24hour_remaining": float(quota["Max24HourSend"]) - float(quota["SentLast24Hours"]),
"persecond_rate": quota["MaxSendRate"],
"verified_emails": verified_emails,
"summary": summary,
"access_key": ses_conn.gs_access_key_id,
"local_time": True if pytz else False,
}
response = render_to_response("django_ses/send_stats.html", extra_context, context_instance=RequestContext(request))
cache.set(cache_key, response, 60 * 15) # Cache for 15 minutes
return response
示例4: handle
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import get_send_statistics [as 别名]
def handle(self, *args, **options):
connection = SESConnection(
aws_access_key_id=settings.ACCESS_KEY,
aws_secret_access_key=settings.SECRET_KEY,
proxy=settings.AWS_SES_PROXY,
proxy_port=settings.AWS_SES_PROXY_PORT,
proxy_user=settings.AWS_SES_PROXY_USER,
proxy_pass=settings.AWS_SES_PROXY_PASS,
)
stats = connection.get_send_statistics()
data_points = stats_to_list(stats, localize=False)
stats_dict = defaultdict(stat_factory)
for data in data_points:
attempts = int(data['DeliveryAttempts'])
bounces = int(data['Bounces'])
complaints = int(data['Complaints'])
rejects = int(data['Rejects'])
date = data['Timestamp'].split('T')[0]
stats_dict[date]['delivery_attempts'] += attempts
stats_dict[date]['bounces'] += bounces
stats_dict[date]['complaints'] += complaints
stats_dict[date]['rejects'] += rejects
for k, v in stats_dict.items():
stat, created = SESStat.objects.get_or_create(
date=k,
defaults={
'delivery_attempts': v['delivery_attempts'],
'bounces': v['bounces'],
'complaints': v['complaints'],
'rejects': v['rejects'],
})
# If statistic is not new, modify data if values are different
if not created and stat.delivery_attempts != v['delivery_attempts']:
stat.delivery_attempts = v['delivery_attempts']
stat.bounces = v['bounces']
stat.complaints = v['complaints']
stat.rejects = v['rejects']
stat.save()
示例5: handle
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import get_send_statistics [as 别名]
def handle(self, *args, **options):
connection = SESConnection(
aws_access_key_id=getattr(settings, "AWS_ACCESS_KEY_ID", None),
aws_secret_access_key=getattr(settings, "AWS_SECRET_ACCESS_KEY", None),
)
stats = connection.get_send_statistics()
data_points = stats_to_list(stats, localize=False)
stats_dict = defaultdict(stat_factory)
for data in data_points:
attempts = int(data["DeliveryAttempts"])
bounces = int(data["Bounces"])
complaints = int(data["Complaints"])
rejects = int(data["Rejects"])
date = data["Timestamp"].split("T")[0]
stats_dict[date]["delivery_attempts"] += attempts
stats_dict[date]["bounces"] += bounces
stats_dict[date]["complaints"] += complaints
stats_dict[date]["rejects"] += rejects
for k, v in stats_dict.items():
stat, created = SESStat.objects.get_or_create(
date=k,
defaults={
"delivery_attempts": v["delivery_attempts"],
"bounces": v["bounces"],
"complaints": v["complaints"],
"rejects": v["rejects"],
},
)
# If statistic is not new, modify data if values are different
if not created and stat.delivery_attempts != v["delivery_attempts"]:
stat.delivery_attempts = v["delivery_attempts"]
stat.bounces = v["bounces"]
stat.complaints = v["complaints"]
stat.rejects = v["rejects"]
stat.save()