forked from platformio/platformio-core
Use "ensure_python3" util
This commit is contained in:
@ -23,12 +23,12 @@ from time import sleep
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from platformio import exception, fs, proc
|
from platformio import fs, proc
|
||||||
from platformio.commands.device import helpers as device_helpers
|
from platformio.commands.device import helpers as device_helpers
|
||||||
from platformio.commands.device.command import device_monitor as cmd_device_monitor
|
from platformio.commands.device.command import device_monitor as cmd_device_monitor
|
||||||
from platformio.commands.run.command import cli as cmd_run
|
from platformio.commands.run.command import cli as cmd_run
|
||||||
from platformio.commands.test.command import cli as cmd_test
|
from platformio.commands.test.command import cli as cmd_test
|
||||||
from platformio.compat import PY2
|
from platformio.compat import ensure_python3
|
||||||
from platformio.package.manager.core import inject_contrib_pysite
|
from platformio.package.manager.core import inject_contrib_pysite
|
||||||
from platformio.project.exception import NotPlatformIOProjectError
|
from platformio.project.exception import NotPlatformIOProjectError
|
||||||
|
|
||||||
@ -37,13 +37,7 @@ from platformio.project.exception import NotPlatformIOProjectError
|
|||||||
@click.option("-a", "--agent", multiple=True)
|
@click.option("-a", "--agent", multiple=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, agent):
|
def cli(ctx, agent):
|
||||||
if PY2:
|
assert ensure_python3()
|
||||||
raise exception.UserSideException(
|
|
||||||
"PlatformIO Remote Development requires Python 3.5 or above. \n"
|
|
||||||
"Please install the latest Python 3 and reinstall PlatformIO Core using "
|
|
||||||
"installation script:\n"
|
|
||||||
"https://docs.platformio.org/page/core/installation.html"
|
|
||||||
)
|
|
||||||
ctx.obj = agent
|
ctx.obj = agent
|
||||||
inject_contrib_pysite(verify_openssl=True)
|
inject_contrib_pysite(verify_openssl=True)
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from platformio.exception import UserSideException
|
||||||
|
|
||||||
PY2 = sys.version_info[0] == 2
|
PY2 = sys.version_info[0] == 2
|
||||||
CYGWIN = sys.platform.startswith("cygwin")
|
CYGWIN = sys.platform.startswith("cygwin")
|
||||||
WINDOWS = sys.platform.startswith("win")
|
WINDOWS = sys.platform.startswith("win")
|
||||||
@ -59,6 +61,17 @@ def ci_strings_are_equal(a, b):
|
|||||||
return a.strip().lower() == b.strip().lower()
|
return a.strip().lower() == b.strip().lower()
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_python3(raise_exception=True):
|
||||||
|
if not raise_exception or not PY2:
|
||||||
|
return not PY2
|
||||||
|
raise UserSideException(
|
||||||
|
"Python 3.5 or later is required for this operation. \n"
|
||||||
|
"Please install the latest Python 3 and reinstall PlatformIO Core using "
|
||||||
|
"installation script:\n"
|
||||||
|
"https://docs.platformio.org/page/core/installation.html"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
import imp
|
import imp
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user