sharnett / myweather

simple weather forecast webpage
www.seanweather.com
6 stars 3 forks source link

better reporting #16

Closed sharnett closed 7 years ago

sharnett commented 10 years ago

Check this out: https://github.com/adamhadani/logtools

sharnett commented 8 years ago

Update the info in the daily email to include location_name and zmw. Make it say 'daily' report instead of 'weekly'. Commit the analysis scripts.

sharnett commented 8 years ago

!/usr/bin/python

import pandas as pd import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.header import Header from email_credentials import email_credentials from dateutil.parser import parse

def send_mail(data): mailhost, fromaddr, toaddrs, subject, credentials = email_credentials() username, password = credentials subject = 'seanweather daily report' body = 'Here are some interesting results, my good-looking friend:\n\n' + data msg = MIMEText(body, 'html', _charset="UTF-8") msg['Subject'] = Header(subject, "utf-8") server = smtplib.SMTP(mailhost) server.starttls() server.login(username, password) server.sendmail(fromaddr, toaddrs, msg.as_string()) server.quit()

if name == 'main': counts = [42, 4, 3, 1] cities = ['10027 - New York, NY', 'McLean, Virginia', '94110 - San Francisco, CA', '08904 - Highland Park, NJ'] style = '''''' data = pd.DataFrame(dict(Count=counts, City=cities)).to_html(index=False, col_space=3, justify='left') msg = '\n' + style + '\n\n\n' + data + '\n' print(msg) send_mail(msg)