From 7218fabad6f63bc01ddf75e94b5fa6323eb6c6a1 Mon Sep 17 00:00:00 2001 From: NCLanceman Date: Thu, 19 Jun 2025 16:45:56 -0500 Subject: [PATCH] portable code --- __pycache__/iconSelector.cpython-310.pyc | Bin 0 -> 1635 bytes iconSelector.py | 6 +++--- readme.md | 2 +- weather.py | 8 ++++++-- weather.sh | 4 ++++ 5 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 __pycache__/iconSelector.cpython-310.pyc create mode 100755 weather.sh diff --git a/__pycache__/iconSelector.cpython-310.pyc b/__pycache__/iconSelector.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2c6d9658e04704ea90bdc28367240efd44d3f066 GIT binary patch literal 1635 zcmZux&yO256t+E+$;@n$&6Xc2qLda|Afmews<?X6F83%i^ zOQKya@Q3Vj<6rWXQ{jS;I8Y(M_a;d@tvZoEzwh&VcKrNo-R;H?xu6g@4I@;^WqYN$(dv4x}$z6ESYfK(^6`&_n1E z`Urh2W4Q%=OLk-zeMk1>_RnnGm3_H`z9+>I8(w*gRoPHD|1hbhu6sB)>QLM42cieV zzy(&FD5G3t)1<0kNf*o#Q{@X66xveX%CpI|a;>RKPQcP!CC0Vvyet>aH%V5yww>xz zW$e&%-a|ccevw%O*g`*2(EQV^l&(dH_{rQ>)&*&<=b)j+@@WG1ZZ(~k60=m=6xMZ` zH0897^+y?{_63^#5pc#X*d@E*l3((3e#ZCNgS+SAOjP28nf~_?EDzQI`9@B_e6Z_a zUd>uyx550H1z>l;S~Y8f-31G37J_{O);?lD%q2tQI68R3Zy2fq(;?^)>=3+4FaS7s zA&-`s7&*uOjVJTqnXjPwjIqD)l`?Gi7E?SetW7=6v~XURF_98 zhle(MvxV!UAgtQQ>?WI4nJ#H__7tP2cr+38|`jJWe;P=jkUHnBT;j<{ze_{9GEw--J6w@EEba}0L|z~(o^MC$4 Bs-pk^ literal 0 HcmV?d00001 diff --git a/iconSelector.py b/iconSelector.py index d970f94..d13231f 100644 --- a/iconSelector.py +++ b/iconSelector.py @@ -1,9 +1,9 @@ from pathlib import Path, PurePosixPath import os -currentDirectory = os.getcwd() -currentDirHC = "/home/nclanceman/tools/weather" +# currentDirectory = os.getcwd() +# currentDirectory = "/home/nclanceman/tools/weather" -# currentDirectory = PurePosixPath(Path.cwd()) +currentDirectory = PurePosixPath(Path.cwd()) adjectives = ["severe", "scattered", "partly", "mostly", "light", "heavy"] clearWords = ["clear", "sunny"] diff --git a/readme.md b/readme.md index 86b58bc..282dffe 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,7 @@ For use in XFCE for monitoring weather from a given station using the National W Instructions: - Download files -- Run weather.py from XFCE GenMon as path/to/script/weather.py STATIONNAME +- Run test.sh from XFCE genMon as path/to/script/test.sh STATIONAME Without a station name, the script will report the weather at Hartsfield-Jackson International Airport in Atlanta, GA. diff --git a/weather.py b/weather.py index 33686c1..526e7e2 100644 --- a/weather.py +++ b/weather.py @@ -97,9 +97,13 @@ else: roundedTemp = rounding(temp) condition = request_json["properties"]["textDescription"] parsedCondition = iconSelect.parseDescription(condition) - timeOfDay = request_json['properties']['icon'].split("/")[5] + + if not (request_json['properties']['icon']): + timeOfDay = "day" + else: + timeOfDay = request_json['properties']['icon'].split("/")[5] weatherIcon = iconSelect.imageSelector(parsedCondition, timeOfDay) # print(f" \u2601 {condition}, {roundedTemp} F") print( - f"{weatherIcon}{roundedTemp}F") + f"{weatherIcon} {roundedTemp}F") print(tooltipPrinter(request_json)) diff --git a/weather.sh b/weather.sh new file mode 100755 index 0000000..63f76dd --- /dev/null +++ b/weather.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cd "$(dirname "$0")" +SCRIPT_DIR="$(pwd)" +python3 $SCRIPT_DIR/weather.py $1