vendor-reset less cursed, moved scripts

This commit is contained in:
kat witch 2021-02-27 13:57:42 +00:00
parent b140857acd
commit 17cbf19db4
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
4 changed files with 2 additions and 8 deletions

View file

@ -1,46 +0,0 @@
import requests
import json
import sys
city = sys.argv[1]
api_key = sys.argv[2]
url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric"
weather_icons = {
"Thunderstorm": "",
"Clouds": "",
"Drizzle": "",
"Rain": "",
"Snow": "",
"Clear": "",
"Mist": "",
"Smoke": "",
"Haze": "",
"Dust": "",
"Fog": "",
"Sand": "",
"Ash": "",
"Squall": "",
"Tornado": ""
}
#def degrees_to_cardinal(d):
# dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
# "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]
# ix = int((d + 11.25)/22.5)
# return dirs[ix % 16]
response = requests.get(url)
data = json.loads(response.text)
#print(data)
condition = data["weather"][0]["main"]
weather_icon = weather_icons[condition]
temperature = f"{round(data['main']['temp'])}°C"
feels_like_temperature = f"{round(data['main']['feels_like'])}°C"
humidity = f"{data['main']['humidity']}%"
wind = f"{round(data['wind']['speed'])}m/s" # {degrees_to_cardinal(data['wind']['deg'])}"
end_string = f"{weather_icon} {temperature} {feels_like_temperature} {humidity} {wind}"
print(end_string)