weatherbot
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
weatherbot [2014/08/30 14:42] – [Talking to WeatherBot] sekula | weatherbot [2014/08/31 03:23] (current) – [Talking to WeatherBot] sekula | ||
---|---|---|---|
Line 45: | Line 45: | ||
import subprocess | import subprocess | ||
import os | import os | ||
+ | import unicodedata | ||
from datetime import datetime | from datetime import datetime | ||
Line 122: | Line 123: | ||
def CelsiusToFarenheit(temp_celsius): | def CelsiusToFarenheit(temp_celsius): | ||
return temp_celsius*1.8 + 32.0 | return temp_celsius*1.8 + 32.0 | ||
+ | |||
+ | def FarenheitToCelsius(temp_farenheit): | ||
+ | return (temp_farenheit - 32.0)/1.8 | ||
def KPHToMPH(speed_kph): | def KPHToMPH(speed_kph): | ||
Line 135: | Line 139: | ||
wind_speed_kmh = weather_data[' | wind_speed_kmh = weather_data[' | ||
wind_speed_mph = KPHToMPH(wind_speed_kmh) | wind_speed_mph = KPHToMPH(wind_speed_kmh) | ||
+ | | ||
+ | heat_index_farenheit = -42.379 + 2.04901523*temp_farenheit + 10.14333127*humidity - .22475541*temp_farenheit*humidity - .00683783*temp_farenheit*temp_farenheit - .05481717*humidity*humidity + .00122874*temp_farenheit*temp_farenheit*humidity + .00085282*temp_farenheit*humidity*humidity - .00000199*temp_farenheit*temp_farenheit*humidity*humidity | ||
+ | heat_index_celsius = FarenheitToCelsius(heat_index_farenheit) | ||
| | ||
response = "" | response = "" | ||
Line 143: | Line 150: | ||
response += "< | response += "< | ||
response += "< | response += "< | ||
+ | response += "< | ||
response += "< | response += "< | ||
response += "< | response += "< | ||
Line 276: | Line 284: | ||
pass | pass | ||
| | ||
- | print "%s sent a weather request for the %s for %s, which I will now process..." | + | |
+ | if type(activity.obj.author) == Person: | ||
+ | author = activity.obj.author.display_name | ||
+ | elif type(activity.obj.author) == unicode: | ||
+ | author = unicodedata.normalize(' | ||
+ | else: | ||
+ | author = activity.obj.author | ||
+ | pass | ||
+ | |||
+ | | ||
| | ||
# clean up poor formatting in content | # clean up poor formatting in content | ||
Line 393: | Line 410: | ||
New York,NY,US | New York,NY,US | ||
or | or | ||
- | New York,US | + | Stockholm,SE |
</ | </ | ||
weatherbot.1409409778.txt.gz · Last modified: 2014/08/30 14:42 by sekula