5
5
import os
6
6
7
7
packagesPath = "package_air_index.json"
8
+ packagesCNPath = "package_air_cn_index.json"
8
9
9
10
GCCVersion = "12.2.1-1.2"
10
- AirISPVersion = "" # 不定义具体的版本,在GetAirISPVersion函数中创造
11
+ AirISPVersion = "" # 不定义具体的版本,在GetAirISPVersion函数中创造
11
12
CMSISVersion = "5.7.0"
12
13
PlatformsVersion = []
13
14
@@ -27,6 +28,7 @@ def GetAirISPVersion():
27
28
else :
28
29
print (f"Request failed: { response .status_code } " )
29
30
31
+
30
32
def GetRepoVersion (owner , repo ):
31
33
url = f"https://api.github.com/repos/{ owner } /{ repo } /releases"
32
34
@@ -89,6 +91,7 @@ def downloadFile(url):
89
91
90
92
def DownloadAndCheck (url , fileName , host , suffixName ):
91
93
temp = {}
94
+ tempCn = {}
92
95
url += fileName
93
96
temp ['host' ] = host
94
97
tempUrl = url + suffixName
@@ -99,97 +102,131 @@ def DownloadAndCheck(url, fileName, host, suffixName):
99
102
tempPath = fileName + suffixName
100
103
temp ['checksum' ] = "SHA-256:" + ComputeSHA256 (tempPath )
101
104
temp ['size' ] = ComputeSize (tempPath )
102
- return temp
105
+
106
+ tempCn = temp
107
+ tempCn ['url' ] = "https://arduino.luatos.com/" + fileName + suffixName
108
+ return temp , tempCn
103
109
104
110
105
111
def GCC ():
106
112
data = {'name' : "xpack-arm-none-eabi-gcc" , 'version' : GCCVersion }
113
+ dataCn = data
107
114
system = []
115
+ systemCn = []
108
116
109
117
def f (host , suffixName ):
110
118
url = "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v" + GCCVersion + "/"
111
119
fileName = "xpack-arm-none-eabi-gcc-" + GCCVersion + "-"
112
120
return DownloadAndCheck (url , fileName , host , suffixName )
113
121
114
- temp = f ("x86_64-mingw32" , "win32-x64.zip" )
122
+ temp , tempCn = f ("x86_64-mingw32" , "win32-x64.zip" )
115
123
system .append (temp )
116
- temp = f ("i686-mingw32" , "win32-x64.zip" )
124
+ systemCn .append (tempCn )
125
+ temp , tempCn = f ("i686-mingw32" , "win32-x64.zip" )
117
126
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" )
119
129
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" )
121
132
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" )
123
135
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" )
125
138
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" )
127
141
system .append (temp )
142
+ systemCn .append (tempCn )
128
143
data ['systems' ] = system
129
- return data
144
+ dataCn ['systems' ] = systemCn
145
+ return data , dataCn
130
146
131
147
132
148
def AirISP ():
133
149
data = {'name' : "AirISP" , 'version' : AirISPVersion }
150
+ dataCn = data
134
151
system = []
152
+ systemCn = []
135
153
136
154
def f (host , suffixName ):
137
155
url = "https://github.com/Air-duino/AirISP/releases/download/" + AirISPVersion + "/"
138
156
fileName = "AirISP-"
139
157
return DownloadAndCheck (url , fileName , host , suffixName )
140
158
141
- temp = f ("x86_64-mingw32" , "win-x64.zip" )
159
+ temp , tempCn = f ("x86_64-mingw32" , "win-x64.zip" )
142
160
system .append (temp )
143
- temp = f ("i686-mingw32" , "win-x64.zip" )
161
+ systemCn .append (tempCn )
162
+ temp , tempCn = f ("i686-mingw32" , "win-x64.zip" )
144
163
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" )
146
166
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" )
148
169
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" )
150
172
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" )
152
175
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" )
154
178
system .append (temp )
179
+ systemCn .append (tempCn )
180
+
155
181
data ['systems' ] = system
156
- print ( data )
157
- return data
182
+ dataCn [ 'systems' ] = systemCn
183
+ return data , dataCn
158
184
159
185
160
186
def CMSIS ():
161
187
data = {'name' : "CMSIS" , 'version' : CMSISVersion }
188
+ dataCn = data
162
189
system = []
190
+ systemCn = []
163
191
164
192
def f (host , suffixName ):
165
193
url = "https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/" + CMSISVersion + "/"
166
194
fileName = "CMSIS-" + CMSISVersion
167
195
return DownloadAndCheck (url , fileName , host , suffixName )
168
196
169
- temp = f ("x86_64-mingw32" , ".tar.bz2" )
197
+ temp , tempCn = f ("x86_64-mingw32" , ".tar.bz2" )
170
198
system .append (temp )
171
- temp = f ("i686-mingw32" , ".tar.bz2" )
199
+ systemCn .append (tempCn )
200
+ temp , tempCn = f ("i686-mingw32" , ".tar.bz2" )
172
201
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" )
174
204
system .append (temp )
175
- temp = f ("arm64-apple-darwin" , ".tar.bz2" )
205
+ systemCn .append (tempCn )
206
+ temp , tempCn = f ("arm64-apple-darwin" , ".tar.bz2" )
176
207
system .append (temp )
177
- temp = f ("arm-linux-gnueabihf" , ".tar.bz2" )
208
+ systemCn .append (tempCn )
209
+ temp , tempCn = f ("arm-linux-gnueabihf" , ".tar.bz2" )
178
210
system .append (temp )
179
- temp = f ("aarch64-linux-gnu" , ".tar.bz2" )
211
+ systemCn .append (tempCn )
212
+ temp , tempCn = f ("aarch64-linux-gnu" , ".tar.bz2" )
180
213
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" )
182
216
system .append (temp )
217
+ systemCn .append (tempCn )
218
+
183
219
data ['systems' ] = system
184
- print ( data )
185
- return data
220
+ dataCn [ 'systems' ] = systemCn
221
+ return data , dataCn
186
222
187
223
188
224
def PlatformsAirMCU (version ):
189
225
fileName = "AirMCU-" + version + ".zip"
190
226
url = "https://github.com/Air-duino/Arduino-AirMCU/releases/download/" + version + "/" + fileName
191
227
downloadFile (url )
192
228
data = {}
229
+ dataCn = {}
193
230
data ['name' ] = "Air MCU"
194
231
data ['architecture' ] = "AirMCU"
195
232
data ['version' ] = version
@@ -203,34 +240,62 @@ def PlatformsAirMCU(version):
203
240
data ['toolsDependencies' ] = [{'packager' : "AirM2M" , 'name' : "xpack-arm-none-eabi-gcc" , 'version' : GCCVersion },
204
241
{'packager' : "AirM2M" , 'name' : "CMSIS" , 'version' : CMSISVersion },
205
242
{'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
207
246
208
247
209
248
def PackagesAirM2M ():
210
249
data = {}
250
+ dataCn = {}
211
251
data ['name' ] = "AirM2M"
212
252
data ['maintainer' ] = "AirM2M"
213
253
data ['websiteURL' ] = "https://github.com/Air-duino"
214
254
data [
'email' ]
= "[email protected] "
215
255
data ['help' ] = {'online' : "https://github.com/Air-duino" }
216
256
platforms = []
257
+ platformsCn = []
217
258
218
259
PlatformsVersion .extend (GetRepoVersion ("Air-duino" , "Arduino-AirMCU" ))
219
260
for item in PlatformsVersion :
220
- platforms .append (PlatformsAirMCU (item ))
261
+ temp ,tempCn = PlatformsAirMCU (item )
262
+ platforms .append (temp )
263
+ platformsCn .append (tempCn )
221
264
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
+
223
280
data ['tools' ] = tools
224
- return data
281
+ dataCn = data
282
+ dataCn ['tools' ] = toolsCn
283
+ return data , dataCn
225
284
226
285
227
286
def Encode ():
228
287
data = {}
229
- data ['packages' ] = [PackagesAirM2M ()]
288
+ dataCn = {}
289
+ temp , tempCn = PackagesAirM2M ()
290
+ data ['packages' ] = [temp ]
291
+ dataCn ['packages' ] = [tempCn ]
230
292
json_str = json .dumps (data , indent = 2 )
231
293
with open (packagesPath , "w+" ) as f :
232
294
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
234
299
235
300
236
301
def main ():
0 commit comments