8
8
import zipfile
9
9
10
10
import requests
11
+ from requests .exceptions import ConnectionError
12
+ from retry import retry
11
13
12
14
from ..standard .codelist import CodelistSet
13
15
from .config import CONFIG
14
16
from . import helpers
15
17
16
18
19
+ @retry (ConnectionError , tries = 3 , delay = 1 , backoff = 2 )
17
20
def data ():
18
21
path = CONFIG ['paths' ]['registry' ]
19
22
# downloads from https://iati-data-dump.codeforiati.org
@@ -38,6 +41,7 @@ def data():
38
41
_unlink (zip_filepath )
39
42
40
43
44
+ @retry (ConnectionError , tries = 3 , delay = 1 , backoff = 2 )
41
45
def metadata ():
42
46
logging .getLogger (__name__ ).info (
43
47
'Downloading metadata from the IATI registry...' )
@@ -127,6 +131,7 @@ def _get_codelist_mappings(versions):
127
131
json .dump (organisation_mappings , handler )
128
132
129
133
134
+ @retry (ConnectionError , tries = 3 , delay = 1 , backoff = 2 )
130
135
def codelists ():
131
136
def get_list_of_codelists (version ):
132
137
if version in _VERY_OLD_IATI_VERSIONS :
@@ -218,6 +223,7 @@ def get_codelist(codelist_name, version):
218
223
_get_codelist_mappings (all_versions )
219
224
220
225
226
+ @retry (ConnectionError , tries = 3 , delay = 1 , backoff = 2 )
221
227
def schemas ():
222
228
path = join (CONFIG ['paths' ]['standard' ], 'schemas' )
223
229
shutil .rmtree (path , ignore_errors = True )
0 commit comments