Skip to content

Commit 3e6670a

Browse files
authored
Merge pull request #110 from SummerGGift/for_python3
【更新】 python3
2 parents 593e844 + a939ca6 commit 3e6670a

File tree

9 files changed

+1236
-1191
lines changed

9 files changed

+1236
-1191
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,6 @@ ENV/
9999

100100
# mypy
101101
.mypy_cache/
102+
.vscode/settings.json
103+
cmds/.config.old
104+
/cmds/.config

archive.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
103103

104104
def packtest(path):
105105
ret = True
106-
if ".zip" in path:
106+
107+
if path.find(".zip") != -1:
107108
try:
108109
if zipfile.is_zipfile(path):
109110
# Test zip again to make sure it's a right zip file.
@@ -114,24 +115,26 @@ def packtest(path):
114115
else:
115116
ret = False
116117
print('package check error. \n')
117-
except Exception, e:
118-
print('packtest e.message:%s\t' % e.message)
119-
# arch.close()
118+
except Exception as e:
119+
print('packtest error message:%s\t' % e)
120120
print("The archive package is broken. \n")
121+
arch.close()
121122
ret = False
122123

123-
if ".tar.bz2" in path:
124+
# if ".tar.bz2" in path:.
125+
if path.find(".tar.bz2") != -1:
124126
try:
125127
if not tarfile.is_tarfile(path):
126128
ret = False
127-
except Exception, e:
129+
except Exception as e:
128130
ret = False
129131

130-
if ".tar.gz" in path:
132+
# if ".tar.gz" in path:
133+
if path.find(".tar.gz") != -1:
131134
try:
132135
if not tarfile.is_tarfile(path):
133136
ret = False
134-
except Exception, e:
137+
except Exception as e:
135138
ret = False
136139

137140
return ret

cmds/cmd_menuconfig.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def mk_rtconfig(filename):
101101

102102
def find_macro_in_config(filename, macro_name):
103103
try:
104-
config = file(filename)
104+
config = open(filename, "r")
105105
except:
106-
print 'open .config failed'
106+
print('open .config failed')
107107
return
108108

109109
empty_line = 1
@@ -141,6 +141,7 @@ def find_macro_in_config(filename, macro_name):
141141
if setting[0] == macro_name and setting[1] == 'y':
142142
return True
143143

144+
config.close()
144145
return False
145146

146147

@@ -178,7 +179,7 @@ def cmd(args):
178179
os.system('chcp 437 > nul')
179180

180181
if args.menuconfig_fn:
181-
print 'use', args.menuconfig_fn
182+
print('use', args.menuconfig_fn)
182183
import shutil
183184
shutil.copy(args.menuconfig_fn, fn)
184185
elif args.menuconfig_g:
@@ -236,18 +237,18 @@ def cmd(args):
236237

237238
if find_macro_in_config(fn, 'SYS_AUTO_UPDATE_PKGS'):
238239
os.system('pkgs --update')
239-
print "==============================>The packages have been updated completely."
240+
print("==============================>The packages have been updated completely.")
240241

241242
if find_macro_in_config(fn, 'SYS_CREATE_MDK_IAR_PROJECT'):
242243
if find_macro_in_config(fn, 'SYS_CREATE_MDK4'):
243244
os.system('scons --target=mdk4 -s')
244-
print "Create mdk4 project done"
245+
print("Create mdk4 project done")
245246
elif find_macro_in_config(fn, 'SYS_CREATE_MDK5'):
246247
os.system('scons --target=mdk5 -s')
247-
print "Create mdk5 project done"
248+
print("Create mdk5 project done")
248249
elif find_macro_in_config(fn, 'SYS_CREATE_IAR'):
249250
os.system('scons --target=iar -s')
250-
print "Create iar project done"
251+
print("Create iar project done")
251252

252253

253254
def add_parser(sub):

0 commit comments

Comments
 (0)