Browse Source

Icon Progress

master
NCLanceman 5 months ago
parent
commit
24f33ec5ea
  1. BIN
      __pycache__/iconSelector.cpython-311.pyc
  2. 21
      iconSelector.py
  3. 5
      readme.md
  4. 5
      weather.py

BIN
__pycache__/iconSelector.cpython-311.pyc

Binary file not shown.

21
iconSelector.py

@ -8,7 +8,8 @@ windWords = ["wind", "windy", "gusts"]
def parseDescription(desc): def parseDescription(desc):
# Parse a weather description by returning the first # Parse a weather description by returning the first
# "weather word" in a NWS description. # "weather word" in a NWS description.
parsed = desc.split(" ") # parsed = ((desc.lower()).split("/")).split(" ")
parsed = ((desc.lower()).split(" "))
for i in parsed: for i in parsed:
if i in adjectives: if i in adjectives:
@ -30,14 +31,20 @@ def parseDescription(desc):
def imageSelector(desc, timeOfDay): def imageSelector(desc, timeOfDay):
match desc: match desc:
case "Clear": case "Clear":
return "./smallIcons/clear-day-small.png" if timeOfDay == "day":
return "/smallIcons/clear-day-small.png"
else:
return "/smallIcons/clear-night-small.png"
case "Cloudy": case "Cloudy":
return "./smallIcons/cloudy-small.png" if timeOfDay == "day":
return "/smallIcons/overcast-day-small.png"
else:
return "/smallIcons/overcast-night-small.png"
case "Wind": case "Wind":
return "./smallIcons/wind-small.png" return "/smallIcons/wind-small.png"
case "Thunderstorm": case "Thunderstorm":
return "./smallIcons/thunderstorms-day-small.png" return "/smallIcons/thunderstorms-rain-small.png"
case "Rain": case "Rain":
return "./smallIcons/rain-small.png" return "/smallIcons/rain-small.png"
return "" return "/smallIcons/code-red-small.png"

5
readme.md

@ -4,6 +4,9 @@ For use in XFCE for monitoring weather from a given station using the National W
Instructions: Instructions:
- Download files - Download files
- Run weather.py from XFCE GenMon as path/to/script/weather.py -station STATIONNAME - Run weather.py from XFCE GenMon as path/to/script/weather.py STATIONNAME
Without a station name, the script will report the weather at Hartsfield-Jackson International Airport in Atlanta, GA. Without a station name, the script will report the weather at Hartsfield-Jackson International Airport in Atlanta, GA.
TODO: add zipcode as a proper arguement and find the nearest station for current observations.
- Five Day Forecast in tooltip.

5
weather.py

@ -1,6 +1,7 @@
import requests import requests
import math import math
import sys import sys
import iconSelector as iconSelect
try: try:
stationName = sys.argv[1] stationName = sys.argv[1]
@ -87,7 +88,9 @@ else:
roundedTemp = rounding(temp) roundedTemp = rounding(temp)
condition = request_json["properties"]["textDescription"] condition = request_json["properties"]["textDescription"]
timeOfDay = request_json['properties']['icon'].split("/")[5] timeOfDay = request_json['properties']['icon'].split("/")[5]
weatherIcon = iconSelect.parseDescription(condition)
weatherIconImage = f"/home/nclanceman/tools/weather{iconSelect.imageSelector(weatherIcon, timeOfDay)}"
# print(f"<txt> \u2601 {condition}, {roundedTemp} F</txt>") # print(f"<txt> \u2601 {condition}, {roundedTemp} F</txt>")
print( print(
f"<img>/home/nclanceman/tools/weather/smallIcons/cloudy-small.png</img><txt> {condition}, {roundedTemp}F</txt>") f"<img>{weatherIconImage}</img><txt> {condition}, {roundedTemp}F</txt>")
print(tooltipPrinter(request_json)) print(tooltipPrinter(request_json))

Loading…
Cancel
Save