mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 09:25:09 +08:00
Fix dashboard upload port selection
This commit is contained in:
@@ -102,11 +102,14 @@ class SerialPortRequestHandler(tornado.web.RequestHandler):
|
|||||||
data = []
|
data = []
|
||||||
for port, desc in ports:
|
for port, desc in ports:
|
||||||
if port == '/dev/ttyAMA0':
|
if port == '/dev/ttyAMA0':
|
||||||
# ignore RPi built-in serial port
|
desc = 'UART pins on GPIO header'
|
||||||
continue
|
split_desc = desc.split(' - ')
|
||||||
|
if len(split_desc) == 2 and split_desc[0] == split_desc[1]:
|
||||||
|
# Some serial ports repeat their values
|
||||||
|
desc = split_desc[0]
|
||||||
data.append({'port': port, 'desc': desc})
|
data.append({'port': port, 'desc': desc})
|
||||||
data.append({'port': 'OTA', 'desc': 'Over-The-Air Upload/Logs'})
|
data.append({'port': 'OTA', 'desc': 'Over-The-Air'})
|
||||||
self.write(json.dumps(data))
|
self.write(json.dumps(sorted(data, reverse=True)))
|
||||||
|
|
||||||
|
|
||||||
class WizardRequestHandler(tornado.web.RequestHandler):
|
class WizardRequestHandler(tornado.web.RequestHandler):
|
||||||
@@ -119,7 +122,7 @@ class WizardRequestHandler(tornado.web.RequestHandler):
|
|||||||
with codecs.open(destination, 'w') as f_handle:
|
with codecs.open(destination, 'w') as f_handle:
|
||||||
f_handle.write(config)
|
f_handle.write(config)
|
||||||
|
|
||||||
self.redirect('/')
|
self.redirect('/?begin=True')
|
||||||
|
|
||||||
|
|
||||||
class DownloadBinaryRequestHandler(tornado.web.RequestHandler):
|
class DownloadBinaryRequestHandler(tornado.web.RequestHandler):
|
||||||
@@ -143,14 +146,15 @@ class DownloadBinaryRequestHandler(tornado.web.RequestHandler):
|
|||||||
|
|
||||||
class MainRequestHandler(tornado.web.RequestHandler):
|
class MainRequestHandler(tornado.web.RequestHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
|
begin = bool(self.get_argument('begin', False))
|
||||||
files = sorted([f for f in os.listdir(CONFIG_DIR) if f.endswith('.yaml') and
|
files = sorted([f for f in os.listdir(CONFIG_DIR) if f.endswith('.yaml') and
|
||||||
not f.startswith('.')])
|
not f.startswith('.')])
|
||||||
full_path_files = [os.path.join(CONFIG_DIR, f) for f in files]
|
full_path_files = [os.path.join(CONFIG_DIR, f) for f in files]
|
||||||
self.render("templates/index.html", files=files, full_path_files=full_path_files,
|
self.render("templates/index.html", files=files, full_path_files=full_path_files,
|
||||||
version=const.__version__)
|
version=const.__version__, begin=begin)
|
||||||
|
|
||||||
|
|
||||||
def make_app():
|
def make_app(debug=False):
|
||||||
static_path = os.path.join(os.path.dirname(__file__), 'static')
|
static_path = os.path.join(os.path.dirname(__file__), 'static')
|
||||||
return tornado.web.Application([
|
return tornado.web.Application([
|
||||||
(r"/", MainRequestHandler),
|
(r"/", MainRequestHandler),
|
||||||
@@ -161,7 +165,7 @@ def make_app():
|
|||||||
(r"/serial-ports", SerialPortRequestHandler),
|
(r"/serial-ports", SerialPortRequestHandler),
|
||||||
(r"/wizard.html", WizardRequestHandler),
|
(r"/wizard.html", WizardRequestHandler),
|
||||||
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_path}),
|
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_path}),
|
||||||
], debug=False)
|
], debug=debug)
|
||||||
|
|
||||||
|
|
||||||
def start_web_server(args):
|
def start_web_server(args):
|
||||||
@@ -177,7 +181,7 @@ def start_web_server(args):
|
|||||||
|
|
||||||
_LOGGER.info("Starting dashboard web server on port %s and configuration dir %s...",
|
_LOGGER.info("Starting dashboard web server on port %s and configuration dir %s...",
|
||||||
args.port, CONFIG_DIR)
|
args.port, CONFIG_DIR)
|
||||||
app = make_app()
|
app = make_app(args.verbose)
|
||||||
app.listen(args.port)
|
app.listen(args.port)
|
||||||
try:
|
try:
|
||||||
tornado.ioloop.IOLoop.current().start()
|
tornado.ioloop.IOLoop.current().start()
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -450,10 +450,12 @@ def flush_tasks():
|
|||||||
raise ESPHomeYAMLError("Circular dependency detected!")
|
raise ESPHomeYAMLError("Circular dependency detected!")
|
||||||
|
|
||||||
task, domain = _TASKS.popleft()
|
task, domain = _TASKS.popleft()
|
||||||
|
_LOGGER.debug("Executing task for domain=%s", domain)
|
||||||
try:
|
try:
|
||||||
task.next()
|
task.next()
|
||||||
_TASKS.append((task, domain))
|
_TASKS.append((task, domain))
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
|
_LOGGER.debug(" -> %s finished", domain)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -461,6 +463,7 @@ def add(expression, require=True):
|
|||||||
if require and isinstance(expression, Expression):
|
if require and isinstance(expression, Expression):
|
||||||
expression.require()
|
expression.require()
|
||||||
_EXPRESSIONS.append(expression)
|
_EXPRESSIONS.append(expression)
|
||||||
|
_LOGGER.debug("Adding: %s", statement(expression))
|
||||||
return expression
|
return expression
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user