21
21
import subprocess
22
22
import sys
23
23
import time
24
+ import requests
24
25
25
26
import click
26
27
import semantic_version
29
30
30
31
log = logging .getLogger (__name__ )
31
32
33
+ PIO_CORE_API_URL = (
34
+ "https://api.github.com/repos/pioarduino/"
35
+ "platformio-core/releases/latest"
36
+ )
37
+ api_data = requests .get (PIO_CORE_API_URL , timeout = 10 ).json ()
38
+ try :
39
+ data = api_data ["zipball_url" ]
40
+ except KeyError :
41
+ data = "https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.16.zip"
42
+ print (
43
+ "Could not download actual pioarduino core. Try to install v6.1.16 instead."
44
+ )
45
+ PIO_CORE_RELEASE_URL = data
32
46
PIO_CORE_DEVELOP_URL = (
33
47
"https://github.com/pioarduino/platformio-core/"
34
48
"archive/pio_github.zip"
35
49
)
36
- PIO_CORE_RELEASE_URL = (
37
- "https://github.com/pioarduino/platformio-core/"
38
- "archive/refs/tags/v6.1.16+test.zip"
39
- )
40
- UPDATE_INTERVAL = 60 * 60 * 24 * 3 # 3 days
50
+ UPDATE_INTERVAL = 60 * 60 * 24 * 31 # 31 days
41
51
42
52
43
53
def get_core_dir (force_to_root = False ):
@@ -111,10 +121,10 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
111
121
)
112
122
command = [python_exe , "-m" , "pip" , "install" , "-U" ]
113
123
if develop :
114
- click .echo ("Installing a development version of PlatformIO Core" )
124
+ click .echo ("Installing a development version of pioarduino Core" )
115
125
command .append (PIO_CORE_DEVELOP_URL )
116
126
else :
117
- click .echo ("Installing PlatformIO Core" )
127
+ click .echo ("Installing pioarduino Core" )
118
128
command .append (PIO_CORE_RELEASE_URL )
119
129
try :
120
130
subprocess .check_call (command )
@@ -126,15 +136,15 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
126
136
" try to disable it for a while.\n %s" % error
127
137
)
128
138
raise exception .PIOInstallerException (
129
- "Could not install PlatformIO Core: %s" % error
139
+ "Could not install pioarduino Core: %s" % error
130
140
)
131
141
platformio_exe = os .path .join (
132
142
penv .get_penv_bin_dir (penv_dir ),
133
143
"platformio.exe" if util .IS_WINDOWS else "platformio" ,
134
144
)
135
145
136
146
click .secho (
137
- "\n PlatformIO Core has been successfully installed into an isolated environment `%s`!\n "
147
+ "\n pioarduino Core has been successfully installed into an isolated environment `%s`!\n "
138
148
% penv_dir ,
139
149
fg = "green" ,
140
150
)
@@ -143,9 +153,7 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
143
153
click .secho (
144
154
"""
145
155
If you need an access to `platformio.exe` from other applications, please install Shell Commands
146
- (add PlatformIO Core binary directory `%s` to the system environment PATH variable):
147
-
148
- See https://docs.platformio.org/page/installation.html#install-shell-commands
156
+ (add pioarduino Core binary directory `%s` to the system environment PATH variable).
149
157
"""
150
158
% penv .get_penv_bin_dir (penv_dir ),
151
159
fg = "cyan" ,
@@ -173,7 +181,7 @@ def check(develop=False, global_=False, auto_upgrade=False, version_spec=None):
173
181
)
174
182
if not os .path .isfile (platformio_exe ):
175
183
raise exception .InvalidPlatformIOCore (
176
- "PlatformIO executable not found in `%s`" % penv .get_penv_bin_dir ()
184
+ "pioarduino executable not found in `%s`" % penv .get_penv_bin_dir ()
177
185
)
178
186
try :
179
187
subprocess .check_output ([platformio_exe , "--help" ], stderr = subprocess .STDOUT )
@@ -189,7 +197,7 @@ def check(develop=False, global_=False, auto_upgrade=False, version_spec=None):
189
197
except subprocess .CalledProcessError as e :
190
198
error = e .output .decode ()
191
199
raise exception .InvalidPlatformIOCore (
192
- "Could not import PlatformIO module. Error: %s" % error
200
+ "Could not import pioarduino module. Error: %s" % error
193
201
)
194
202
piocore_version = convert_version (result .get ("core_version" ))
195
203
develop = develop or bool (piocore_version .prerelease if piocore_version else False )
@@ -220,7 +228,7 @@ def check(develop=False, global_=False, auto_upgrade=False, version_spec=None):
220
228
try :
221
229
result .update (fetch_python_state (python_exe ))
222
230
except : # pylint:disable=bare-except
223
- raise exception .InvalidPlatformIOCore ("Could not import PlatformIO module" )
231
+ raise exception .InvalidPlatformIOCore ("Could not import pioarduino module" )
224
232
225
233
return result
226
234
@@ -229,7 +237,7 @@ def _check_core_version(piocore_version, version_spec):
229
237
try :
230
238
if piocore_version not in semantic_version .Spec (version_spec ):
231
239
raise exception .InvalidPlatformIOCore (
232
- "PlatformIO Core version %s does not match version requirements %s."
240
+ "pioarduino Core version %s does not match version requirements %s."
233
241
% (str (piocore_version ), version_spec )
234
242
)
235
243
except ValueError :
@@ -254,7 +262,7 @@ def _check_platform_version():
254
262
):
255
263
return True
256
264
raise exception .InvalidPlatformIOCore (
257
- "PlatformIO Core was installed using another platform `%s`. "
265
+ "pioarduino Core was installed using another platform `%s`. "
258
266
"Your current platform: %s"
259
267
% (platform_state .get ("platform" ), platform .platform (terse = True ))
260
268
)
@@ -327,7 +335,7 @@ def auto_upgrade_core(platformio_exe, develop=False):
327
335
return True
328
336
except Exception as e : # pylint:disable=broad-except
329
337
raise exception .PIOInstallerException (
330
- "Could not upgrade PlatformIO Core: %s" % str (e )
338
+ "Could not upgrade pioarduino Core: %s" % str (e )
331
339
)
332
340
return False
333
341
0 commit comments