Skip to content

Commit

Permalink
v2.0.5 Better error handling if BOM fails to return data
Browse files Browse the repository at this point in the history
  • Loading branch information
bossanova808 committed Feb 7, 2022
1 parent 45db28b commit 9fe0a62
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
9 changes: 3 additions & 6 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="weather.ozweather" name="Oz Weather" version="2.0.4" provider-name="Bossanova808">
<addon id="weather.ozweather" name="Oz Weather" version="2.0.5" provider-name="Bossanova808">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.22.0+matrix.1"/>
Expand All @@ -22,11 +22,8 @@
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
</assets>
<news>v2.0.4
- Remove WeatherZone support due to upstream site being totally revised
v2.0.3
- Set some limits to prevent issues with the BOM suddenly supplying days, not hours, worth of images
- Fix missing weathercode
<news>v2.0.5
- Improve error handling if the BOM disappears for a bit...
</news>
</extension>
</addon>
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.0.5
- Improve error handling if the BOM disappears for a bit...

v2.0.4
- Remove WeatherZone support due to upstream site being totally revised

Expand Down
35 changes: 17 additions & 18 deletions resources/lib/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,26 @@ def forecast(geohash, radar_code):
build_images(radar_code, backgrounds_path, overlay_loop_path)
set_property(WEATHER_WINDOW, 'Radar', radar_code)

# Finally set some labels so we can see when the loop runs from, to
list_of_loop_files = glob.glob(overlay_loop_path + "*")

# Finally, set some labels, so we can see the time period the loop covers
list_of_loop_files = list(filter(os.path.isfile, glob.glob(overlay_loop_path + "*")))
list_of_loop_files.sort(key=lambda x: os.path.getmtime(x))

oldest_file = list_of_loop_files[0]
newest_file = list_of_loop_files[-1]
# utc - get from filename of oldest and newest - it's the last number before the .png
utc_oldest = oldest_file.split('.')[-2]
utc_newest = newest_file.split('.')[-2]
log(f"utc_oldest {utc_oldest}")
log(f"utc_newest {utc_newest}")
if list_of_loop_files:
oldest_file = list_of_loop_files[0]
newest_file = list_of_loop_files[-1]
# utc - get from filename of oldest and newest - it's the last number before the .png
utc_oldest = oldest_file.split('.')[-2]
utc_newest = newest_file.split('.')[-2]
log(f"utc_oldest {utc_oldest}")
log(f"utc_newest {utc_newest}")

time_oldest = utc_str_to_local_str(utc_oldest, "%Y%m%d%H%M")
time_newest = utc_str_to_local_str(utc_newest, "%Y%m%d%H%M")
time_oldest = utc_str_to_local_str(utc_oldest, "%Y%m%d%H%M")
time_newest = utc_str_to_local_str(utc_newest, "%Y%m%d%H%M")

oldest_dt = datetime.datetime.fromtimestamp(os.path.getctime(oldest_file))
newest_dt = datetime.datetime.fromtimestamp(os.path.getctime(newest_file))
set_property(WEATHER_WINDOW, 'RadarOldest', time_oldest)
set_property(WEATHER_WINDOW, 'RadarNewest', time_newest)
oldest_dt = datetime.datetime.fromtimestamp(os.path.getctime(oldest_file))
newest_dt = datetime.datetime.fromtimestamp(os.path.getctime(newest_file))
set_property(WEATHER_WINDOW, 'RadarOldest', time_oldest)
set_property(WEATHER_WINDOW, 'RadarNewest', time_newest)

# Get all the weather & forecast data from the BOM API
weather_data = False
Expand All @@ -184,7 +183,7 @@ def forecast(geohash, radar_code):
for weather_key in sorted(weather_data):
set_property(WEATHER_WINDOW, weather_key, weather_data[weather_key])

# Get the ABC 90 second weather video link if extended features is enabled
# Get the ABC 90-second weather video link if extended features is enabled
if extended_features:
log("Getting the ABC weather video link")
url = get_abc_weather_video_link(ADDON.getSetting("ABCQuality"))
Expand All @@ -209,7 +208,7 @@ def get_weather():
clear_properties()

# This is/was an attempt to use conditions in skins to basically auto-adapt the MyWeather.xml and all OzWeather
# components to the currently in use skin. However not matter what I try I can't get the coditions to work
# components to the currently-in-use skin. However, no matter what I try I can't get the conditions to work
# in the skin files.
try:
skin_in_use = xbmc.getSkinDir().split('.')[1]
Expand Down

0 comments on commit 9fe0a62

Please sign in to comment.