Created
September 24, 2018 20:23
-
-
Save nwhobart/ecf1f1e1f3846483b1b62f0111c0938c to your computer and use it in GitHub Desktop.
Temperature check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import geocoder | |
import argparse | |
import json | |
from darksky import forecast | |
tomkey = '' | |
darkkey = '' | |
locations = { | |
'work': '', | |
'home': '', | |
'bliss': '', | |
'cabin': '' | |
} | |
parser = argparse.ArgumentParser(description='Weather, son.') | |
parser.add_argument('locations', nargs='?', const=1, default="home", help='name of city, state') | |
args = parser.parse_args() | |
def wx(location): | |
latlng = geocoder.tomtom(location, key=tomkey).latlng | |
info = forecast(darkkey, latlng[0], latlng[1]) | |
wx = json.dumps({ | |
"current_temp": info.temperature, | |
"current_dew_point": info.dewPoint, | |
"todays_high": info['daily']['data'][0]['temperatureHigh'], | |
"summary": info['hourly']['summary']}) | |
return wx | |
print(wx(locations.get(args.locations, args.locations))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment