Merge pull request #5240 from studavekar/retry-on-clone-failure

Add retry to handle git clone failure
pull/5264/head
Jimmy Brisson 2017-10-05 11:15:41 -05:00 committed by GitHub
commit 0fd13b5288
1 changed files with 6 additions and 3 deletions

View File

@ -169,7 +169,7 @@ def source_repos(config, examples):
subprocess.call(["mbed-cli", "import", repo_info['repo']]) subprocess.call(["mbed-cli", "import", repo_info['repo']])
def clone_repos(config, examples): def clone_repos(config, examples , retry = 3):
""" Clones each of the repos associated with the specific examples name from the """ Clones each of the repos associated with the specific examples name from the
json config file. Note if there is already a clone of the repo then it will first json config file. Note if there is already a clone of the repo then it will first
be removed to ensure a clean, up to date cloning. be removed to ensure a clean, up to date cloning.
@ -185,8 +185,11 @@ def clone_repos(config, examples):
if os.path.exists(name): if os.path.exists(name):
print("'%s' example directory already exists. Deleting..." % name) print("'%s' example directory already exists. Deleting..." % name)
rmtree(name) rmtree(name)
for i in range(0, retry):
subprocess.call([repo_info['type'], "clone", repo_info['repo']]) if subprocess.call([repo_info['type'], "clone", repo_info['repo']]) == 0:
break
else:
print("ERROR : unable to clone the repo {}".format(name))
def deploy_repos(config, examples): def deploy_repos(config, examples):
""" If the example directory exists as provided by the json config file, """ If the example directory exists as provided by the json config file,