Skip to content

Commit 4d0258e

Browse files
osupdate: tweaks to run on desktop
1 parent 4549704 commit 4d0258e

File tree

1 file changed

+14
-5
lines changed
  • internal_filesystem/builtin/apps/com.example.osupdate/assets

1 file changed

+14
-5
lines changed

internal_filesystem/builtin/apps/com.example.osupdate/assets/osupdate.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
appscreen.clean()
33

44
import lvgl as lv
5-
import ota.update
6-
from esp32 import Partition
75
import urequests
86
import ujson
9-
import ota.status
10-
import network
117
import time
128
import _thread
139

@@ -41,7 +37,10 @@ def update_with_lvgl(url):
4137
global install_button, status_label
4238
install_button.add_flag(lv.obj.FLAG.HIDDEN) # or change to cancel button?
4339
status_label.set_text("Update in progress.\nNavigate away to cancel.")
40+
import ota.update
41+
import ota.status
4442
ota.status.status()
43+
from esp32 import Partition
4544
current_partition = Partition(Partition.RUNNING)
4645
print(f"Current partition: {current_partition}")
4746
next_partition = current_partition.get_next_update()
@@ -112,7 +111,9 @@ def show_update_info():
112111
status_label.set_text("Checking for OS updates...")
113112
# URL of the JSON file
114113
url = "http://demo.lnpiggy.com:2121/osupdate.json" # Adjust if the actual JSON URL differs
114+
print(f"osudpate.py: fetching {url}")
115115
try:
116+
print("doing urequests.get()")
116117
# Download the JSON
117118
response = urequests.get(url)
118119
# Check if request was successful
@@ -146,10 +147,18 @@ def show_update_info():
146147
status_label = lv.label(appscreen)
147148
status_label.align(lv.ALIGN.TOP_LEFT,0,NOTIFICATION_BAR_HEIGHT)
148149

149-
if not network.WLAN(network.STA_IF).isconnected():
150+
network_connected = True
151+
try:
152+
import network
153+
network_connected = network.WLAN(network.STA_IF).isconnected()
154+
except Exception as e:
155+
print("Warning: could not check WLAN status:", str(e))
156+
157+
if not network_connected:
150158
status_label.set_text("Error: WiFi is not connected.")
151159
time.sleep(10)
152160
else:
161+
print("Showing update info...")
153162
show_update_info()
154163

155164
print("osupdate.py finished")

0 commit comments

Comments
 (0)