Added fallback version URL to rnodeconf updater

This commit is contained in:
Mark Qvist 2023-02-04 14:18:11 +01:00
parent 42dfee8557
commit e9ae255f84
1 changed files with 25 additions and 1 deletions

View File

@ -881,6 +881,7 @@ class RNode():
selected_version = None selected_version = None
selected_hash = None selected_hash = None
firmware_version_url = "https://unsigned.io/firmware/latest/?v="+program_version+"&variant=" firmware_version_url = "https://unsigned.io/firmware/latest/?v="+program_version+"&variant="
fallback_firmware_version_url = "https://github.com/markqvist/rnode_firmware/releases/latest/download/release.json"
def ensure_firmware_file(fw_filename): def ensure_firmware_file(fw_filename):
global selected_version, selected_hash, upd_nocheck global selected_version, selected_hash, upd_nocheck
if fw_filename == "extracted_rnode_firmware.zip": if fw_filename == "extracted_rnode_firmware.zip":
@ -918,8 +919,31 @@ def ensure_firmware_file(fw_filename):
try: try:
if selected_version == None: if selected_version == None:
if not upd_nocheck: if not upd_nocheck:
try:
try: try:
urlretrieve(firmware_version_url+fw_filename, UPD_DIR+"/"+fw_filename+".version.latest") urlretrieve(firmware_version_url+fw_filename, UPD_DIR+"/"+fw_filename+".version.latest")
except Exception as e:
RNS.log("")
RNS.log("WARNING!")
RNS.log("Failed to retrieve latest version information for your board from the default server")
RNS.log("Will retry using the following fallback URL: "+fallback_firmware_version_url)
RNS.log("")
RNS.log("Hit enter if you want to proceed")
input()
try:
urlretrieve(fallback_firmware_version_url, UPD_DIR+"/fallback_release_info.json")
import json
with open(UPD_DIR+"/fallback_release_info.json", "rb") as rif:
rdat = json.loads(rif.read())
variant = rdat[fw_filename]
with open(UPD_DIR+"/"+fw_filename+".version.latest", "wb") as verf:
inf_str = str(variant["version"])+" "+str(variant["hash"])
verf.write(inf_str.encode("utf-8"))
except Exception as e:
RNS.log("Error while trying fallback URL: "+str(e))
raise e
except Exception as e: except Exception as e:
RNS.log("Failed to retrive latest version information for your board.") RNS.log("Failed to retrive latest version information for your board.")
RNS.log("Check your internet connection and try again.") RNS.log("Check your internet connection and try again.")