Get rid of urequests (new module is called requests)

This commit is contained in:
Thomas Farstrike
2025-05-17 19:01:34 +02:00
parent e76ff00f6f
commit 65e7404d85
3 changed files with 9 additions and 9 deletions
@@ -1,6 +1,6 @@
import lvgl as lv
import json
import urequests
import requests
import gc
import os
import time
@@ -113,7 +113,7 @@ def set_install_label(app_fullname):
def download_icon(url):
print(f"Downloading icon from {url}")
try:
response = urequests.get(url, timeout=5)
response = requests.get(url, timeout=5)
if response.status_code == 200:
image_data = response.content
print("Downloaded image, size:", len(image_data), "bytes")
@@ -169,7 +169,7 @@ def download_and_unzip(zip_url, dest_folder, app_fullname):
try:
# Step 1: Download the .mpk file
print(f"Downloading .mpk file from: {zip_url}")
response = urequests.get(zip_url, timeout=10)
response = requests.get(zip_url, timeout=10)
if response.status_code != 200:
print("Download failed: Status code", response.status_code)
response.close()
@@ -228,7 +228,7 @@ def download_and_unzip(zip_url, dest_folder, app_fullname):
def download_apps(json_url):
global apps, please_wait_label
try:
response = urequests.get(json_url, timeout=10)
response = requests.get(json_url, timeout=10)
except Exception as e:
print("Download failed:", e)
lv.async_call(lambda l: please_wait_label.set_text(f"Error downloading app index: {e}"), None)
@@ -250,7 +250,7 @@ def download_icons():
image_dsc = download_icon(app.icon_url)
app.image_dsc = image_dsc # save it for the app detail page
lv.async_call(lambda l: app.image.set_src(image_dsc), None)
time.sleep_ms(round(th.duration*1.5)) # not waiting here will result in some async_calls() not being executed
time.sleep_ms(round(th.duration*2)) # not waiting here will result in some async_calls() not being executed
print("Finished downloading icons...")
@@ -2,7 +2,7 @@ appscreen = lv.screen_active()
appscreen.clean()
import lvgl as lv
import urequests
import requests
import ujson
import time
import _thread
@@ -59,7 +59,7 @@ def update_with_lvgl(url):
progress_bar.set_value(int(percent), lv.ANIM.ON)
current = Partition(Partition.RUNNING)
next_partition = current.get_next_update()
response = urequests.get(url, stream=True)
response = requests.get(url, stream=True)
total_size = int(response.headers.get('Content-Length', 0))
bytes_written = 0
chunk_size = 4096
@@ -113,9 +113,9 @@ def show_update_info():
url = "http://demo.lnpiggy.com:2121/osupdate.json" # Adjust if the actual JSON URL differs
print(f"osudpate.py: fetching {url}")
try:
print("doing urequests.get()")
print("doing requests.get()")
# Download the JSON
response = urequests.get(url)
response = requests.get(url)
# Check if request was successful
if response.status_code == 200:
# Parse JSON
Binary file not shown.