forked from platformio/platformio-core
Finally removed all tracks to the Python 2.7
This commit is contained in:
1 parent
541fcbf015
commit
5e18f9bbda
17 files changed
+49
-117
No files matched your search
+2
-11
@@ -12,15 +12,13 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# pylint: disable=import-outside-toplevel
|
||||
|
||||
import os
|
||||
import sys
|
||||
from traceback import format_exc
|
||||
|
||||
import click
|
||||
|
||||
from platformio import __version__, exception
|
||||
from platformio import __version__, exception, maintenance
|
||||
from platformio.commands import PlatformioCLI
|
||||
from platformio.compat import IS_CYGWIN, ensure_python3
|
||||
|
||||
@@ -55,16 +53,12 @@ def cli(ctx, force, caller, no_ansi):
|
||||
except: # pylint: disable=bare-except
|
||||
pass
|
||||
|
||||
from platformio import maintenance
|
||||
|
||||
maintenance.on_platformio_start(ctx, force, caller)
|
||||
|
||||
|
||||
@cli.result_callback()
|
||||
@click.pass_context
|
||||
def process_result(ctx, result, *_, **__):
|
||||
from platformio import maintenance
|
||||
|
||||
maintenance.on_platformio_end(ctx, result)
|
||||
|
||||
|
||||
@@ -111,10 +105,7 @@ def main(argv=None):
|
||||
exit_code = int(e.code)
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
if not isinstance(e, exception.ReturnErrorCode):
|
||||
if sys.version_info.major != 2:
|
||||
from platformio import maintenance
|
||||
|
||||
maintenance.on_platformio_exception(e)
|
||||
maintenance.on_platformio_exception(e)
|
||||
error_str = "Error: "
|
||||
if isinstance(e, exception.PlatformioException):
|
||||
error_str += str(e)
|
||||
|
||||
@@ -16,6 +16,7 @@ import json
|
||||
import math
|
||||
import os
|
||||
import socket
|
||||
from urllib.parse import urljoin
|
||||
|
||||
import requests.adapters
|
||||
from requests.packages.urllib3.util.retry import Retry # pylint:disable=import-error
|
||||
@@ -24,11 +25,6 @@ from platformio import __check_internet_hosts__, __default_requests_timeout__, a
|
||||
from platformio.cache import ContentCache, cleanup_content_cache
|
||||
from platformio.exception import PlatformioException, UserSideException
|
||||
|
||||
try:
|
||||
from urllib.parse import urljoin
|
||||
except ImportError:
|
||||
from urlparse import urljoin
|
||||
|
||||
|
||||
class HTTPClientError(PlatformioException):
|
||||
def __init__(self, message, response=None):
|
||||
|
||||
@@ -14,10 +14,11 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
import threading
|
||||
|
||||
import click
|
||||
from ajsonrpc.core import JSONRPC20DispatchException
|
||||
@@ -27,27 +28,22 @@ from platformio import __main__, __version__, fs, proc
|
||||
from platformio.commands.home import helpers
|
||||
from platformio.compat import get_locale_encoding, is_bytes
|
||||
|
||||
try:
|
||||
from thread import get_ident as thread_get_ident
|
||||
except ImportError:
|
||||
from threading import get_ident as thread_get_ident
|
||||
|
||||
|
||||
class MultiThreadingStdStream(object):
|
||||
def __init__(self, parent_stream):
|
||||
self._buffers = {thread_get_ident(): parent_stream}
|
||||
self._buffers = {threading.get_ident(): parent_stream}
|
||||
|
||||
def __getattr__(self, name):
|
||||
thread_id = thread_get_ident()
|
||||
thread_id = threading.get_ident()
|
||||
self._ensure_thread_buffer(thread_id)
|
||||
return getattr(self._buffers[thread_id], name)
|
||||
|
||||
def _ensure_thread_buffer(self, thread_id):
|
||||
if thread_id not in self._buffers:
|
||||
self._buffers[thread_id] = StringIO()
|
||||
self._buffers[thread_id] = io.StringIO()
|
||||
|
||||
def write(self, value):
|
||||
thread_id = thread_get_ident()
|
||||
thread_id = threading.get_ident()
|
||||
self._ensure_thread_buffer(thread_id)
|
||||
return self._buffers[thread_id].write(
|
||||
value.decode() if is_bytes(value) else value
|
||||
|
||||
@@ -18,6 +18,7 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from urllib.parse import quote
|
||||
|
||||
import click
|
||||
from tabulate import tabulate
|
||||
@@ -32,11 +33,6 @@ from platformio.proc import is_ci
|
||||
from platformio.project.config import ProjectConfig
|
||||
from platformio.project.helpers import get_project_dir, is_platformio_project
|
||||
|
||||
try:
|
||||
from urllib.parse import quote
|
||||
except ImportError:
|
||||
from urllib import quote
|
||||
|
||||
CTX_META_INPUT_DIRS_KEY = __name__ + ".input_dirs"
|
||||
CTX_META_PROJECT_ENVIRONMENTS_KEY = __name__ + ".project_environments"
|
||||
CTX_META_STORAGE_DIRS_KEY = __name__ + ".storage_dirs"
|
||||
|
||||
@@ -20,16 +20,14 @@ import sys
|
||||
|
||||
from platformio.exception import UserSideException
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
if sys.version_info >= (3, 7):
|
||||
from asyncio import create_task as aio_create_task
|
||||
from asyncio import get_running_loop as aio_get_running_loop
|
||||
else:
|
||||
from asyncio import ensure_future as aio_create_task
|
||||
from asyncio import get_event_loop as aio_get_running_loop
|
||||
if sys.version_info >= (3, 7):
|
||||
from asyncio import create_task as aio_create_task
|
||||
from asyncio import get_running_loop as aio_get_running_loop
|
||||
else:
|
||||
from asyncio import ensure_future as aio_create_task
|
||||
from asyncio import get_event_loop as aio_get_running_loop
|
||||
|
||||
|
||||
PY2 = sys.version_info[0] == 2
|
||||
IS_CYGWIN = sys.platform.startswith("cygwin")
|
||||
IS_WINDOWS = WINDOWS = sys.platform.startswith("win")
|
||||
IS_MACOS = sys.platform.startswith("darwin")
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import time
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import click
|
||||
|
||||
@@ -22,11 +23,6 @@ from platformio.package.exception import UnknownPackageError
|
||||
from platformio.package.meta import PackageSpec
|
||||
from platformio.package.version import cast_version_to_semver
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
class RegistryFileMirrorIterator(object):
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import json
|
||||
import os
|
||||
import re
|
||||
import tarfile
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from platformio import util
|
||||
from platformio.clients.http import fetch_remote_content
|
||||
@@ -25,11 +26,6 @@ from platformio.compat import get_object_members, string_types
|
||||
from platformio.package.exception import ManifestParserError, UnknownManifestError
|
||||
from platformio.project.helpers import is_platformio_project
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
class ManifestFileType(object):
|
||||
PLATFORM_JSON = "platform.json"
|
||||
|
||||
@@ -26,37 +26,21 @@ from platformio.clients.http import fetch_remote_content
|
||||
from platformio.package.exception import ManifestValidationError
|
||||
from platformio.util import memoized
|
||||
|
||||
MARSHMALLOW_2 = marshmallow.__version_info__ < (3,)
|
||||
|
||||
class BaseSchema(Schema):
|
||||
class Meta(object): # pylint: disable=no-init
|
||||
unknown = marshmallow.EXCLUDE # pylint: disable=no-member
|
||||
|
||||
if MARSHMALLOW_2:
|
||||
|
||||
class CompatSchema(Schema):
|
||||
pass
|
||||
|
||||
else:
|
||||
|
||||
class CompatSchema(Schema):
|
||||
class Meta(object): # pylint: disable=no-init
|
||||
unknown = marshmallow.EXCLUDE # pylint: disable=no-member
|
||||
|
||||
def handle_error(self, error, data, **_): # pylint: disable=arguments-differ
|
||||
raise ManifestValidationError(
|
||||
error.messages,
|
||||
data,
|
||||
error.valid_data if hasattr(error, "valid_data") else error.data,
|
||||
)
|
||||
|
||||
|
||||
class BaseSchema(CompatSchema):
|
||||
def load_manifest(self, data):
|
||||
if MARSHMALLOW_2:
|
||||
data, errors = self.load(data)
|
||||
if errors:
|
||||
raise ManifestValidationError(errors, data, data)
|
||||
return data
|
||||
return self.load(data)
|
||||
|
||||
def handle_error(self, error, data, **_): # pylint: disable=arguments-differ
|
||||
raise ManifestValidationError(
|
||||
error.messages,
|
||||
data,
|
||||
error.valid_data if hasattr(error, "valid_data") else error.data,
|
||||
)
|
||||
|
||||
|
||||
class StrictSchema(BaseSchema):
|
||||
def handle_error(self, error, data, **_): # pylint: disable=arguments-differ
|
||||
@@ -67,8 +51,6 @@ class StrictSchema(BaseSchema):
|
||||
]
|
||||
else:
|
||||
error.valid_data = None
|
||||
if MARSHMALLOW_2:
|
||||
error.data = error.valid_data
|
||||
raise error
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from platformio import proc
|
||||
from platformio.package.exception import (
|
||||
@@ -24,11 +25,6 @@ from platformio.package.exception import (
|
||||
UserSideException,
|
||||
)
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
class VCSBaseException(PackageException):
|
||||
pass
|
||||
|
||||
@@ -16,6 +16,7 @@ import base64
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from urllib.parse import quote
|
||||
|
||||
import click
|
||||
|
||||
@@ -24,11 +25,6 @@ from platformio.compat import hashlib_encode_data, is_bytes
|
||||
from platformio.package.manager.core import get_core_package_dir
|
||||
from platformio.platform.exception import BuildScriptNotFound
|
||||
|
||||
try:
|
||||
from urllib.parse import quote
|
||||
except ImportError:
|
||||
from urllib import quote
|
||||
|
||||
|
||||
class PlatformRunMixin(object):
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import configparser
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
@@ -24,11 +25,6 @@ from platformio.compat import string_types
|
||||
from platformio.project import exception
|
||||
from platformio.project.options import ProjectOptions
|
||||
|
||||
try:
|
||||
import ConfigParser as ConfigParser
|
||||
except ImportError:
|
||||
import configparser as ConfigParser
|
||||
|
||||
CONFIG_HEADER = """
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
@@ -87,7 +83,7 @@ class ProjectConfigBase(object):
|
||||
self.expand_interpolations = expand_interpolations
|
||||
self.warnings = []
|
||||
self._parsed = []
|
||||
self._parser = ConfigParser.ConfigParser(inline_comment_prefixes=("#", ";"))
|
||||
self._parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";"))
|
||||
if path and os.path.isfile(path):
|
||||
self.read(path, parse_extra)
|
||||
|
||||
@@ -102,7 +98,7 @@ class ProjectConfigBase(object):
|
||||
self._parsed.append(path)
|
||||
try:
|
||||
self._parser.read(path, "utf-8")
|
||||
except ConfigParser.Error as e:
|
||||
except configparser.Error as e:
|
||||
raise exception.InvalidProjectConfError(path, str(e))
|
||||
|
||||
if not parse_extra:
|
||||
@@ -310,7 +306,7 @@ class ProjectConfigBase(object):
|
||||
value = None
|
||||
try:
|
||||
value = self.getraw(section, option, default)
|
||||
except ConfigParser.Error as e:
|
||||
except configparser.Error as e:
|
||||
raise exception.InvalidProjectConfError(self.path, str(e))
|
||||
|
||||
option_meta = ProjectOptions.get("%s.%s" % (section.split(":", 1)[0], option))
|
||||
@@ -398,7 +394,7 @@ class ProjectConfig(ProjectConfigBase, ProjectConfigDirsMixin):
|
||||
def update(self, data, clear=False):
|
||||
assert isinstance(data, list)
|
||||
if clear:
|
||||
self._parser = ConfigParser.ConfigParser()
|
||||
self._parser = configparser.ConfigParser()
|
||||
for section, options in data:
|
||||
if not self._parser.has_section(section):
|
||||
self._parser.add_section(section)
|
||||
|
||||
@@ -16,6 +16,7 @@ import atexit
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import queue
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
@@ -32,11 +33,6 @@ from platformio.compat import hashlib_encode_data, string_types
|
||||
from platformio.proc import is_ci, is_container
|
||||
from platformio.project.helpers import is_platformio_project
|
||||
|
||||
try:
|
||||
import queue
|
||||
except ImportError:
|
||||
import Queue as queue
|
||||
|
||||
|
||||
class TelemetryBase(object):
|
||||
def __init__(self):
|
||||
|
||||
Reference in new issue
Block a user