Fix up subprocess calls

subprocess.call() does not by default return a status value.

Update the commands to add shell=True which forces a return value.
Also convert the commands to a single string rather than a list as
this plays more nicely with both linux and windows.

Also fix a spurious :
pull/8605/head
adbridge 2018-11-01 13:07:16 +00:00
parent a7c777d5c1
commit b28d0811df
1 changed files with 9 additions and 5 deletions

View File

@ -168,8 +168,10 @@ def source_repos(config, examples):
if os.path.exists(name):
print("'%s' example directory already exists. Deleting..." % name)
rmtree(name)
cmd = "mbed-cli import %s" %repo_info['repo']
result = subprocess.call(cmd, shell=True)
result = subprocess.call(["mbed-cli", "import", repo_info['repo']])
if result:
return result
@ -191,8 +193,9 @@ def clone_repos(config, examples , retry = 3):
if os.path.exists(name):
print("'%s' example directory already exists. Deleting..." % name)
rmtree(name)
cmd = "%s clone %s" %(repo_info['type'], repo_info['repo'])
for i in range(0, retry):
if subprocess.call([repo_info['type'], "clone", repo_info['repo']]) == 0:
if not subprocess.call(cmd, shell=True):
break
else:
print("ERROR : unable to clone the repo {}".format(name))
@ -213,7 +216,7 @@ def deploy_repos(config, examples):
if name in examples:
if os.path.exists(name):
os.chdir(name)
result = subprocess.call(["mbed-cli", "deploy"])
result = subprocess.call("mbed-cli deploy", shell=True)
os.chdir("..")
if result:
print("mbed-cli deploy command failed for '%s'" % name)
@ -415,10 +418,11 @@ def update_mbedos_version(config, tag, examples):
update_dir = basename(repo_info['repo']) + "/mbed-os"
print("\nChanging dir to %s\n" % update_dir)
os.chdir(update_dir)
result = subprocess.call(["mbed-cli", "update", tag, "--clean"])
cmd = "mbed-cli update %s --clean" %tag
result = subprocess.call(cmd, shell=True)
os.chdir("../..")
if result:
return result:
return result
return 0