Skip to content

Commit 65e7404

Browse files
Get rid of urequests (new module is called requests)
1 parent e76ff00 commit 65e7404

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import lvgl as lv
22
import json
3-
import urequests
3+
import requests
44
import gc
55
import os
66
import time
@@ -113,7 +113,7 @@ def set_install_label(app_fullname):
113113
def download_icon(url):
114114
print(f"Downloading icon from {url}")
115115
try:
116-
response = urequests.get(url, timeout=5)
116+
response = requests.get(url, timeout=5)
117117
if response.status_code == 200:
118118
image_data = response.content
119119
print("Downloaded image, size:", len(image_data), "bytes")
@@ -169,7 +169,7 @@ def download_and_unzip(zip_url, dest_folder, app_fullname):
169169
try:
170170
# Step 1: Download the .mpk file
171171
print(f"Downloading .mpk file from: {zip_url}")
172-
response = urequests.get(zip_url, timeout=10)
172+
response = requests.get(zip_url, timeout=10)
173173
if response.status_code != 200:
174174
print("Download failed: Status code", response.status_code)
175175
response.close()
@@ -228,7 +228,7 @@ def download_and_unzip(zip_url, dest_folder, app_fullname):
228228
def download_apps(json_url):
229229
global apps, please_wait_label
230230
try:
231-
response = urequests.get(json_url, timeout=10)
231+
response = requests.get(json_url, timeout=10)
232232
except Exception as e:
233233
print("Download failed:", e)
234234
lv.async_call(lambda l: please_wait_label.set_text(f"Error downloading app index: {e}"), None)
@@ -250,7 +250,7 @@ def download_icons():
250250
image_dsc = download_icon(app.icon_url)
251251
app.image_dsc = image_dsc # save it for the app detail page
252252
lv.async_call(lambda l: app.image.set_src(image_dsc), None)
253-
time.sleep_ms(round(th.duration*1.5)) # not waiting here will result in some async_calls() not being executed
253+
time.sleep_ms(round(th.duration*2)) # not waiting here will result in some async_calls() not being executed
254254
print("Finished downloading icons...")
255255

256256

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
appscreen.clean()
33

44
import lvgl as lv
5-
import urequests
5+
import requests
66
import ujson
77
import time
88
import _thread
@@ -59,7 +59,7 @@ def progress_callback(percent):
5959
progress_bar.set_value(int(percent), lv.ANIM.ON)
6060
current = Partition(Partition.RUNNING)
6161
next_partition = current.get_next_update()
62-
response = urequests.get(url, stream=True)
62+
response = requests.get(url, stream=True)
6363
total_size = int(response.headers.get('Content-Length', 0))
6464
bytes_written = 0
6565
chunk_size = 4096
@@ -113,9 +113,9 @@ def show_update_info():
113113
url = "http://demo.lnpiggy.com:2121/osupdate.json" # Adjust if the actual JSON URL differs
114114
print(f"osudpate.py: fetching {url}")
115115
try:
116-
print("doing urequests.get()")
116+
print("doing requests.get()")
117117
# Download the JSON
118-
response = urequests.get(url)
118+
response = requests.get(url)
119119
# Check if request was successful
120120
if response.status_code == 200:
121121
# Parse JSON
-101 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)