From 172ef2a17de19e7b9077623e102e8128cf16f004 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 21 Oct 2018 21:33:40 +0200 Subject: [PATCH] Lint --- esphomeyaml/components/binary_sensor/__init__.py | 2 +- esphomeyaml/espota2.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/esphomeyaml/components/binary_sensor/__init__.py b/esphomeyaml/components/binary_sensor/__init__.py index 8c5dc52b2e..82da0a9ce9 100644 --- a/esphomeyaml/components/binary_sensor/__init__.py +++ b/esphomeyaml/components/binary_sensor/__init__.py @@ -6,7 +6,7 @@ from esphomeyaml import automation from esphomeyaml.const import CONF_DEVICE_CLASS, CONF_ID, CONF_INTERNAL, CONF_INVERTED, \ CONF_MAX_LENGTH, CONF_MIN_LENGTH, CONF_MQTT_ID, CONF_ON_CLICK, CONF_ON_DOUBLE_CLICK, \ CONF_ON_PRESS, CONF_ON_RELEASE, CONF_TRIGGER_ID, CONF_FILTERS, CONF_INVERT, CONF_DELAYED_ON, \ - CONF_DELAYED_OFF, CONF_LAMBDA, CONF_HEARTBEAT, CONF_NAME + CONF_DELAYED_OFF, CONF_LAMBDA, CONF_HEARTBEAT from esphomeyaml.helpers import App, NoArg, Pvariable, add, add_job, esphomelib_ns, \ setup_mqtt_component, bool_, process_lambda, ArrayInitializer diff --git a/esphomeyaml/espota2.py b/esphomeyaml/espota2.py index f9b7b21190..a2733c85c7 100755 --- a/esphomeyaml/espota2.py +++ b/esphomeyaml/espota2.py @@ -27,17 +27,24 @@ OTA_VERSION_1_0 = 1 MAGIC_BYTES = [0x6C, 0x26, 0xF7, 0x5C, 0x45] _LOGGER = logging.getLogger(__name__) +LAST_PROGRESS = -1 def update_progress(progress): + global LAST_PROGRESS + bar_length = 60 status = "" if progress >= 1: progress = 1 status = "Done...\r\n" + new_progress = int(progress * 100) + if new_progress == LAST_PROGRESS: + return + LAST_PROGRESS = new_progress block = int(round(bar_length * progress)) text = "\rUploading: [{0}] {1}% {2}".format("=" * block + " " * (bar_length - block), - int(progress * 100), status) + new_progress, status) sys.stderr.write(text) sys.stderr.flush()