Skip to content

Commit 0a16f38

Browse files
authored
Merge pull request #78 from RT-Thread/develop
【更新】:升级到 1.1 版本 env 功能代码,优化错误处理逻辑
2 parents 67f7620 + b487c88 commit 0a16f38

File tree

5 files changed

+163
-197
lines changed

5 files changed

+163
-197
lines changed

archive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030

3131

3232
def unpack(archive_fn, path, pkg, pkgs_name_in_json):
33-
33+
pkg_ver = pkg['ver']
3434
flag = True
35-
35+
3636
if ".tar.bz2" in archive_fn:
3737
arch = tarfile.open(archive_fn, "r:bz2")
3838
for tarinfo in arch:
@@ -64,7 +64,7 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
6464
# Gets the folder name and change_dirname only once
6565
if flag:
6666
dir_name = os.path.split(right_path)[0]
67-
change_dirname = pkgs_name_in_json + '-' + pkg['ver']
67+
change_dirname = pkgs_name_in_json + '-' + pkg_ver
6868
flag = False
6969

7070
right_name_to_db = right_path.replace(dir_name, change_dirname, 1)
@@ -73,7 +73,7 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
7373

7474
# Change the folder name
7575

76-
change_dirname = pkgs_name_in_json + '-' + pkg['ver']
76+
change_dirname = pkgs_name_in_json + '-' + pkg_ver
7777

7878
if os.path.isdir(os.path.join(path, change_dirname)):
7979
cmd = 'rd /s /q ' + os.path.join(path, change_dirname)

cmds/cmd_menuconfig.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#
2121
# Change Logs:
2222
# Date Author Notes
23-
# 2018-5-28 SummerGift Add copyright information
23+
# 2018-05-28 SummerGift Add copyright information
24+
# 2019-01-07 SummerGift The prompt supports utf-8 encoding
2425
#
2526

2627
import os
@@ -151,30 +152,35 @@ def find_macro_in_config(filename, macro_name):
151152

152153

153154
def cmd(args):
155+
156+
from cmd_package import determine_support_chinese
154157
env_root = Import('env_root')
155158
currentdir = os.getcwd()
156159
dirname = os.path.split(os.path.split(currentdir)[0])[0]
157160
get_rtt_name = os.path.basename(dirname)
158161
os_version = platform.platform(True)[10:13]
159-
# print os.path.split(currentdir)[1]
160162
kconfig_win7_path = os.path.join(
161163
env_root, 'tools', 'bin', 'kconfig-mconf_win7.exe')
162164

163165
if not os.getenv("RTT_ROOT"):
164166
if get_rtt_name != 'rt-thread':
165-
print ("menuconfig command should be used in a bsp root path with a Kconfig file, you should check if there is a Kconfig file in your bsp root first.")
166-
print (
167-
'And then you can check Kconfig file and modify the default option below to your rtthread root path.\n')
167+
if determine_support_chinese(env_root):
168+
print("\n<menuconfig> 命令应当在某一特定 BSP 目录下执行,例如:\"rt-thread/bsp/stm32/stm32f091-st-nucleo\"")
169+
print("请确保当前目录为 BSP 根目录,并且该目录中有 Kconfig 文件。\n")
170+
171+
print ("<menuconfig> command should be used in a bsp root path with a Kconfig file.")
172+
print ("Example: \"rt-thread/bsp/stm32/stm32f091-st-nucleo\"")
173+
print ("You should check if there is a Kconfig file in your bsp root first.")
168174

169-
print ('config $RTT_DIR')
175+
print ('\nconfig $RTT_DIR')
170176
print ('string')
171177
print ('option env="RTT_ROOT"')
172178
print ('default "../.."\n')
173-
print ('example: default "F:/git_repositories/rt-thread" \n')
174179

175-
print (
176-
"using command 'set RTT_ROOT=your_rtthread_root_path' to set RTT_ROOT is ok too.\n")
177-
print ("you can ignore debug messages below.")
180+
if determine_support_chinese(env_root):
181+
print ('例如修改 default 这一项为 rt-thread 所在路径: default "F:/git_repositories/rt-thread"')
182+
print ('\n下面的警告信息提示与找不到正确的 Kconfig 文件有关:')
183+
178184
# if not args.menuconfig_easy:
179185
# return
180186

@@ -185,6 +191,9 @@ def cmd(args):
185191
else:
186192
mtime = -1
187193

194+
if platform.system() == "Windows":
195+
os.system('chcp 437 > nul')
196+
188197
if args.menuconfig_fn:
189198
print 'use', args.menuconfig_fn
190199
import shutil
@@ -215,7 +224,12 @@ def cmd(args):
215224
os.system('kconfig-mconf Kconfig')
216225

217226
os.chdir(beforepath)
227+
228+
if determine_support_chinese(env_root):
229+
if platform.system() == "Windows":
230+
os.system('chcp 65001 > nul')
218231
return
232+
219233
else:
220234
if float(os_version) >= 6.2:
221235
os.system('kconfig-mconf Kconfig')
@@ -233,14 +247,17 @@ def cmd(args):
233247
if mtime != mtime2:
234248
mk_rtconfig(fn)
235249

250+
if determine_support_chinese(env_root):
251+
if platform.system() == "Windows":
252+
os.system('chcp 65001 > nul')
253+
236254
if platform.system() == "Windows":
237255
env_kconfig_path = os.path.join(env_root, 'tools\scripts\cmds')
238256
fn = os.path.join(env_kconfig_path, '.config')
239257

240258
if not os.path.isfile(fn):
241259
return
242260

243-
244261
if find_macro_in_config(fn, 'SYS_AUTO_UPDATE_PKGS'):
245262
os.system('pkgs --update')
246263
print "==============================>The packages have been updated completely."

0 commit comments

Comments
 (0)