Use native Python unzip for updates

This commit is contained in:
Mark Qvist 2023-05-03 12:57:38 +02:00
parent d467ed9ece
commit e386a5d08b
1 changed files with 15 additions and 9 deletions

View File

@ -41,7 +41,7 @@ import RNS
RNS.logtimefmt = "%H:%M:%S" RNS.logtimefmt = "%H:%M:%S"
RNS.compact_log_fmt = True RNS.compact_log_fmt = True
program_version = "2.1.1" program_version = "2.1.2"
eth_addr = "0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a" eth_addr = "0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a"
btc_addr = "3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq" btc_addr = "3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq"
xmr_addr = "87HcDx6jRSkMQ9nPRd5K9hGGpZLn2s7vWETjMaVM5KfV4TD36NcYa8J8WSxhTSvBzzFpqDwp2fg5GX2moZ7VAP9QMZCZGET" xmr_addr = "87HcDx6jRSkMQ9nPRd5K9hGGpZLn2s7vWETjMaVM5KfV4TD36NcYa8J8WSxhTSvBzzFpqDwp2fg5GX2moZ7VAP9QMZCZGET"
@ -2298,8 +2298,12 @@ def main():
try: try:
if fw_filename.endswith(".zip"): if fw_filename.endswith(".zip"):
RNS.log("Decompressing firmware...") RNS.log("Decompressing firmware...")
with zipfile.ZipFile(fw_src+fw_filename) as zip: try:
zip.extractall(fw_src) with zipfile.ZipFile(fw_src+fw_filename) as zip:
zip.extractall(fw_src)
except Exception as e:
RNS.log("Could not decompress firmware from downloaded zip file")
exit()
RNS.log("Firmware decompressed") RNS.log("Firmware decompressed")
RNS.log("Flashing RNode firmware to device on "+args.port) RNS.log("Flashing RNode firmware to device on "+args.port)
@ -2422,13 +2426,15 @@ def main():
ensure_firmware_file(fw_filename) ensure_firmware_file(fw_filename)
if fw_filename.endswith(".zip") and not fw_filename == "extracted_rnode_firmware.zip": if fw_filename.endswith(".zip") and not fw_filename == "extracted_rnode_firmware.zip":
RNS.log("Extracting firmware...") RNS.log("Decompressing firmware...")
unzip_status = call(get_flasher_call("unzip", fw_filename)) fw_src = UPD_DIR+"/"+selected_version+"/"
if unzip_status == 0: try:
RNS.log("Firmware extracted") with zipfile.ZipFile(fw_src+fw_filename) as zip:
else: zip.extractall(fw_src)
RNS.log("Could not extract firmware from downloaded zip file") except Exception as e:
RNS.log("Could not decompress firmware from downloaded zip file")
exit() exit()
RNS.log("Firmware decompressed")
except Exception as e: except Exception as e:
RNS.log("Could not obtain firmware package for your board") RNS.log("Could not obtain firmware package for your board")