@@ -196,6 +196,7 @@ class ProcessException(Exception):
196196def popen (command , stdin = None , ** kwargs ):
197197 # print for debugging
198198 info ('Exec "' + ' ' .join (command )+ '" in ' + getcwd ())
199+ proc = None
199200 try :
200201 proc = subprocess .Popen (command , ** kwargs )
201202 except OSError as e :
@@ -206,7 +207,7 @@ def popen(command, stdin=None, **kwargs):
206207 else :
207208 raise e
208209
209- if proc .wait () != 0 :
210+ if proc and proc .wait () != 0 :
210211 raise ProcessException (proc .returncode , command [0 ], ' ' .join (command ), getcwd ())
211212
212213def pquery (command , output_callback = None , stdin = None , ** kwargs ):
@@ -232,7 +233,7 @@ def pquery(command, output_callback=None, stdin=None, **kwargs):
232233 line = ""
233234
234235 if proc .returncode is None :
235- code = proc .poll ()
236+ proc .poll ()
236237 else :
237238 break
238239
@@ -1282,8 +1283,8 @@ def get_cache(self, url):
12821283 def set_cache (self , url ):
12831284 up = urlparse (formaturl (url , 'https' ))
12841285 if self .cache and up and up .netloc and os .path .isdir (self .path ):
1286+ cpath = os .path .join (self .cache , up .netloc , re .sub (r'^/' , '' , up .path ))
12851287 try :
1286- cpath = os .path .join (self .cache , up .netloc , re .sub (r'^/' , '' , up .path ))
12871288 if not os .path .isdir (cpath ):
12881289 os .makedirs (cpath )
12891290
@@ -1827,6 +1828,7 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
18271828
18281829 d_path = os .path .abspath (name or getcwd ())
18291830 p_path = os .path .dirname (d_path )
1831+ d_type = None
18301832 if program and library :
18311833 error ("Cannot use both --program and --library options." , 1 )
18321834 elif program or library :
@@ -2157,7 +2159,6 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
21572159 # Compare library references (.lib) before and after update, and remove libraries that do not have references in the current revision
21582160 for lib in repo_orig .libs :
21592161 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
2160- gc = False
21612162 with cd (lib .path ):
21622163 lib_repo = Repo .fromrepo (lib .path )
21632164 gc , msg = lib_repo .can_update (clean , clean_deps )
@@ -2180,7 +2181,6 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
21802181 lib_repo = Repo .fromrepo (lib .path )
21812182 if (not lib .is_local and not lib_repo .is_local and
21822183 formaturl (lib .url , 'https' ) != formaturl (lib_repo .url , 'https' )): # Repository URL has changed
2183- gc = False
21842184 with cd (lib .path ):
21852185 gc , msg = lib_repo .can_update (clean , clean_deps )
21862186 if gc :
@@ -2370,7 +2370,7 @@ def status_(ignore=False):
23702370 dict (name = ['-S' , '--supported' ], dest = 'supported' , const = True , choices = ["matrix" , "toolchains" , "targets" ], nargs = "?" , help = 'Shows supported matrix of targets and toolchains' ),
23712371 dict (name = '--app-config' , dest = "app_config" , help = "Path of an app configuration file (Default is to look for 'mbed_app.json')" ),
23722372 help = 'Compile code using the mbed build tools' ,
2373- description = ( "Compile this program using the mbed build tools." ) )
2373+ description = "Compile this program using the mbed build tools." )
23742374def 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 ):
23752375 # Gather remaining arguments
23762376 args = remainder
@@ -2490,7 +2490,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
24902490 dict (name = '--app-config' , dest = "app_config" , help = "Path of an app configuration file (Default is to look for 'mbed_app.json')" ),
24912491 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" ),
24922492 help = 'Find, build and run tests' ,
2493- description = ( "Find, build, and run tests in a program and libraries" ) )
2493+ description = "Find, build, and run tests in a program and libraries" )
24942494def 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 ):
24952495 # Gather remaining arguments
24962496 args = remainder
@@ -2730,7 +2730,7 @@ def config_(var=None, value=None, global_cfg=False, unset=False, list_config=Fal
27302730 action ('%s now set as global %s' % (value , name ))
27312731 else :
27322732 value = g .get_cfg (var )
2733- action (('%s' % value ) if value else 'No global %s set' % ( name ) )
2733+ action (('%s' % value ) if value else 'No global %s set' % name )
27342734 else :
27352735 # Find the root of the program
27362736 program = Program (getcwd ())
@@ -2897,7 +2897,7 @@ def main():
28972897 "You could retry the last command with \" -v\" flag for verbose output\n " , e [0 ])
28982898 else :
28992899 error ('OS Error: %s' % e [1 ], e [0 ])
2900- except KeyboardInterrupt as e :
2900+ except KeyboardInterrupt :
29012901 info ('User aborted!' , - 1 )
29022902 sys .exit (255 )
29032903 except Exception as e :
0 commit comments