@@ -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,14 @@ def pre_package_update():
500509 """ Make preparations before updating the software package. """
501510
502511 bsp_root = Import ('bsp_root' )
512+ env_root = Import ('env_root' )
513+ from cmd_package import determine_support_chinese
503514
504515 if not os .path .exists ('.config' ):
505- print ("\n 当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。" )
506- print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n " )
516+ if determine_support_chinese (env_root ):
517+ print ("\n 当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。" )
518+ print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n " )
519+
507520 print ('No system configuration file : .config.' )
508521 print ('You should use < menuconfig > command to config bsp first.' )
509522 return False
@@ -533,7 +546,6 @@ def pre_package_update():
533546 sql = '''CREATE TABLE packagefile
534547 (pathname TEXT ,package TEXT ,md5 TEXT );'''
535548 pkgsdb .create_table (conn , sql )
536- # print("Create dbsqlite done")
537549
538550 fn = '.config'
539551 pkgs = kconfig .parse (fn )
@@ -696,33 +708,28 @@ 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 """
714719
720+ sys_value = pre_package_update ()
721+
722+ if not sys_value :
723+ return
724+
715725 bsp_root = Import ('bsp_root' )
716726 env_root = Import ('env_root' )
717727 flag = True
718728
719729 # According to the env version, whether Chinese output is supported or not
720- determine_support_chinese (env_root )
721-
722- sys_value = pre_package_update ()
723-
724- if not sys_value :
725- return
730+ if determine_support_chinese (env_root ):
731+ if platform .system () == "Windows" :
732+ os .system ('chcp 65001 > nul' )
726733
727734 oldpkgs = sys_value [0 ]
728735 newpkgs = sys_value [1 ]
0 commit comments