55import os
66
77packagesPath = "package_air_index.json"
8+ packagesCNPath = "package_air_cn_index.json"
89
910GCCVersion = "12.2.1-1.2"
10- AirISPVersion = "" # 不定义具体的版本,在GetAirISPVersion函数中创造
11+ AirISPVersion = "" # 不定义具体的版本,在GetAirISPVersion函数中创造
1112CMSISVersion = "5.7.0"
1213PlatformsVersion = []
1314
@@ -27,6 +28,7 @@ def GetAirISPVersion():
2728 else :
2829 print (f"Request failed: { response .status_code } " )
2930
31+
3032def GetRepoVersion (owner , repo ):
3133 url = f"https://api.github.com/repos/{ owner } /{ repo } /releases"
3234
@@ -89,6 +91,7 @@ def downloadFile(url):
8991
9092def DownloadAndCheck (url , fileName , host , suffixName ):
9193 temp = {}
94+ tempCn = {}
9295 url += fileName
9396 temp ['host' ] = host
9497 tempUrl = url + suffixName
@@ -99,97 +102,131 @@ def DownloadAndCheck(url, fileName, host, suffixName):
99102 tempPath = fileName + suffixName
100103 temp ['checksum' ] = "SHA-256:" + ComputeSHA256 (tempPath )
101104 temp ['size' ] = ComputeSize (tempPath )
102- return temp
105+
106+ tempCn = temp
107+ tempCn ['url' ] = "https://arduino.luatos.com/" + fileName + suffixName
108+ return temp , tempCn
103109
104110
105111def GCC ():
106112 data = {'name' : "xpack-arm-none-eabi-gcc" , 'version' : GCCVersion }
113+ dataCn = data
107114 system = []
115+ systemCn = []
108116
109117 def f (host , suffixName ):
110118 url = "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v" + GCCVersion + "/"
111119 fileName = "xpack-arm-none-eabi-gcc-" + GCCVersion + "-"
112120 return DownloadAndCheck (url , fileName , host , suffixName )
113121
114- temp = f ("x86_64-mingw32" , "win32-x64.zip" )
122+ temp , tempCn = f ("x86_64-mingw32" , "win32-x64.zip" )
115123 system .append (temp )
116- temp = f ("i686-mingw32" , "win32-x64.zip" )
124+ systemCn .append (tempCn )
125+ temp , tempCn = f ("i686-mingw32" , "win32-x64.zip" )
117126 system .append (temp )
118- temp = f ("x86_64-apple-darwin" , "darwin-x64.tar.gz" )
127+ systemCn .append (tempCn )
128+ temp , tempCn = f ("x86_64-apple-darwin" , "darwin-x64.tar.gz" )
119129 system .append (temp )
120- temp = f ("arm64-apple-darwin" , "darwin-arm64.tar.gz" )
130+ systemCn .append (tempCn )
131+ temp , tempCn = f ("arm64-apple-darwin" , "darwin-arm64.tar.gz" )
121132 system .append (temp )
122- temp = f ("arm-linux-gnueabihf" , "linux-arm.tar.gz" )
133+ systemCn .append (tempCn )
134+ temp , tempCn = f ("arm-linux-gnueabihf" , "linux-arm.tar.gz" )
123135 system .append (temp )
124- temp = f ("aarch64-linux-gnu" , "linux-arm64.tar.gz" )
136+ systemCn .append (tempCn )
137+ temp , tempCn = f ("aarch64-linux-gnu" , "linux-arm64.tar.gz" )
125138 system .append (temp )
126- temp = f ("x86_64-pc-linux-gnu" , "linux-x64.tar.gz" )
139+ systemCn .append (tempCn )
140+ temp , tempCn = f ("x86_64-pc-linux-gnu" , "linux-x64.tar.gz" )
127141 system .append (temp )
142+ systemCn .append (tempCn )
128143 data ['systems' ] = system
129- return data
144+ dataCn ['systems' ] = systemCn
145+ return data , dataCn
130146
131147
132148def AirISP ():
133149 data = {'name' : "AirISP" , 'version' : AirISPVersion }
150+ dataCn = data
134151 system = []
152+ systemCn = []
135153
136154 def f (host , suffixName ):
137155 url = "https://github.com/Air-duino/AirISP/releases/download/" + AirISPVersion + "/"
138156 fileName = "AirISP-"
139157 return DownloadAndCheck (url , fileName , host , suffixName )
140158
141- temp = f ("x86_64-mingw32" , "win-x64.zip" )
159+ temp , tempCn = f ("x86_64-mingw32" , "win-x64.zip" )
142160 system .append (temp )
143- temp = f ("i686-mingw32" , "win-x64.zip" )
161+ systemCn .append (tempCn )
162+ temp , tempCn = f ("i686-mingw32" , "win-x64.zip" )
144163 system .append (temp )
145- temp = f ("x86_64-apple-darwin" , "osx-x64.zip" )
164+ systemCn .append (tempCn )
165+ temp , tempCn = f ("x86_64-apple-darwin" , "osx-x64.zip" )
146166 system .append (temp )
147- temp = f ("arm64-apple-darwin" , "osx-arm64.zip" )
167+ systemCn .append (tempCn )
168+ temp , tempCn = f ("arm64-apple-darwin" , "osx-arm64.zip" )
148169 system .append (temp )
149- temp = f ("arm-linux-gnueabihf" , "linux-arm.zip" )
170+ systemCn .append (tempCn )
171+ temp , tempCn = f ("arm-linux-gnueabihf" , "linux-arm.zip" )
150172 system .append (temp )
151- temp = f ("aarch64-linux-gnu" , "linux-arm64.zip" )
173+ systemCn .append (tempCn )
174+ temp , tempCn = f ("aarch64-linux-gnu" , "linux-arm64.zip" )
152175 system .append (temp )
153- temp = f ("x86_64-pc-linux-gnu" , "linux-x64.zip" )
176+ systemCn .append (tempCn )
177+ temp , tempCn = f ("x86_64-pc-linux-gnu" , "linux-x64.zip" )
154178 system .append (temp )
179+ systemCn .append (tempCn )
180+
155181 data ['systems' ] = system
156- print ( data )
157- return data
182+ dataCn [ 'systems' ] = systemCn
183+ return data , dataCn
158184
159185
160186def CMSIS ():
161187 data = {'name' : "CMSIS" , 'version' : CMSISVersion }
188+ dataCn = data
162189 system = []
190+ systemCn = []
163191
164192 def f (host , suffixName ):
165193 url = "https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/" + CMSISVersion + "/"
166194 fileName = "CMSIS-" + CMSISVersion
167195 return DownloadAndCheck (url , fileName , host , suffixName )
168196
169- temp = f ("x86_64-mingw32" , ".tar.bz2" )
197+ temp , tempCn = f ("x86_64-mingw32" , ".tar.bz2" )
170198 system .append (temp )
171- temp = f ("i686-mingw32" , ".tar.bz2" )
199+ systemCn .append (tempCn )
200+ temp , tempCn = f ("i686-mingw32" , ".tar.bz2" )
172201 system .append (temp )
173- temp = f ("x86_64-apple-darwin" , ".tar.bz2" )
202+ systemCn .append (tempCn )
203+ temp , tempCn = f ("x86_64-apple-darwin" , ".tar.bz2" )
174204 system .append (temp )
175- temp = f ("arm64-apple-darwin" , ".tar.bz2" )
205+ systemCn .append (tempCn )
206+ temp , tempCn = f ("arm64-apple-darwin" , ".tar.bz2" )
176207 system .append (temp )
177- temp = f ("arm-linux-gnueabihf" , ".tar.bz2" )
208+ systemCn .append (tempCn )
209+ temp , tempCn = f ("arm-linux-gnueabihf" , ".tar.bz2" )
178210 system .append (temp )
179- temp = f ("aarch64-linux-gnu" , ".tar.bz2" )
211+ systemCn .append (tempCn )
212+ temp , tempCn = f ("aarch64-linux-gnu" , ".tar.bz2" )
180213 system .append (temp )
181- temp = f ("x86_64-pc-linux-gnu" , ".tar.bz2" )
214+ systemCn .append (tempCn )
215+ temp , tempCn = f ("x86_64-pc-linux-gnu" , ".tar.bz2" )
182216 system .append (temp )
217+ systemCn .append (tempCn )
218+
183219 data ['systems' ] = system
184- print ( data )
185- return data
220+ dataCn [ 'systems' ] = systemCn
221+ return data , dataCn
186222
187223
188224def PlatformsAirMCU (version ):
189225 fileName = "AirMCU-" + version + ".zip"
190226 url = "https://github.com/Air-duino/Arduino-AirMCU/releases/download/" + version + "/" + fileName
191227 downloadFile (url )
192228 data = {}
229+ dataCn = {}
193230 data ['name' ] = "Air MCU"
194231 data ['architecture' ] = "AirMCU"
195232 data ['version' ] = version
@@ -203,34 +240,62 @@ def PlatformsAirMCU(version):
203240 data ['toolsDependencies' ] = [{'packager' : "AirM2M" , 'name' : "xpack-arm-none-eabi-gcc" , 'version' : GCCVersion },
204241 {'packager' : "AirM2M" , 'name' : "CMSIS" , 'version' : CMSISVersion },
205242 {'packager' : "AirM2M" , 'name' : "AirISP" , 'version' : AirISPVersion }]
206- return data
243+ dataCn = data
244+ dataCn ['url' ] = "https://arduino.luatos.com/" + version + "/" + fileName
245+ return data , dataCn
207246
208247
209248def PackagesAirM2M ():
210249 data = {}
250+ dataCn = {}
211251 data ['name' ] = "AirM2M"
212252 data ['maintainer' ] = "AirM2M"
213253 data ['websiteURL' ] = "https://github.com/Air-duino"
214254 data ['email' ] = "HalfSweet@HalfSweet.cn"
215255 data ['help' ] = {'online' : "https://github.com/Air-duino" }
216256 platforms = []
257+ platformsCn = []
217258
218259 PlatformsVersion .extend (GetRepoVersion ("Air-duino" , "Arduino-AirMCU" ))
219260 for item in PlatformsVersion :
220- platforms .append (PlatformsAirMCU (item ))
261+ temp ,tempCn = PlatformsAirMCU (item )
262+ platforms .append (temp )
263+ platformsCn .append (tempCn )
221264 data ['platforms' ] = platforms
222- tools = [GCC (), CMSIS (), AirISP ()]
265+ tools = []
266+ toolsCn = []
267+
268+ temp , tempCn = GCC ()
269+ tools .append (temp )
270+ toolsCn .append (tempCn )
271+
272+ temp , tempCn = CMSIS ()
273+ tools .append (temp )
274+ toolsCn .append (tempCn )
275+
276+ temp , tempCn = AirISP ()
277+ tools .append (temp )
278+ toolsCn .append (tempCn )
279+
223280 data ['tools' ] = tools
224- return data
281+ dataCn = data
282+ dataCn ['tools' ] = toolsCn
283+ return data , dataCn
225284
226285
227286def Encode ():
228287 data = {}
229- data ['packages' ] = [PackagesAirM2M ()]
288+ dataCn = {}
289+ temp , tempCn = PackagesAirM2M ()
290+ data ['packages' ] = [temp ]
291+ dataCn ['packages' ] = [tempCn ]
230292 json_str = json .dumps (data , indent = 2 )
231293 with open (packagesPath , "w+" ) as f :
232294 f .write (json_str )
233- return json_str
295+ json_str_cn = json .dumps (dataCn , indent = 2 )
296+ with open (packagesCNPath , "w+" ) as f :
297+ f .write (json_str_cn )
298+ return json_str ,json_str_cn
234299
235300
236301def main ():
0 commit comments