Skip to content

Commit 25aab49

Browse files
authored
Merge pull request #81 from SummerGGift/optimize_env
【修改】:检测 rt-thread 是否被存放在非 ascii 路径中,并完善提示信息
2 parents 195a17b + 32194d6 commit 25aab49

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

cmds/cmd_menuconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ def cmd(args):
162162
if platform.system() == "Windows":
163163
os.system('chcp 65001 > nul')
164164

165-
print("\n<menuconfig> 命令应当在某一特定 BSP 目录下执行,例如:\"rt-thread/bsp/stm32/stm32f091-st-nucleo\"")
166-
print("请确保当前目录为 BSP 根目录,并且该目录中有 Kconfig 文件。\n")
165+
print("\n\033[1;31;40m<menuconfig> 命令应当在某一特定 BSP 目录下执行,例如:\"rt-thread/bsp/stm32/stm32f091-st-nucleo\"\033[0m")
166+
print("\033[1;31;40m请确保当前目录为 BSP 根目录,并且该目录中有 Kconfig 文件。\033[0m\n")
167167

168168
print ("<menuconfig> command should be used in a bsp root path with a Kconfig file.")
169169
print ("Example: \"rt-thread/bsp/stm32/stm32f091-st-nucleo\"")

cmds/cmd_package.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,11 @@ def package_list():
359359
if platform.system() == "Windows":
360360
os.system('chcp 65001 > nul')
361361

362-
print ("\n当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。")
363-
print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n")
362+
print ("\n\033[1;31;40m当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。\033[0m")
363+
print ("\033[1;31;40m如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\033[0m\n")
364364

365-
print ('\nNo system configuration file : .config.')
366-
print ('You should use < menuconfig > command to config bsp first.')
365+
print ('\033[1;31;40mNo system configuration file : .config.\033[0m')
366+
print ('\033[1;31;40mYou should use < menuconfig > command to config bsp first.\033[0m')
367367

368368
if platform.system() == "Windows":
369369
os.system('chcp 437 > nul')
@@ -520,8 +520,8 @@ def pre_package_update():
520520
if platform.system() == "Windows":
521521
os.system('chcp 65001 > nul')
522522

523-
print ("\n当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。")
524-
print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n")
523+
print ("\n\033[1;31;40m当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。\033[0m")
524+
print ("\033[1;31;40m如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\033[0m\n")
525525

526526
print ('No system configuration file : .config.')
527527
print ('You should use < menuconfig > command to config bsp first.')

env.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Change Logs:
2222
# Date Author Notes
2323
# 2018-5-28 SummerGift Add copyright information
24+
# 2019-1-16 SummerGift Add chinese detection
2425
#
2526

2627
import os
@@ -31,7 +32,7 @@
3132
from cmds import *
3233
from vars import Export
3334

34-
__version__ = 'rt-thread packages v1.0.0'
35+
__version__ = 'rt-thread packages v1.1.0'
3536

3637

3738
def init_argparse():
@@ -63,6 +64,22 @@ def main():
6364
Export('env_root')
6465
Export('bsp_root')
6566

67+
try:
68+
bsp_root.decode("ascii")
69+
except Exception, e:
70+
if platform.system() == "Windows":
71+
os.system('chcp 65001 > nul')
72+
73+
print ("\n\033[1;31;40m警告:\033[0m")
74+
print ("\033[1;31;40m当前路径不支持非英文字符,请修改当前路径为纯英文路径。\033[0m")
75+
print ("\033[1;31;40mThe current path does not support non-English characters.\033[0m")
76+
print ("\033[1;31;40mPlease modify the current path to a pure English path.\033[0m")
77+
78+
if platform.system() == "Windows":
79+
os.system('chcp 437 > nul')
80+
81+
return False
82+
6683
parser = init_argparse()
6784
args = parser.parse_args()
6885
args.func(args)

0 commit comments

Comments
 (0)