1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 15:18:16 +00:00

Remove sleeps.

- the sleeps is not needed.
This commit is contained in:
Jimmy Hedman 2018-04-11 18:16:47 +02:00
parent 9e5548324b
commit b25b908aa9

View File

@ -3,7 +3,6 @@ from __future__ import print_function
import codecs import codecs
import os import os
import unicodedata import unicodedata
from time import sleep
import voluptuous as vol import voluptuous as vol
@ -77,7 +76,6 @@ def print_step(step, big):
print("============= STEP {} =============".format(step)) print("============= STEP {} =============".format(step))
print(big) print(big)
print("===================================") print("===================================")
sleep(0.25)
def default_input(text, default): def default_input(text, default):
@ -102,23 +100,17 @@ def wizard(path):
"or chose another configuration file.".format(color('cyan', path))) "or chose another configuration file.".format(color('cyan', path)))
return 1 return 1
print("Hi there!") print("Hi there!")
sleep(1.5)
print("I'm the wizard of esphomeyaml :)") print("I'm the wizard of esphomeyaml :)")
sleep(1.25)
print("And I'm here to help you get started with esphomeyaml.") print("And I'm here to help you get started with esphomeyaml.")
sleep(2.0)
print("In 5 steps I'm going to guide you through creating a basic " print("In 5 steps I'm going to guide you through creating a basic "
"configuration file for your custom ESP8266/ESP32 firmware. Yay!") "configuration file for your custom ESP8266/ESP32 firmware. Yay!")
sleep(3.0)
print() print()
print_step(1, CORE_BIG) print_step(1, CORE_BIG)
print("First up, please choose a " + color('green', 'name') + " for your node.") print("First up, please choose a " + color('green', 'name') + " for your node.")
print("It should be a unique name that can be used to identify the device later.") print("It should be a unique name that can be used to identify the device later.")
sleep(1)
print("For example, I like calling the node in my living room {}.".format( print("For example, I like calling the node in my living room {}.".format(
color('bold_white', "livingroom"))) color('bold_white', "livingroom")))
print() print()
sleep(1)
name = raw_input(color("bold_white", "(name): ")) name = raw_input(color("bold_white", "(name): "))
while True: while True:
try: try:
@ -130,18 +122,15 @@ def wizard(path):
name = strip_accents(name).replace(' ', '_') name = strip_accents(name).replace(' ', '_')
name = u''.join(c for c in name if c in cv.ALLOWED_NAME_CHARS) name = u''.join(c for c in name if c in cv.ALLOWED_NAME_CHARS)
print("Shall I use \"{}\" as the name instead?".format(color('cyan', name))) print("Shall I use \"{}\" as the name instead?".format(color('cyan', name)))
sleep(0.5)
name = default_input("(name [{}]): ", name) name = default_input("(name [{}]): ", name)
print("Great! Your node is now called \"{}\".".format(color('cyan', name))) print("Great! Your node is now called \"{}\".".format(color('cyan', name)))
sleep(1)
print_step(2, ESP_BIG) print_step(2, ESP_BIG)
print("Now I'd like to know which *board* you're using so that I can compile " print("Now I'd like to know which *board* you're using so that I can compile "
"firmwares for it.") "firmwares for it.")
print("Are you using an " + color('green', 'ESP32') + " or " + print("Are you using an " + color('green', 'ESP32') + " or " +
color('green', 'ESP8266') + " based board?") color('green', 'ESP8266') + " based board?")
while True: while True:
sleep(0.5)
print() print()
print("Please enter either ESP32 or ESP8266.") print("Please enter either ESP32 or ESP8266.")
platform = raw_input(color("bold_white", "(ESP32/ESP8266): ")) platform = raw_input(color("bold_white", "(ESP32/ESP8266): "))
@ -153,7 +142,6 @@ def wizard(path):
"\"{}\". Please try again.".format(platform)) "\"{}\". Please try again.".format(platform))
print("Thanks! You've chosen {} as your platform.".format(color('cyan', platform))) print("Thanks! You've chosen {} as your platform.".format(color('cyan', platform)))
print() print()
sleep(1)
if platform == ESP_PLATFORM_ESP32: if platform == ESP_PLATFORM_ESP32:
board_link = 'http://docs.platformio.org/en/latest/platforms/espressif32.html#boards' board_link = 'http://docs.platformio.org/en/latest/platforms/espressif32.html#boards'
@ -161,7 +149,6 @@ def wizard(path):
board_link = 'http://docs.platformio.org/en/latest/platforms/espressif8266.html#boards' board_link = 'http://docs.platformio.org/en/latest/platforms/espressif8266.html#boards'
print("Next, I need to know what " + color('green', 'board') + " you're using.") print("Next, I need to know what " + color('green', 'board') + " you're using.")
sleep(0.5)
print("Please go to {} and choose a board.".format(color('green', board_link))) print("Please go to {} and choose a board.".format(color('green', board_link)))
print() print()
# Don't sleep because user needs to copy link # Don't sleep because user needs to copy link
@ -178,22 +165,18 @@ def wizard(path):
except vol.Invalid: except vol.Invalid:
print(color('red', "Sorry, I don't think the board \"{}\" exists.")) print(color('red', "Sorry, I don't think the board \"{}\" exists."))
print() print()
sleep(0.25)
print("Possible options are {}".format(', '.join(boards))) print("Possible options are {}".format(', '.join(boards)))
print() print()
print("Way to go! You've chosen {} as your board.".format(color('cyan', board))) print("Way to go! You've chosen {} as your board.".format(color('cyan', board)))
print() print()
sleep(1)
print_step(3, WIFI_BIG) print_step(3, WIFI_BIG)
print("In this step, I'm going to create the configuration for " print("In this step, I'm going to create the configuration for "
"WiFi.") "WiFi.")
print() print()
sleep(1)
print("First, what's the " + color('green', 'SSID') + " (the name) of the WiFi network {} " print("First, what's the " + color('green', 'SSID') + " (the name) of the WiFi network {} "
"I should connect to?".format(name)) "I should connect to?".format(name))
sleep(1.5)
print("For example \"{}\".".format(color('bold_white', "Abraham Linksys"))) print("For example \"{}\".".format(color('bold_white', "Abraham Linksys")))
while True: while True:
ssid = raw_input(color('bold_white', "(ssid): ")) ssid = raw_input(color('bold_white', "(ssid): "))
@ -204,26 +187,21 @@ def wizard(path):
print(color('red', "Unfortunately, \"{}\" doesn't seem to be a valid SSID. " print(color('red', "Unfortunately, \"{}\" doesn't seem to be a valid SSID. "
"Please try again.".format(ssid))) "Please try again.".format(ssid)))
print() print()
sleep(1)
print("Thank you very much! You've just chosen \"{}\" as your SSID.".format( print("Thank you very much! You've just chosen \"{}\" as your SSID.".format(
color('cyan', ssid))) color('cyan', ssid)))
print() print()
sleep(0.75)
print("Now please state the " + color('green', 'password') + print("Now please state the " + color('green', 'password') +
" of the WiFi network so that I can connect to it.") " of the WiFi network so that I can connect to it.")
print() print()
print("For example \"{}\"".format(color('bold_white', 'PASSWORD42'))) print("For example \"{}\"".format(color('bold_white', 'PASSWORD42')))
sleep(0.5)
psk = raw_input(color('bold_white', '(PSK): ')) psk = raw_input(color('bold_white', '(PSK): '))
print("Perfect! WiFi is now set up (you can create static IPs and so on later).") print("Perfect! WiFi is now set up (you can create static IPs and so on later).")
sleep(1.5)
print_step(4, MQTT_BIG) print_step(4, MQTT_BIG)
print("Almost there! Now let's setup MQTT so that your node can connect to the outside world.") print("Almost there! Now let's setup MQTT so that your node can connect to the outside world.")
print() print()
sleep(1)
print("Please enter the " + color('green', 'address') + " of your MQTT broker.") print("Please enter the " + color('green', 'address') + " of your MQTT broker.")
print() print()
print("For example \"{}\".".format(color('bold_white', '192.168.178.84'))) print("For example \"{}\".".format(color('bold_white', '192.168.178.84')))
@ -237,7 +215,6 @@ def wizard(path):
broker, err))) broker, err)))
print("Please try again.") print("Please try again.")
print() print()
sleep(1)
print("Thanks! Now enter the " + color('green', 'username') + " and " + print("Thanks! Now enter the " + color('green', 'username') + " and " +
color('green', 'password') + " for the MQTT broker. Leave empty for no authentication.") color('green', 'password') + " for the MQTT broker. Leave empty for no authentication.")
@ -260,7 +237,6 @@ def wizard(path):
print("This can be insecure if you do not trust the WiFi network. Do you want to set " print("This can be insecure if you do not trust the WiFi network. Do you want to set "
"an " + color('green', 'OTA password') + " for remote updates?") "an " + color('green', 'OTA password') + " for remote updates?")
print() print()
sleep(0.25)
print("Press ENTER for no password") print("Press ENTER for no password")
ota_password = raw_input(color('bold_white', '(password): ')) ota_password = raw_input(color('bold_white', '(password): '))