From 7a43231c430c9e480b5916be29d77c41509887a7 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 18 Oct 2019 20:21:16 +0530 Subject: [PATCH] Support for Python 3 (#702) * Support for Python 3 * Add later Python releases * Remove Python 3.6 * Re-enable Python 2.7 * Remove platformio-core zip archive * Re-enable Python 2.7 * Fixes for python 3 Co-Authored-By: C W --- .travis.yml | 12 +++++++++--- esphome/platformio_api.py | 2 ++ esphome/util.py | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a453ab52b2..c14859ba8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ sudo: false language: python -python: '2.7' +python: '3.5' install: script/setup cache: directories: @@ -9,8 +9,8 @@ cache: matrix: fast_finish: true include: - - python: "2.7" - env: TARGET=Lint2.7 + - python: "3.7" + env: TARGET=Lint3.7 script: - script/ci-custom.py - flake8 esphome @@ -21,6 +21,12 @@ matrix: - script/ci-custom.py - flake8 esphome - pylint esphome + - python: "3.5" + env: TARGET=Test3.5 + script: + - esphome tests/test1.yaml compile + - esphome tests/test2.yaml compile + - esphome tests/test3.yaml compile - python: "2.7" env: TARGET=Test2.7 script: diff --git a/esphome/platformio_api.py b/esphome/platformio_api.py index 1b79be2526..de3aa4cce9 100644 --- a/esphome/platformio_api.py +++ b/esphome/platformio_api.py @@ -7,6 +7,7 @@ import re import subprocess from esphome.core import CORE +from esphome.py_compat import text_type, decode_text from esphome.util import run_external_command, run_external_process _LOGGER = logging.getLogger(__name__) @@ -72,6 +73,7 @@ def run_upload(config, verbose, port): def run_idedata(config): args = ['-t', 'idedata'] stdout = run_platformio_cli_run(config, False, *args, capture_stdout=True) + stdout = decode_text(stdout) match = re.search(r'{.*}', stdout) if match is None: return IDEData(None) diff --git a/esphome/util.py b/esphome/util.py index f631e48a6b..1f5f79c2f2 100644 --- a/esphome/util.py +++ b/esphome/util.py @@ -9,7 +9,7 @@ import subprocess import sys from esphome import const -from esphome.py_compat import IS_PY2 +from esphome.py_compat import IS_PY2, IS_PY3 _LOGGER = logging.getLogger(__name__) @@ -127,7 +127,7 @@ def run_external_command(func, *cmd, **kwargs): capture_stdout = kwargs.get('capture_stdout', False) if capture_stdout: - cap_stdout = sys.stdout = io.BytesIO() + cap_stdout = sys.stdout = io.StringIO() try: sys.argv = list(cmd)