@@ -164,8 +164,7 @@ def get_url_from_mirror_server(pkgs_name_in_json, pkgs_ver):
164164 # Can't find package,change git package SHA if it's a git
165165 # package
166166 if len (package_info ['packages' ]) == 0 :
167- print (
168- "Package was NOT found on mirror server. Using a non-mirrored address to download." )
167+ print ("Package was NOT found on mirror server. Using a non-mirrored address to download." )
169168 return None , None
170169 else :
171170 for item in package_info ['packages' ][0 ]['packages_info' ]['site' ]:
@@ -184,8 +183,8 @@ def get_url_from_mirror_server(pkgs_name_in_json, pkgs_ver):
184183 return None , None
185184
186185 except Exception , e :
187- print ('e.message:%s\t ' % e .message )
188- print ("The server could not be contacted. Please check your network connection." )
186+ # print('e.message:%s\t' % e.message)
187+ print ("\n The mirror server could not be contacted. Please check your network connection." )
189188
190189
191190def determine_url_valid (url_from_srv ):
@@ -209,8 +208,8 @@ def determine_url_valid(url_from_srv):
209208 return True
210209
211210 except Exception , e :
212- # print('e.message:%s\t' % e.message)
213- print ('Network connection error or the url : %s is invalid.\n ' % url_from_srv )
211+ # print('e.message:%s\t' % e.message)
212+ print ('Network connection error or the url : %s is invalid.\n ' % url_from_srv . encode ( "utf-8" ) )
214213
215214
216215def install_pkg (env_root , bsp_root , pkg ):
@@ -264,26 +263,28 @@ def install_pkg(env_root, bsp_root, pkg):
264263 upstream_change_flag = True
265264 except Exception , e :
266265 # print('e.message:%s\t' % e.message)
267- print ("Failed to connect to the mirror server, package will be downloaded from non-mirror server." )
266+ print ("Failed to connect to the mirror server, package will be downloaded from non-mirror server.\n " )
268267
269268 if package_url [- 4 :] == '.git' :
269+ try :
270+ repo_path = os .path .join (bsp_pkgs_path , pkgs_name_in_json )
271+ repo_path = repo_path + '-' + pkg ['ver' ]
272+ repo_path_full = '"' + repo_path + '"'
270273
271- repo_path = os .path .join (bsp_pkgs_path , pkgs_name_in_json )
272- repo_path = repo_path + '-' + pkg ['ver' ]
273- repo_path_full = '"' + repo_path + '"'
274-
275- cmd = 'git clone ' + package_url + ' ' + repo_path_full
276- execute_command (cmd , cwd = bsp_pkgs_path )
274+ cmd = 'git clone ' + package_url + ' ' + repo_path_full
275+ execute_command (cmd , cwd = bsp_pkgs_path )
277276
278- cmd = 'git checkout -q ' + ver_sha
279- execute_command (cmd , cwd = repo_path )
277+ cmd = 'git checkout -q ' + ver_sha
278+ execute_command (cmd , cwd = repo_path )
279+ except Exception , e :
280+ print ("\n Failed to download software package with git. Please check the network connection." )
281+ return False
280282
281283 if upstream_change_flag :
282284 cmd = 'git remote set-url origin ' + url_from_json
283285 execute_command (cmd , cwd = repo_path )
284286
285- # If there is a .gitmodules file in the package, prepare to update the
286- # submodule.
287+ # If there is a .gitmodules file in the package, prepare to update submodule.
287288 submod_path = os .path .join (repo_path , '.gitmodules' )
288289 if os .path .isfile (submod_path ):
289290 print ("Start to update submodule" )
@@ -421,8 +422,8 @@ def git_cmd_exec(cmd, cwd):
421422 try :
422423 execute_command (cmd , cwd = cwd )
423424 except Exception , e :
424- print ('error message:%s%s. %s \n You can solve this problem by manually removing old packages and re-downloading them using env. \t ' %
425- ( cwd , " path doesn't exist" , e . message ) )
425+ print ('error message:%s%s. %s \n \t ' % ( cwd . encode ( "utf-8" ), " path doesn't exist" , e . message ))
426+ print ( "You can solve this problem by manually removing old packages and re-downloading them using env." )
426427
427428
428429def update_latest_packages (pkgs_fn , bsp_packages_path ):
@@ -489,7 +490,7 @@ def update_latest_packages(pkgs_fn, bsp_packages_path):
489490 git_cmd_exec (cmd , repo_path )
490491 else :
491492 print ("Can't find the package : %s's url in file : %s" %
492- (payload_pkgs_name_in_json , pkg_path ))
493+ (payload_pkgs_name_in_json . encode ( "utf-8" ) , pkg_path . encode ( "utf-8" ) ))
493494
494495 print ("==============================> %s update done \n " %
495496 (pkgs_name_in_json .encode ("utf-8" )))
@@ -607,16 +608,14 @@ def error_packages_handle(error_packages_list, read_back_pkgs_json, pkgs_fn):
607608 if len (error_packages_redownload_error_list ):
608609 print ("%s" % error_packages_redownload_error_list )
609610 print ("Packages:%s,%s redownloed error, you need to use <pkgs --update> command again to redownload them." %
610- (pkg ['name' ], pkg ['ver' ]))
611+ (pkg ['name' ]. encode ( "utf-8" ) , pkg ['ver' ]. encode ( "utf-8" ) ))
611612 write_back_pkgs_json = sub_list (
612613 read_back_pkgs_json , error_packages_redownload_error_list )
613614 read_back_pkgs_json = write_back_pkgs_json
614615 # print("write_back_pkgs_json:%s"%write_back_pkgs_json)
615616 pkgs_file = file (pkgs_fn , 'w' )
616617 pkgs_file .write (json .dumps (write_back_pkgs_json , indent = 1 ))
617618 pkgs_file .close ()
618- else :
619- print ("\n All the selected packages have been downloaded successfully.\n " )
620619
621620 return flag
622621
@@ -638,7 +637,7 @@ def rm_package(dir):
638637 os .system (cmd )
639638
640639 if os .path .isdir (dir ):
641- print ("Folder path: %s" % dir )
640+ print ("Folder path: %s" % dir . encode ( "utf-8" ) )
642641 return False
643642 else :
644643 print ("Path: %s \n Success: Folder has been removed. " % dir .encode ("utf-8" ))
@@ -734,10 +733,10 @@ def package_update(isDeleteOld=False):
734733
735734 if os .path .isdir (removepath_ver ):
736735 print ("\n Error: %s package delete failed, begin to remove it." %
737- error_package ['name' ])
736+ error_package ['name' ]. encode ( "utf-8" ) )
738737
739738 if rm_package (removepath_ver ) == False :
740- print ("Error: Delete package %s failed! Please delete the folder manually.\n " % error_package ['name' ])
739+ print ("Error: Delete package %s failed! Please delete the folder manually.\n " % error_package ['name' ]. encode ( "utf-8" ) )
741740 return
742741
743742 # 1.in old ,not in new : Software packages that need to be removed.
@@ -756,7 +755,7 @@ def package_update(isDeleteOld=False):
756755 print ("\n Start to remove %s \n please wait..." % gitdir .encode ("utf-8" ))
757756 if isDeleteOld :
758757 if rm_package (gitdir ) == False :
759- print ("Floder delete fail: %s" % gitdir )
758+ print ("Floder delete fail: %s" % gitdir . encode ( "utf-8" ) )
760759 print ("Please delete this folder manually." )
761760 else :
762761 print (
@@ -770,7 +769,7 @@ def package_update(isDeleteOld=False):
770769 print ("Error: Please delete the folder manually." )
771770 except Exception , e :
772771 print ('Error message:%s%s. error.message: %s\n \t ' %
773- ("Delete folder failed: " , gitdir , e .message ))
772+ ("Delete folder failed: " , gitdir . encode ( "utf-8" ) , e .message ))
774773 else :
775774 if os .path .isdir (removepath_ver ):
776775 print ("Start to remove %s \n please wait..." % removepath_ver .encode ("utf-8" ))
@@ -779,7 +778,7 @@ def package_update(isDeleteOld=False):
779778 except Exception , e :
780779 pkgs_delete_fail_list .append (pkg )
781780 print ('Error message:\n %s %s. %s \n \t ' % (
782- "Delete folder failed, please delete the folder manually" , removepath_ver , e .message ))
781+ "Delete folder failed, please delete the folder manually" , removepath_ver . encode ( "utf-8" ) , e .message ))
783782
784783 if len (pkgs_delete_fail_list ):
785784 # write error messages
@@ -817,9 +816,11 @@ def package_update(isDeleteOld=False):
817816
818817 # Give hints based on the success of the download.
819818 if len (pkgs_download_fail_list ):
820- print ("Package download failed pkgs_download_fail_list: %s \n " %
821- pkgs_download_fail_list )
822- print ("You need to reuse the <pkgs -update> command to download again.\n " )
819+ print ("\n Package download failed list:" )
820+ for item in pkgs_download_fail_list :
821+ print (item )
822+
823+ print ("You need to reuse the <pkgs -update> command to download again." )
823824
824825 # update pkgs.json and SConscript
825826 write_storage_file (pkgs_fn , newpkgs )
@@ -961,16 +962,14 @@ def upgrade_packages_index():
961962 git_repo = 'https://gitee.com/RT-Thread-Mirror/packages.git'
962963 else :
963964 git_repo = 'https://github.com/RT-Thread/packages.git'
964-
965- # print(get_package_url,get_ver_sha)
966-
965+
967966 packages_root = os .path .join (env_root , 'packages' )
968967 pkgs_path = os .path .join (packages_root , 'packages' )
969968
970969 if not os .path .isdir (pkgs_path ):
971970 cmd = 'git clone ' + git_repo + ' ' + pkgs_path
972971 os .system (cmd )
973- print ("upgrade from :%s" % (git_repo ))
972+ print ("upgrade from :%s" % (git_repo . encode ( "utf-8" ) ))
974973 else :
975974 print ("Begin to upgrade env packages." )
976975 cmd = r'git pull ' + git_repo
@@ -1008,8 +1007,6 @@ def upgrade_env_script():
10081007 else :
10091008 env_scripts_repo = 'https://github.com/RT-Thread/env.git'
10101009
1011- # print(get_package_url,get_ver_sha)
1012-
10131010 env_scripts_root = os .path .join (env_root , 'tools' , 'scripts' )
10141011 cmd = r'git pull ' + env_scripts_repo
10151012 execute_command (cmd , cwd = env_scripts_root )
0 commit comments