mirror of
https://github.com/deepfakes/faceswap
synced 2025-06-08 11:53:26 -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:
parent
cbaad146d5
commit
2d1296e9f6
1 changed files with 14 additions and 0 deletions
|
@ -78,6 +78,20 @@ def download_file(url, filename): # TODO: retry
|
||||||
except urllib.error.URLError as err:
|
except urllib.error.URLError as err:
|
||||||
print_fail(f"[-] Failed downloading: {err}")
|
print_fail(f"[-] Failed downloading: {err}")
|
||||||
return None
|
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):
|
def extract_args(detector, aligner, in_path, out_path, args=None):
|
||||||
|
|
Loading…
Add table
Reference in a new issue