diff options
Diffstat (limited to 'datasets/occupancy/get_occupancy.py')
| -rw-r--r-- | datasets/occupancy/get_occupancy.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/datasets/occupancy/get_occupancy.py b/datasets/occupancy/get_occupancy.py index 0b590fa..aa12514 100644 --- a/datasets/occupancy/get_occupancy.py +++ b/datasets/occupancy/get_occupancy.py @@ -17,9 +17,12 @@ import clevercsv import hashlib import json import os +import sys +import time from functools import wraps from urllib.request import urlretrieve +from urllib.error import URLError SAMPLE = 16 @@ -72,7 +75,19 @@ def validate(checksum): @validate(MD5_TXT) def download_txt(target_path=None): - urlretrieve(TXT_URL, target_path) + count = 0 + while count < 5: + count += 1 + try: + urlretrieve(TXT_URL, target_path) + return + except URLError as err: + print( + "Error occurred (%r) when trying to download txt. Retrying in 5 seconds" + % err, + sys.stderr, + ) + time.sleep(5) @validate(MD5_JSON) |
