esphome: 1.10.1 -> 1.11.1

This commit is contained in:
Robert Schütz 2019-01-18 16:13:58 +01:00
parent 6c5786a1e8
commit 1011da3807
2 changed files with 15 additions and 136 deletions

View File

@ -1,119 +0,0 @@
diff --git a/esphomeyaml/__main__.py b/esphomeyaml/__main__.py
index 26f42c1..529d2e0 100644
--- a/esphomeyaml/__main__.py
+++ b/esphomeyaml/__main__.py
@@ -167,13 +167,10 @@ def compile_program(args, config):
def upload_using_esptool(config, port):
- import esptool
-
path = os.path.join(CORE.build_path, '.pioenvs', CORE.name, 'firmware.bin')
- cmd = ['esptool.py', '--before', 'default_reset', '--after', 'hard_reset',
+ cmd = ['@esptool@/bin/esptool.py', '--before', 'default_reset', '--after', 'hard_reset',
'--chip', 'esp8266', '--port', port, 'write_flash', '0x0', path]
- # pylint: disable=protected-access
- return run_external_command(esptool._main, *cmd)
+ return run_external_command(*cmd)
def upload_program(config, args, host):
diff --git a/esphomeyaml/platformio_api.py b/esphomeyaml/platformio_api.py
index df29491..f991701 100644
--- a/esphomeyaml/platformio_api.py
+++ b/esphomeyaml/platformio_api.py
@@ -13,12 +13,9 @@ _LOGGER = logging.getLogger(__name__)
def run_platformio_cli(*args, **kwargs):
- import platformio.__main__
-
os.environ["PLATFORMIO_FORCE_COLOR"] = "true"
- cmd = ['platformio'] + list(args)
- return run_external_command(platformio.__main__.main,
- *cmd, **kwargs)
+ cmd = ['@platformio@/bin/platformio'] + list(args)
+ return run_external_command(*cmd, **kwargs)
def run_platformio_cli_run(config, verbose, *args, **kwargs):
diff --git a/esphomeyaml/util.py b/esphomeyaml/util.py
index eebb4b7..9e9e58f 100644
--- a/esphomeyaml/util.py
+++ b/esphomeyaml/util.py
@@ -4,6 +4,7 @@ import io
import logging
import re
import sys
+import subprocess
_LOGGER = logging.getLogger(__name__)
@@ -79,42 +80,25 @@ class RedirectText(object):
return True
-def run_external_command(func, *cmd, **kwargs):
- def mock_exit(return_code):
- raise SystemExit(return_code)
-
- orig_argv = sys.argv
- orig_exit = sys.exit # mock sys.exit
+def run_external_command(*cmd, **kwargs):
full_cmd = u' '.join(shlex_quote(x) for x in cmd)
_LOGGER.info(u"Running: %s", full_cmd)
- orig_stdout = sys.stdout
- sys.stdout = RedirectText(sys.stdout)
- orig_stderr = sys.stderr
- sys.stderr = RedirectText(sys.stderr)
-
capture_stdout = kwargs.get('capture_stdout', False)
if capture_stdout:
- cap_stdout = sys.stdout = io.BytesIO()
+ cap_stdout = io.BytesIO()
+ else:
+ cap_stdout = sys.stdout
try:
- sys.argv = list(cmd)
- sys.exit = mock_exit
- return func() or 0
- except KeyboardInterrupt:
- return 1
- except SystemExit as err:
- return err.args[0]
+ completed_process = subprocess.run(cmd,
+ stdout=RedirectText(cap_stdout),
+ stderr=RedirectText(sys.stderr))
+ return completed_process.returncode
except Exception as err: # pylint: disable=broad-except
_LOGGER.error(u"Running command failed: %s", err)
_LOGGER.error(u"Please try running %s locally.", full_cmd)
finally:
- sys.argv = orig_argv
- sys.exit = orig_exit
-
- sys.stdout = orig_stdout
- sys.stderr = orig_stderr
-
if capture_stdout:
# pylint: disable=lost-exception
return cap_stdout.getvalue()
diff --git a/setup.py b/setup.py
index 78a5378..8ce80de 100755
--- a/setup.py
+++ b/setup.py
@@ -23,12 +23,10 @@ DOWNLOAD_URL = '{}/archive/{}.zip'.format(GITHUB_URL, const.__version__)
REQUIRES = [
'voluptuous>=0.11.1',
- 'platformio>=3.5.3',
'pyyaml>=3.12',
'paho-mqtt>=1.3.1',
'colorlog>=3.1.2',
'tornado>=5.0.0',
- 'esptool>=2.3.1',
'typing>=3.0.0',
'protobuf>=3.4',
'tzlocal>=1.4',

View File

@ -1,29 +1,27 @@
{ lib, python3, fetchpatch, substituteAll, platformio, esptool }:
{ lib, python3, fetchpatch, platformio, esptool, git }:
python3.pkgs.buildPythonApplication rec {
pname = "esphomeyaml";
version = "1.10.1";
pname = "esphome";
version = "1.11.1";
src = python3.pkgs.fetchPypi {
inherit pname version;
sha256 = "426cd545b4e9505ce5b4f5c63d2d54cb038f93fe3ba9d4d56b6b6431b222485d";
sha256 = "1764q4wyl8qlk2514gikv8178c8fwhhvbw64zkd76nb107hxzrk5";
};
patches = [
(substituteAll {
src = ./dont-import-platformio-esptool.patch;
inherit platformio esptool;
})
];
postPatch = ''
# typing is part of the standard library since Python 3.5
substituteInPlace setup.py --replace "'typing>=3.0.0'," ""
'';
ESPHOME_USE_SUBPROCESS = "";
propagatedBuildInputs = with python3.pkgs; [
voluptuous pyyaml paho-mqtt colorlog
tornado protobuf tzlocal pyserial
tornado protobuf tzlocal pyserial ifaddr
];
makeWrapperArgs = [
# platformio is used in esphomeyaml/platformio_api.py
# esptool is used in esphomeyaml/__main__.py
# git is used in esphomeyaml/writer.py
"--prefix PATH : ${lib.makeBinPath [ platformio esptool git ]}"
"--set ESPHOME_USE_SUBPROCESS ''"
];
checkPhase = ''
@ -36,7 +34,7 @@ python3.pkgs.buildPythonApplication rec {
meta = with lib; {
description = "Make creating custom firmwares for ESP32/ESP8266 super easy";
homepage = https://esphomelib.com/esphomeyaml;
homepage = https://esphome.io/;
license = licenses.mit;
maintainers = with maintainers; [ dotlambda ];
};