1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-07 10:43:27 -04:00

Update simple_tests.py

Fix: Consider using the requests library, which has better error handling and timeout capabilities
This commit is contained in:
JONH VINCENT ALVARO 2024-09-20 17:21:03 +08:00 committed by GitHub
parent cbaad146d5
commit 2d1296e9f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -78,6 +78,20 @@ def download_file(url, filename): # TODO: retry
except urllib.error.URLError as err:
print_fail(f"[-] Failed downloading: {err}")
return None
*********************************
import requests
def download_file(url, filename):
try:
response = requests.get(url, stream=True, timeout=10)
response.raise_for_status()
with open(filename, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
return filename
except requests.RequestException as err:
print_fail(f"[-] Failed downloading: {err}")
return None
**************************
def extract_args(detector, aligner, in_path, out_path, args=None):