@@ -196,6 +196,7 @@ class ProcessException(Exception):
196
196
def popen (command , stdin = None , ** kwargs ):
197
197
# print for debugging
198
198
info ('Exec "' + ' ' .join (command )+ '" in ' + getcwd ())
199
+ proc = None
199
200
try :
200
201
proc = subprocess .Popen (command , ** kwargs )
201
202
except OSError as e :
@@ -206,7 +207,7 @@ def popen(command, stdin=None, **kwargs):
206
207
else :
207
208
raise e
208
209
209
- if proc .wait () != 0 :
210
+ if proc and proc .wait () != 0 :
210
211
raise ProcessException (proc .returncode , command [0 ], ' ' .join (command ), getcwd ())
211
212
212
213
def pquery (command , output_callback = None , stdin = None , ** kwargs ):
@@ -232,7 +233,7 @@ def pquery(command, output_callback=None, stdin=None, **kwargs):
232
233
line = ""
233
234
234
235
if proc .returncode is None :
235
- code = proc .poll ()
236
+ proc .poll ()
236
237
else :
237
238
break
238
239
@@ -1278,8 +1279,8 @@ def get_cache(self, url):
1278
1279
def set_cache (self , url ):
1279
1280
up = urlparse (formaturl (url , 'https' ))
1280
1281
if self .cache and up and up .netloc and os .path .isdir (self .path ):
1282
+ cpath = os .path .join (self .cache , up .netloc , re .sub (r'^/' , '' , up .path ))
1281
1283
try :
1282
- cpath = os .path .join (self .cache , up .netloc , re .sub (r'^/' , '' , up .path ))
1283
1284
if not os .path .isdir (cpath ):
1284
1285
os .makedirs (cpath )
1285
1286
@@ -1809,6 +1810,7 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
1809
1810
1810
1811
d_path = os .path .abspath (name or getcwd ())
1811
1812
p_path = os .path .dirname (d_path )
1813
+ d_type = None
1812
1814
if program and library :
1813
1815
error ("Cannot use both --program and --library options." , 1 )
1814
1816
elif program or library :
@@ -2139,7 +2141,6 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
2139
2141
# Compare library references (.lib) before and after update, and remove libraries that do not have references in the current revision
2140
2142
for lib in repo_orig .libs :
2141
2143
if not os .path .isfile (lib .lib ) and os .path .isdir (lib .path ): # Library reference doesn't exist in the new revision. Will try to remove library to reproduce original structure
2142
- gc = False
2143
2144
with cd (lib .path ):
2144
2145
lib_repo = Repo .fromrepo (lib .path )
2145
2146
gc , msg = lib_repo .can_update (clean , clean_deps )
@@ -2162,7 +2163,6 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
2162
2163
lib_repo = Repo .fromrepo (lib .path )
2163
2164
if (not lib .is_local and not lib_repo .is_local and
2164
2165
formaturl (lib .url , 'https' ) != formaturl (lib_repo .url , 'https' )): # Repository URL has changed
2165
- gc = False
2166
2166
with cd (lib .path ):
2167
2167
gc , msg = lib_repo .can_update (clean , clean_deps )
2168
2168
if gc :
@@ -2352,7 +2352,7 @@ def status_(ignore=False):
2352
2352
dict (name = ['-S' , '--supported' ], dest = 'supported' , const = True , choices = ["matrix" , "toolchains" , "targets" ], nargs = "?" , help = 'Shows supported matrix of targets and toolchains' ),
2353
2353
dict (name = '--app-config' , dest = "app_config" , help = "Path of an app configuration file (Default is to look for 'mbed_app.json')" ),
2354
2354
help = 'Compile code using the mbed build tools' ,
2355
- description = ( "Compile this program using the mbed build tools." ) )
2355
+ description = "Compile this program using the mbed build tools." )
2356
2356
def compile_ (toolchain = None , target = None , profile = False , compile_library = False , compile_config = False , config_prefix = None , source = False , build = False , clean = False , flash = False , artifact_name = None , supported = False , app_config = None ):
2357
2357
# Gather remaining arguments
2358
2358
args = remainder
@@ -2472,7 +2472,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
2472
2472
dict (name = '--app-config' , dest = "app_config" , help = "Path of an app configuration file (Default is to look for 'mbed_app.json')" ),
2473
2473
dict (name = '--test-config' , dest = "test_config" , help = "Path or mbed OS keyword of a test configuration file. Example: ethernet, odin_wifi, or path/to/config.json" ),
2474
2474
help = 'Find, build and run tests' ,
2475
- description = ( "Find, build, and run tests in a program and libraries" ) )
2475
+ description = "Find, build, and run tests in a program and libraries" )
2476
2476
def test_ (toolchain = None , target = None , compile_list = False , run_list = False , compile_only = False , run_only = False , tests_by_name = None , source = False , profile = False , build = False , clean = False , test_spec = None , app_config = None , test_config = None ):
2477
2477
# Gather remaining arguments
2478
2478
args = remainder
@@ -2712,7 +2712,7 @@ def config_(var=None, value=None, global_cfg=False, unset=False, list_config=Fal
2712
2712
action ('%s now set as global %s' % (value , name ))
2713
2713
else :
2714
2714
value = g .get_cfg (var )
2715
- action (('%s' % value ) if value else 'No global %s set' % ( name ) )
2715
+ action (('%s' % value ) if value else 'No global %s set' % name )
2716
2716
else :
2717
2717
# Find the root of the program
2718
2718
program = Program (getcwd ())
@@ -2806,7 +2806,7 @@ def main():
2806
2806
"You could retry the last command with \" -v\" flag for verbose output\n " , e [0 ])
2807
2807
else :
2808
2808
error ('OS Error: %s' % e [1 ], e [0 ])
2809
- except KeyboardInterrupt as e :
2809
+ except KeyboardInterrupt :
2810
2810
info ('User aborted!' , - 1 )
2811
2811
sys .exit (255 )
2812
2812
except Exception as e :
0 commit comments