2121import subprocess
2222import sys
2323import time
24+ import requests
2425
2526import click
2627import semantic_version
2930
3031log = logging .getLogger (__name__ )
3132
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
3246PIO_CORE_DEVELOP_URL = (
3347 "https://github.com/pioarduino/platformio-core/"
3448 "archive/pio_github.zip"
3549)
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
4151
4252
4353def get_core_dir (force_to_root = False ):
@@ -111,10 +121,10 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
111121 )
112122 command = [python_exe , "-m" , "pip" , "install" , "-U" ]
113123 if develop :
114- click .echo ("Installing a development version of PlatformIO Core" )
124+ click .echo ("Installing a development version of pioarduino Core" )
115125 command .append (PIO_CORE_DEVELOP_URL )
116126 else :
117- click .echo ("Installing PlatformIO Core" )
127+ click .echo ("Installing pioarduino Core" )
118128 command .append (PIO_CORE_RELEASE_URL )
119129 try :
120130 subprocess .check_call (command )
@@ -126,15 +136,15 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
126136 " try to disable it for a while.\n %s" % error
127137 )
128138 raise exception .PIOInstallerException (
129- "Could not install PlatformIO Core: %s" % error
139+ "Could not install pioarduino Core: %s" % error
130140 )
131141 platformio_exe = os .path .join (
132142 penv .get_penv_bin_dir (penv_dir ),
133143 "platformio.exe" if util .IS_WINDOWS else "platformio" ,
134144 )
135145
136146 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 "
138148 % penv_dir ,
139149 fg = "green" ,
140150 )
@@ -143,9 +153,7 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
143153 click .secho (
144154 """
145155If 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).
149157"""
150158 % penv .get_penv_bin_dir (penv_dir ),
151159 fg = "cyan" ,
@@ -173,7 +181,7 @@ def check(develop=False, global_=False, auto_upgrade=False, version_spec=None):
173181 )
174182 if not os .path .isfile (platformio_exe ):
175183 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 ()
177185 )
178186 try :
179187 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):
189197 except subprocess .CalledProcessError as e :
190198 error = e .output .decode ()
191199 raise exception .InvalidPlatformIOCore (
192- "Could not import PlatformIO module. Error: %s" % error
200+ "Could not import pioarduino module. Error: %s" % error
193201 )
194202 piocore_version = convert_version (result .get ("core_version" ))
195203 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):
220228 try :
221229 result .update (fetch_python_state (python_exe ))
222230 except : # pylint:disable=bare-except
223- raise exception .InvalidPlatformIOCore ("Could not import PlatformIO module" )
231+ raise exception .InvalidPlatformIOCore ("Could not import pioarduino module" )
224232
225233 return result
226234
@@ -229,7 +237,7 @@ def _check_core_version(piocore_version, version_spec):
229237 try :
230238 if piocore_version not in semantic_version .Spec (version_spec ):
231239 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."
233241 % (str (piocore_version ), version_spec )
234242 )
235243 except ValueError :
@@ -254,7 +262,7 @@ def _check_platform_version():
254262 ):
255263 return True
256264 raise exception .InvalidPlatformIOCore (
257- "PlatformIO Core was installed using another platform `%s`. "
265+ "pioarduino Core was installed using another platform `%s`. "
258266 "Your current platform: %s"
259267 % (platform_state .get ("platform" ), platform .platform (terse = True ))
260268 )
@@ -327,7 +335,7 @@ def auto_upgrade_core(platformio_exe, develop=False):
327335 return True
328336 except Exception as e : # pylint:disable=broad-except
329337 raise exception .PIOInstallerException (
330- "Could not upgrade PlatformIO Core: %s" % str (e )
338+ "Could not upgrade pioarduino Core: %s" % str (e )
331339 )
332340 return False
333341
0 commit comments