Skip to content

Commit d4a7d5c

Browse files
committed
Fixed issue when cloning tools in .temp. Added debug info when using cached copy
1 parent 7684ea1 commit d4a7d5c

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

mbed/mbed.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -952,21 +952,17 @@ def clone(self, url, path, depth=None, protocol=None, **kwargs):
952952
cache = self.get_cache(url)
953953

954954
# Try to clone with cache ref first
955-
if cache:
955+
if cache and not os.path.isdir(path):
956+
log("Trying to use cached repository in \"%s\" for \"%s\"" % (cache, path))
956957
try:
957-
if not os.path.isdir(path):
958-
if not os.path.isdir(os.path.split(path)[0]):
959-
os.makedirs(os.path.split(path)[0])
960-
shutil.copytree(cache, path)
961-
962-
try:
963-
with cd(path):
964-
scm.update(None, True)
965-
main = False
966-
except ProcessException:
967-
if os.path.exists(path):
968-
rmtree_readonly(path)
969-
except ProcessException, e:
958+
if os.path.split(path)[0] and not os.path.isdir(os.path.split(path)[0]):
959+
os.makedirs(os.path.split(path)[0])
960+
shutil.copytree(cache, path)
961+
962+
with cd(path):
963+
scm.update(None, True)
964+
main = False
965+
except (ProcessException, IOError):
970966
if os.path.isdir(path):
971967
rmtree_readonly(path)
972968

@@ -1208,11 +1204,12 @@ def add_tools(self, path):
12081204
if not os.path.exists(tools_dir):
12091205
try:
12101206
action("Couldn't find build tools in your program. Downloading the mbed SDK tools...")
1211-
Hg.clone(mbed_sdk_tools_url, tools_dir)
1207+
repo = Repo.fromurl(mbed_sdk_tools_url)
1208+
repo.clone(mbed_sdk_tools_url, tools_dir)
12121209
except:
12131210
if os.path.exists(tools_dir):
12141211
rmtree_readonly(tools_dir)
1215-
raise Exception(128, "An error occurred while cloning the mbed SDK tools from \"%s\"" % mbed_sdk_tools_url)
1212+
error("An error occurred while cloning the mbed SDK tools from \"%s\"" % mbed_sdk_tools_url)
12161213

12171214
def get_tools(self):
12181215
mbed_tools_path = self.get_tools_dir()

0 commit comments

Comments
 (0)