Skip to content

Commit 9686c64

Browse files
committed
Download mbed 2.0 SDK tools only if mbed.bld is present #216
1 parent 76ba390 commit 9686c64

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mbed/mbed.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ class Program(object):
10991099
name = None
11001100
is_cwd = False
11011101
is_repo = False
1102+
is_classic = False
11021103

11031104
def __init__(self, path=None, print_warning=False):
11041105
path = os.path.abspath(path or os.getcwd())
@@ -1117,6 +1118,7 @@ def __init__(self, path=None, print_warning=False):
11171118
break
11181119

11191120
self.name = os.path.basename(self.path)
1121+
self.is_classic = os.path.isfile(os.path.join(self.path, 'mbed.bld'))
11201122

11211123
# is_cwd flag indicates that current dir is assumed to be root, not root repo
11221124
if self.is_cwd and print_warning:
@@ -1179,9 +1181,7 @@ def get_tools_dir(self):
11791181
def post_action(self):
11801182
mbed_tools_path = self.get_tools_dir()
11811183

1182-
if not mbed_tools_path:
1183-
if not os.path.exists(os.path.join(self.path, '.temp')):
1184-
os.mkdir(os.path.join(self.path, '.temp'))
1184+
if not mbed_tools_path and self.is_classic:
11851185
self.add_tools(os.path.join(self.path, '.temp'))
11861186
mbed_tools_path = self.get_tools_dir()
11871187

@@ -1221,11 +1221,13 @@ def post_action(self):
12211221
"You can install all missing modules by running \"pip install -r %s\" in \"%s\"" % (', '.join(missing), fname, mbed_os_path))
12221222

12231223
def add_tools(self, path):
1224+
if not os.path.exists(path):
1225+
os.mkdir(path)
12241226
with cd(path):
12251227
tools_dir = 'tools'
12261228
if not os.path.exists(tools_dir):
12271229
try:
1228-
action("Couldn't find build tools in your program. Downloading the mbed SDK tools...")
1230+
action("Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...")
12291231
repo = Repo.fromurl(mbed_sdk_tools_url)
12301232
repo.clone(mbed_sdk_tools_url, tools_dir)
12311233
except Exception:

0 commit comments

Comments
 (0)