@@ -501,6 +501,47 @@ def pre_package_update():
501501
502502 return [oldpkgs , newpkgs , pkgs_fn , bsp_packages_path , dbsqlite_pathname ]
503503
504+ def error_packages_handle (error_packages_list , read_back_pkgs_json , pkgs_fn ):
505+ bsp_root = Import ('bsp_root' )
506+ env_root = Import ('env_root' )
507+
508+ flag = None
509+
510+ error_packages_redownload_error_list = []
511+
512+ if len (error_packages_list ):
513+ print ("\n ==============================> Error packages list : \n " )
514+ for pkg in error_packages_list :
515+ print pkg ['name' ], pkg ['ver' ]
516+ print ("\n The package in the list above is accidentally deleted." )
517+ print ("Env will redownload packages that have been accidentally deleted." )
518+ print ("If you really want to remove these packages, do that in the menuconfig command.\n " )
519+
520+ for pkg in error_packages_list : # Redownloaded the packages in error_packages_list
521+ if install_pkg (env_root , bsp_root , pkg ):
522+ print ("==============================> %s %s is redownloaded successfully. \n " % (
523+ pkg ['name' ], pkg ['ver' ]))
524+ else :
525+ error_packages_redownload_error_list .append (pkg )
526+ print pkg , 'download failed.'
527+ flag = False
528+
529+ if len (error_packages_redownload_error_list ):
530+ print ("%s" % error_packages_redownload_error_list )
531+ print ("Packages:%s,%s redownloed error,you need to use 'pkgs --update' command again to redownload them." %
532+ pkg ['name' ], pkg ['ver' ])
533+ write_back_pkgs_json = sub_list (
534+ read_back_pkgs_json , error_packages_redownload_error_list )
535+ read_back_pkgs_json = write_back_pkgs_json
536+ #print("write_back_pkgs_json:%s"%write_back_pkgs_json)
537+ pkgs_file = file (pkgs_fn , 'w' )
538+ pkgs_file .write (json .dumps (write_back_pkgs_json , indent = 1 ))
539+ pkgs_file .close ()
540+ else :
541+ print ("\n All the selected packages have been downloaded successfully.\n " )
542+
543+ return flag
544+
504545
505546def package_update ():
506547 """Update env's packages.
@@ -627,7 +668,7 @@ def package_update():
627668 #print(read_back_pkgs_json)
628669
629670 error_packages_list = []
630- error_packages_redownload_error_list = []
671+
631672 for pkg in read_back_pkgs_json :
632673 dirpath = pkg ['path' ]
633674 ver = pkg ['ver' ]
@@ -637,11 +678,11 @@ def package_update():
637678
638679 dirpath = os .path .basename (dirpath )
639680 removepath = os .path .join (bsp_packages_path , dirpath )
640-
681+ #print("if floder exist : %s"%removepath)
641682 git_removepath = get_pkg_folder_by_orign_path (removepath , ver )
642- #print "if floder exist",removepath
683+ #print( "if floder exist : %s"%git_removepath)
643684 removepath_ver = get_pkg_folder_by_orign_path (removepath , ver [1 :])
644- #print "if floder exist",removepath
685+ #print( "if floder exist : %s"%removepath_ver)
645686
646687 if os .path .exists (removepath ):
647688 continue
@@ -652,37 +693,11 @@ def package_update():
652693 else :
653694 error_packages_list .append (pkg )
654695
655- if len (error_packages_list ):
656- print ("\n ==============================> Error packages list : \n " )
657- for pkg in error_packages_list :
658- print pkg ['name' ], pkg ['ver' ]
659- print ("\n The package in the list above is accidentally deleted." )
660- print ("Env will redownload packages that have been accidentally deleted." )
661- print ("If you really want to remove these packages, do that in the menuconfig command.\n " )
662-
663- for pkg in error_packages_list : # Redownloaded the packages in error_packages_list
664- if install_pkg (env_root , bsp_root , pkg ):
665- print ("==============================> %s %s is redownloaded successfully. \n " % (
666- pkg ['name' ], pkg ['ver' ]))
667- else :
668- error_packages_redownload_error_list .append (pkg )
669- print pkg , 'download failed.'
670- flag = False
671-
672- if len (error_packages_redownload_error_list ):
673- print ("%s" % error_packages_redownload_error_list )
674- print ("Packages:%s,%s redownloed error,you need to use 'pkgs --update' command again to redownload them." %
675- pkg ['name' ], pkg ['ver' ])
676- write_back_pkgs_json = sub_list (
677- read_back_pkgs_json , error_packages_redownload_error_list )
678- read_back_pkgs_json = write_back_pkgs_json
679- #print("write_back_pkgs_json:%s"%write_back_pkgs_json)
680- pkgs_file = file (pkgs_fn , 'w' )
681- pkgs_file .write (json .dumps (write_back_pkgs_json , indent = 1 ))
682- pkgs_file .close ()
683- else :
684- print ("\n All the selected packages have been downloaded successfully.\n " )
685-
696+ get_flag = error_packages_handle (error_packages_list , read_back_pkgs_json , pkgs_fn )
697+
698+ if get_flag != None :
699+ flag = get_flag
700+
686701 update_latest_packages (read_back_pkgs_json , bsp_packages_path )
687702
688703 if flag :
0 commit comments