@@ -237,7 +237,6 @@ def clone(url, path=None, depth=None, protocol=None):
237
237
m = Bld .isurl (url )
238
238
if not m :
239
239
raise ProcessException (1 , "Not an mbed library build URL" )
240
- return False
241
240
242
241
try :
243
242
Bld .init (path , url + '/tip' )
@@ -286,7 +285,6 @@ def checkout(rev):
286
285
m = Bld .isurl (url )
287
286
if not m :
288
287
raise ProcessException (1 , "Not an mbed library build URL" )
289
- return False
290
288
291
289
log ("Checkout \" %s\" in %s" % (rev , os .path .basename (os .getcwd ())))
292
290
arch_url = m .group (1 ) + '/archive/' + rev + '.zip'
@@ -311,7 +309,10 @@ def update(rev=None, clean=False, is_local=False):
311
309
log ("Cleaning up library build folder" )
312
310
for fl in os .listdir ('.' ):
313
311
if not fl .startswith ('.' ):
314
- os .remove (fl ) if os .path .isfile (fl ) else shutil .rmtree (fl )
312
+ if os .path .isfile (fl ):
313
+ os .remove (fl )
314
+ else :
315
+ shutil .rmtree (fl )
315
316
return Bld .checkout (rev )
316
317
317
318
def status ():
@@ -339,7 +340,7 @@ def seturl(url):
339
340
f .write (url )
340
341
except IOError :
341
342
error ("Unable to write bldrc file in \" %s\" " % fl , 1 )
342
-
343
+
343
344
def geturl ():
344
345
with open (os .path .join ('.bld' , 'bldrc' )) as f :
345
346
url = f .read ().strip ()
@@ -1070,15 +1071,18 @@ def __init__(self, path=None, print_warning=False):
1070
1071
err = (
1071
1072
"Could not find mbed program in current path. Assuming current dir.\n "
1072
1073
"You can fix this by calling \" mbed new .\" in the root dir of your program" )
1073
- warning (err ) if print_warning else error (err , 1 )
1074
+ if print_warning :
1075
+ warning (err )
1076
+ else :
1077
+ error (err , 1 )
1074
1078
1075
1079
# Sets config value
1076
1080
def set_cfg (self , var , val ):
1077
1081
fl = os .path .join (self .path , self .config_file )
1078
1082
try :
1079
1083
with open (fl ) as f :
1080
1084
lines = f .read ().splitlines ()
1081
- except :
1085
+ except IOError :
1082
1086
lines = []
1083
1087
1084
1088
for line in lines :
@@ -1097,7 +1101,7 @@ def get_cfg(self, var, default_val=None):
1097
1101
try :
1098
1102
with open (fl ) as f :
1099
1103
lines = f .read ().splitlines ()
1100
- except :
1104
+ except IOError :
1101
1105
lines = []
1102
1106
1103
1107
for line in lines :
@@ -1155,7 +1159,7 @@ def post_action(self):
1155
1159
for line in f .read ().splitlines ():
1156
1160
if pkgutil .find_loader (line ) is None :
1157
1161
missing .append (line )
1158
- except :
1162
+ except IOError :
1159
1163
pass
1160
1164
1161
1165
if len (missing ):
@@ -1338,14 +1342,20 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
1338
1342
err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (repo .rev , True ))
1339
1343
if depth :
1340
1344
err = err + ("\n The --depth option might prevent fetching the whole revision tree and checking out %s." % (repo .revtype (repo .rev , True )))
1341
- warning (err ) if ignore else error (err , e [0 ])
1345
+ if ignore :
1346
+ warning (err )
1347
+ else :
1348
+ error (err , e [0 ])
1342
1349
break
1343
1350
except ProcessException :
1344
1351
if os .path .isdir (repo .path ):
1345
1352
rmtree_readonly (repo .path )
1346
1353
else :
1347
1354
err = "Unable to clone repository (%s)" % url
1348
- warning (err ) if ignore else error (err , e [0 ])
1355
+ if ignore :
1356
+ warning (err )
1357
+ else :
1358
+ error (err , e [0 ])
1349
1359
1350
1360
repo .sync ()
1351
1361
@@ -1494,7 +1504,10 @@ def update(rev=None, clean=False, force=False, ignore=False, top=True, depth=Non
1494
1504
err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (rev , True ))
1495
1505
if depth :
1496
1506
err = err + ("\n The --depth option might prevent fetching the whole revision tree and checking out %s." % (repo .revtype (repo .rev , True )))
1497
- warning (err ) if ignore else error (err , e [0 ])
1507
+ if ignore :
1508
+ warning (err )
1509
+ else :
1510
+ error (err , e [0 ])
1498
1511
1499
1512
repo .rm_untracked ()
1500
1513
if top and cwd_type == 'library' :
0 commit comments