@@ -72,6 +72,12 @@ def execute_command(cmdstring, cwd=None, shell=True):
7272
7373 return stdout_str
7474
75+ def determine_support_chinese (env_root ):
76+ get_flag_file_path = os .path .join (env_root , 'tools' , 'bin' , 'env_above_ver_1_1' )
77+ if os .path .isfile (get_flag_file_path ):
78+ return True
79+ else :
80+ return False
7581
7682def user_input (msg , default_value ):
7783 """Gets the user's keyboard input."""
@@ -350,8 +356,11 @@ def package_list():
350356 env_root = Import ('env_root' )
351357
352358 if not os .path .isfile (fn ):
353- print ("\n 当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。" )
354- print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n " )
359+
360+ if determine_support_chinese (env_root ):
361+ print ("\n 当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。" )
362+ print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n " )
363+
355364 print ('No system configuration file : .config.' )
356365 print ('You should use < menuconfig > command to config bsp first.' )
357366 return
@@ -500,10 +509,13 @@ def pre_package_update():
500509 """ Make preparations before updating the software package. """
501510
502511 bsp_root = Import ('bsp_root' )
512+ from cmd_package import determine_support_chinese
503513
504514 if not os .path .exists ('.config' ):
505- print ("\n 当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。" )
506- print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n " )
515+ if determine_support_chinese (env_root ):
516+ print ("\n 当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。" )
517+ print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n " )
518+
507519 print ('No system configuration file : .config.' )
508520 print ('You should use < menuconfig > command to config bsp first.' )
509521 return False
@@ -696,18 +708,11 @@ def write_storage_file(pkgs_fn, newpkgs):
696708 pkgs_file .close ()
697709
698710
699- def determine_support_chinese (env_root ):
700- get_flag_file_path = os .path .join (env_root , 'tools' , 'bin' , 'env_above_ver_1_1' )
701- if os .path .isfile (get_flag_file_path ):
702- # change code page to 65001
703- if platform .system () == "Windows" :
704- os .system ('chcp 65001 > nul' )
705-
706711def package_update (isDeleteOld = False ):
707712 """Update env's packages.
708713
709714 Compare the old and new software package list and update the package.
710- Remove unwanted packages and download the newly selected package.
715+ Remove unwanted packages and download the newly selected package.-
711716 Check if the files in the deleted packages have been changed, and if so,
712717 remind the user saved the modified file.
713718 """
@@ -716,14 +721,16 @@ def package_update(isDeleteOld=False):
716721 env_root = Import ('env_root' )
717722 flag = True
718723
719- # According to the env version, whether Chinese output is supported or not
720- determine_support_chinese (env_root )
721-
722724 sys_value = pre_package_update ()
723725
724726 if not sys_value :
725727 return
726728
729+ # According to the env version, whether Chinese output is supported or not
730+ if determine_support_chinese (env_root ):
731+ if platform .system () == "Windows" :
732+ os .system ('chcp 65001 > nul' )
733+
727734 oldpkgs = sys_value [0 ]
728735 newpkgs = sys_value [1 ]
729736 pkgs_delete_error_list = sys_value [2 ]
0 commit comments