1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-14 14:48:18 +00:00
This commit is contained in:
Otto Winter 2018-10-21 21:33:40 +02:00
parent 8a1f85b180
commit 172ef2a17d
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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()