# print "\n Time taken: %s", time_string # ====================================================================================================== # following are mail sending part current_notifications_count = notifications.count() TEXT = "\nTime taken for the Notification_cleanup_daily script: %s and \nCurrently total number notifications: %s " \ " Total number of notifications cleaned-up: %s \nStart time: %s, and \nEnd time: %s \n compact result: %s" % \ (time_string, current_notifications_count, (total_notifications - current_notifications_count), datetime.datetime.fromtimestamp(int(start_time)).strftime( '%Y-%m-%d %H:%M:%S'), datetime.datetime.fromtimestamp(int(end_time)).strftime( '%Y-%m-%d %H:%M:%S'), compact_result ) #email_list = ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'] email_list = ['*****@*****.**', '*****@*****.**'] send_email_amazon_ses(mail_from='*****@*****.**', mail_to=email_list, message=TEXT) # send_mail_gmail(mail_from='*****@*****.**', mail_to=['*****@*****.**', '*****@*****.**'], # host='smtp.gmail.com', message=TEXT, mail_user='******', mail_pwd='Arcgate1!') except: TEXT = "Exception in running the script, please check log file for more details" \ " Exception: %s" % sys.exc_info()[0] #email_list = ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'] email_list = ['*****@*****.**', '*****@*****.**'] send_email_amazon_ses(mail_from='*****@*****.**', mail_to=email_list, message=TEXT)
print "time taken (in seconds ): ", end_time - start_time print "\nstart time: ", start_time, "end time: ", end_time delta = timedelta(seconds=time_taken) time_string = "%d days %02d:%02d:%02d" % (delta.days, delta.seconds / 3600, (delta.seconds / 60) % 60, delta.seconds % 60) print "\n Time taken: %s", time_string # ====================================================================================================== # following are mail sending part TEXT = "\nTime taken for the notificationmappings script: %s and \nCurrently total number notifications: %s " \ " \nStart time: %s, and \nEnd time: %s" % (time_string, notifications.count(), datetime.datetime.fromtimestamp(int(start_time)).strftime( '%Y-%m-%d %H:%M:%S'), datetime.datetime.fromtimestamp(int(end_time)).strftime( '%Y-%m-%d %H:%M:%S') ) send_email_amazon_ses(mail_from='*****@*****.**', mail_to=['*****@*****.**', '*****@*****.**', '*****@*****.**'], message=TEXT) # send_mail_gmail(mail_from='*****@*****.**', mail_to=['*****@*****.**', '*****@*****.**'], # host='smtp.gmail.com', message=TEXT, mail_user='******', mail_pwd='Arcgate1!') except: TEXT = "Some exception happened: ", sys.exc_info()[0] send_email_amazon_ses(mail_from='*****@*****.**', mail_to=['*****@*****.**', '*****@*****.**', '*****@*****.**'], message=TEXT)