@@ -361,7 +361,16 @@ def get_pkg_folder_by_orign_path(orign_path, version):
361361 if os .path .exists (orign_path + '-' + version ):
362362 return orign_path + '-' + version
363363 return orign_path
364+
365+
366+ def git_cmd_exec (cmd , cwd ):
367+ try :
368+ execute_command (cmd , cwd = cwd )
369+ except Exception , e :
370+ print ('error message:%s%s. %s \n You can solve this problem by manually removing old packages and re-downloading them using env.\t ' %
371+ (cwd , " path doesn't exist" , e .message ))
364372
373+
365374def update_latest_packages (read_back_pkgs_json , bsp_packages_path ):
366375 """ update the packages that are latest version.
367376
@@ -386,7 +395,6 @@ def update_latest_packages(read_back_pkgs_json, bsp_packages_path):
386395 env_kconfig_path = os .path .join (env_root , 'tools\scripts\cmds' )
387396 env_config_file = os .path .join (env_kconfig_path , '.config' )
388397
389- beforepath = os .getcwd ()
390398 for pkg in read_back_pkgs_json :
391399 package = Package ()
392400 pkg_path = pkg ['path' ]
@@ -397,9 +405,7 @@ def update_latest_packages(read_back_pkgs_json, bsp_packages_path):
397405 pkgs_name_in_json = package .get_name ()
398406 if pkg ['ver' ] == "latest_version" or pkg ['ver' ] == "latest" :
399407 repo_path = os .path .join (bsp_packages_path , pkgs_name_in_json )
400- #ver_sha = package.get_versha(pkg['ver'])
401408 repo_path = get_pkg_folder_by_orign_path (repo_path , pkg ['ver' ])
402- os .chdir (repo_path )
403409
404410 if os .path .isfile (env_config_file ) and find_macro_in_condfig (env_config_file , 'SYS_PKGS_DOWNLOAD_ACCELERATE' ):
405411 payload_pkgs_name_in_json = pkgs_name_in_json .encode ("utf-8" )
@@ -421,7 +427,9 @@ def update_latest_packages(read_back_pkgs_json, bsp_packages_path):
421427 # from mirror server
422428 cmd = 'git remote set-url origin ' + \
423429 item ['URL' ]
424- os .system (cmd )
430+
431+ git_cmd_exec (cmd , repo_path )
432+
425433 #print(cmd)
426434 except Exception , e :
427435 print ('e.message:%s\t ' % e .message )
@@ -430,16 +438,16 @@ def update_latest_packages(read_back_pkgs_json, bsp_packages_path):
430438
431439 # Only one trace relationship can be used directly with git pull.
432440 cmd = 'git pull'
433- os . system (cmd )
441+ git_cmd_exec (cmd , repo_path )
434442
435443 # If the package has submodules, update the submodules.
436444 update_submodule (repo_path )
437445
438446 # recover origin url to the path which get from packages.json file
439447 if package .get_url (pkg ['ver' ]) :
440448 cmd = 'git remote set-url origin ' + package .get_url (pkg ['ver' ])
441- os . system (cmd )
442- os . chdir ( beforepath )
449+ git_cmd_exec (cmd , repo_path )
450+
443451 print ("==============================> %s update done \n " %
444452 (pkgs_name_in_json ))
445453
0 commit comments