Browse Source

head banging

master
NCLanceman 5 months ago
parent
commit
73437acb67
  1. BIN
      __pycache__/iconSelector.cpython-311.pyc
  2. 36
      iconSelector.py
  3. 11
      weather.py

BIN
__pycache__/iconSelector.cpython-311.pyc

Binary file not shown.

36
iconSelector.py

@ -1,3 +1,10 @@
from pathlib import Path, PurePosixPath
import os
currentDirectory = os.getcwd()
currentDirHC = "/home/nclanceman/tools/weather"
# currentDirectory = PurePosixPath(Path.cwd())
adjectives = ["severe", "scattered", "partly", "mostly", "light", "heavy"] adjectives = ["severe", "scattered", "partly", "mostly", "light", "heavy"]
clearWords = ["clear", "sunny"] clearWords = ["clear", "sunny"]
rainWords = ["rain", "showers"] rainWords = ["rain", "showers"]
@ -35,22 +42,35 @@ def parseDescription(desc):
def imageSelector(desc, timeOfDay): def imageSelector(desc, timeOfDay):
result = ""
match desc: match desc:
case "clear": case "clear":
if timeOfDay == "day": if timeOfDay == "day":
return "/smallIcons/clear-day-small.png" result = os.path.join(
currentDirectory, 'smallIcons', 'clear-day-small.png')
else: else:
return "/smallIcons/clear-night-small.png" result = os.path.join(
currentDirectory, 'smallIcons', 'clear-night-small.png')
case "cloudy": case "cloudy":
if timeOfDay == "day": if timeOfDay == "day":
return "/smallIcons/overcast-day-small.png" result = os.path.join(
currentDirectory, 'smallIcons', 'overcast-day-small.png')
else: else:
return "/smallIcons/overcast-night-small.png" result = os.path.join(
currentDirectory, 'smallIcons', 'overcast-night-small.png')
case "wind": case "wind":
return "/smallIcons/wind-small.png" result = os.path.join(
currentDirectory, 'smallIcons', 'wind-small.png')
case "thunderstorm": case "thunderstorm":
return "/smallIcons/thunderstorms-rain-small.png" result = os.path.join(
currentDirectory, 'smallIcons', 'thunderstorms-rain-small.png')
case "rain": case "rain":
return "/smallIcons/rain-small.png" result = os.path.join(
currentDirectory, 'smallIcons', 'rain-small.png')
case _:
result = os.path.join(
currentDirectory, 'smallIcons', 'code-red-small.png')
return "/smallIcons/code-red-small.png" return result

11
weather.py

@ -2,10 +2,8 @@ import requests
import math import math
import sys import sys
import iconSelector as iconSelect import iconSelector as iconSelect
import os
currentDirectory = os.getcwd() weatherIcon = ""
CDHardcode = "/home/nclanceman/tools/weather"
try: try:
stationName = sys.argv[1] stationName = sys.argv[1]
@ -98,11 +96,10 @@ else:
temp = convertToF(request_json["properties"]["temperature"]["value"]) temp = convertToF(request_json["properties"]["temperature"]["value"])
roundedTemp = rounding(temp) roundedTemp = rounding(temp)
condition = request_json["properties"]["textDescription"] condition = request_json["properties"]["textDescription"]
parsedCondition = iconSelect.parseDescription(condition)
timeOfDay = request_json['properties']['icon'].split("/")[5] timeOfDay = request_json['properties']['icon'].split("/")[5]
weatherIcon = iconSelect.parseDescription(condition) weatherIcon = iconSelect.imageSelector(parsedCondition, timeOfDay)
weatherIconImage = currentDirectory +\
iconSelect.imageSelector(weatherIcon, timeOfDay)
# print(f"<txt> \u2601 {condition}, {roundedTemp} F</txt>") # print(f"<txt> \u2601 {condition}, {roundedTemp} F</txt>")
print( print(
f"<img>{weatherIconImage}</img><txt> {roundedTemp}F</txt>") f"<img>{weatherIcon}</img><txt>{roundedTemp}F</txt>")
print(tooltipPrinter(request_json)) print(tooltipPrinter(request_json))

Loading…
Cancel
Save