#NEWLINE# def handle_noargs( self , **options ) : #NEWLINE# #INDENT# 'Send Report E-mails.' #NEWLINE# r = get_r ( ) #NEWLINE# since = ( datetime . utcnow ( ) - timedelta ( days = 1 ) ) #NEWLINE# metrics = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# categories = r . metric_slugs_by_category ( ) #NEWLINE# for ( category_name , slug_list ) in categories . items ( ) : #NEWLINE# #INDENT# metrics [ category_name ] = [ ] #NEWLINE# for slug in slug_list : #NEWLINE# #INDENT# metric_values = r . get_metric_history ( slug , since = since ) #NEWLINE# metrics [ category_name ] . append ( ( slug , metric_values ) ) #NEWLINE# #UNINDENT# #UNINDENT# template = 'redis_metrics/email/report.{fmt}' #NEWLINE# data = { #NEWLINE# #INDENT# 'today' : message , #NEWLINE# 'metrics' : metrics , #NEWLINE# #UNINDENT# } #NEWLINE# message = render_to_string ( template . format ( fmt = 'txt' ) , data ) #NEWLINE# message_html = render_to_string ( template . format ( fmt = 'html' ) , data ) #NEWLINE# msg = EmailMultiAlternatives ( subject = 'Redis Metrics Report' , body = message , from_email = settings . DEFAULT_FROM_EMAIL , to = [ email for ( name , email ) in settings . ADMINS ] ) #NEWLINE# msg . attach_alternative ( message_html , 'text/html' ) #NEWLINE# msg . send ( )