Skip to content
Snippets Groups Projects
Commit 0bc62435 authored by ave's avatar ave
Browse files

drop urllib.urequest

parent a53d8b54
Branches
Tags
No related merge requests found
package("toml") package("toml")
require("urllib.urequest")
from st3m.input import InputController, InputState from st3m.input import InputController, InputState
from st3m.goose import Optional, List from st3m.goose import Optional, List
from st3m.ui import colours from st3m.ui import colours
from urllib.urequest import urlopen import urequests
import gzip import gzip
from utarfile import TarFile, DIRTYPE from utarfile import TarFile, DIRTYPE
import io import io
...@@ -84,12 +84,12 @@ class DownloadView(BaseView): ...@@ -84,12 +84,12 @@ class DownloadView(BaseView):
def download_file(self, url: str, block_size=40960) -> List[bytes]: def download_file(self, url: str, block_size=40960) -> List[bytes]:
gc.collect() gc.collect()
req = urlopen(url) req = urequests.get(url)
yield yield
try: try:
while True: while True:
new_data = req.read(block_size) new_data = req.raw.read(block_size)
yield new_data yield new_data
if len(new_data) < block_size: if len(new_data) < block_size:
break break
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment