post_esp32.py: Allow renaming of files from URLs on the fly (#18965)

This commit is contained in:
Christian Baars 2023-06-25 21:21:27 +02:00 committed by GitHub
parent 30a65edd7a
commit e0619c8602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -70,9 +70,12 @@ def esp32_build_filesystem(fs_size):
if "no_files" in file:
continue
if "http" and "://" in file:
response = requests.get(file)
response = requests.get(file.split(" ")[0])
if response.ok:
target = join(filesystem_dir,file.split(os.path.sep)[-1])
if len(file.split(" ")) > 1:
target = join(filesystem_dir,file.split(" ")[1])
print("Renaming",(file.split(os.path.sep)[-1]).split(" ")[0],"to",file.split(" ")[1])
open(target, "wb").write(response.content)
else:
print("Failed to download: ",file)