Skip to content

Commit

Permalink
gui: don't crash when checking for new version of flasher if no internet
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzwald committed May 31, 2024
1 parent 69e1d04 commit a59826b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions esphomeflasher/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import io

from urllib.parse import urljoin
from urllib.request import urlopen
import urllib.request
import urllib.error

import wx
import wx.adv
Expand Down Expand Up @@ -380,8 +381,13 @@ def on_pick_file(event):
self.platform_info_text.SetLabel("")

def version_check():
f = urlopen(FUJINET_FLASHER_VERSION_URL)
current_ver = f.read().decode('utf-8').strip()
try:
f = urllib.request.urlopen(FUJINET_FLASHER_VERSION_URL)
current_ver = f.read().decode('utf-8').strip()
except urllib.error.URLError as e:
print("Error getting version: {}".format(e))
current_ver = __version__ # Fallback to current version if there is an error

if __version__ != current_ver:
self.flasher_ver_text.SetLabel("This version of FujiNet-Flasher is old, Please Update ({}->{})\n at https://fujinet.online/download".format(__version__, current_ver))
else:
Expand Down

0 comments on commit a59826b

Please sign in to comment.