From 7cc2d1b869f04f6a3837f1201314d6bdbbe8e67b Mon Sep 17 00:00:00 2001 From: Daniel Perna Date: Wed, 15 Nov 2017 22:22:13 +0100 Subject: [PATCH 1/8] Added IPv6 support --- README.md | 2 +- changelog.txt | 7 +++++-- configurator.py | 12 +++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d9b22a8..5b73f1f 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Near the top of the py-file you'll find some global variables you can change to To keep your setting across updates it is also possible to save settings in an external file. In that case copy [settings.conf](https://github.com/danielperna84/hass-poc-configurator/blob/master/settings.conf) whereever you like and append the full path to the file to the command when starting the configurator. E.g. `sudo .configurator.py /home/hass/.homeassistant/mysettings.conf`. This file is in JSON format. So make sure it has a valid syntax (you can set the editor to JSON to get syntax highlighting for the settings). The major difference to the settings in the py-file is, that `None` becomes `null`. #### LISTENIP (string) -The IP the service is listening on. By default it's binding to `0.0.0.0`, which is every interface on the system. +The IP address the service is listening on. By default it is binding to `0.0.0.0`, which is every IPv4 interface on the system. When using `::`, all available IPv6- and IPv4-addresses will be used. #### LISTENPORT (integer) The port the service is listening on. By default it's using 3218, but you can change this if you need to. #### BASEPATH (string) diff --git a/changelog.txt b/changelog.txt index d0d83b2..f297a81 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,9 @@ +Version 0.2.4 (2017-11-nn) +- Added IPv6 support @danielperna84 + Version 0.2.3 (2017-11-12) -- Switched away from removed bootstrap API -- Added homeassistant-trigger +- Switched away from removed bootstrap API @danielperna84 +- Added homeassistant-trigger @danielperna84 Version 0.2.2 (2017-11-01) - Added option to list directories first @dimagoltsman diff --git a/configurator.py b/configurator.py index e1475e8..0add317 100755 --- a/configurator.py +++ b/configurator.py @@ -8,6 +8,7 @@ import os import sys import json import ssl +import socket import socketserver import base64 import ipaddress @@ -18,7 +19,7 @@ import subprocess import logging import fnmatch from string import Template -from http.server import BaseHTTPRequestHandler, HTTPServer +from http.server import BaseHTTPRequestHandler import urllib.request from urllib.parse import urlparse, parse_qs, unquote @@ -3633,16 +3634,17 @@ def main(args): if args: load_settings(args[0]) LOG.info("Starting server") + CustomServer = socketserver.TCPServer + if ':' in LISTENIP: + CustomServer.address_family = socket.AF_INET6 server_address = (LISTENIP, LISTENPORT) if CREDENTIALS: CREDENTIALS = base64.b64encode(bytes(CREDENTIALS, "utf-8")) Handler = AuthHandler else: Handler = RequestHandler - if not SSL_CERTIFICATE: - HTTPD = HTTPServer(server_address, Handler) - else: - HTTPD = socketserver.TCPServer(server_address, Handler) + HTTPD = CustomServer(server_address, Handler) + if SSL_CERTIFICATE: HTTPD.socket = ssl.wrap_socket(HTTPD.socket, certfile=SSL_CERTIFICATE, keyfile=SSL_KEY, From d1ec00f76894033de02d42f1fa53d1bd4312b536 Mon Sep 17 00:00:00 2001 From: Atoxhybrid Date: Mon, 11 Dec 2017 20:37:45 +0100 Subject: [PATCH 2/8] YAML linter proof of concept --- configurator.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/configurator.py b/configurator.py index 0add317..fae14b2 100755 --- a/configurator.py +++ b/configurator.py @@ -521,6 +521,11 @@ INDEX = Template(r""" 100% { background-color: #f5f5f5; } } + #lint-status { + position: absolute; + top: 0.75rem; + right: 10px; + } @@ -1515,6 +1520,7 @@ INDEX = Template(r"""
+
@@ -2732,6 +2738,29 @@ INDEX = Template(r""" foldstatus = !foldstatus; } + + + """) From d72a554bb65fc526ea6193363d0f46bb32bf25d0 Mon Sep 17 00:00:00 2001 From: Atoxhybrid Date: Thu, 21 Dec 2017 14:27:14 +0100 Subject: [PATCH 3/8] Added a timeout to the linter --- configurator.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/configurator.py b/configurator.py index fae14b2..ccdcc98 100755 --- a/configurator.py +++ b/configurator.py @@ -2741,18 +2741,20 @@ INDEX = Template(r""" """) From a6b986964cd5c4f717b9a249a6e9adce033825d2 Mon Sep 17 00:00:00 2001 From: Atoxhybrid Date: Thu, 21 Dec 2017 14:43:52 +0100 Subject: [PATCH 4/8] The document will lint on the first load --- configurator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configurator.py b/configurator.py index ccdcc98..c491e3f 100755 --- a/configurator.py +++ b/configurator.py @@ -2294,6 +2294,7 @@ INDEX = Template(r""" editor.session.getUndoManager().markClean(); $('.markdirty').each(function(i, o){o.classList.remove('red');}); $('.hidesave').css('opacity', 0); + check_lint(); }); } } @@ -2776,7 +2777,7 @@ function queue_lint(e) } } -editor.getSession().on('change', queue_lint); +editor.on('change', queue_lint); """) From ac3d000e02c9e1b2cb09b8c9adc023cca6870be2 Mon Sep 17 00:00:00 2001 From: Atoxhybrid Date: Thu, 21 Dec 2017 15:33:45 +0100 Subject: [PATCH 5/8] Speed optimizations --- configurator.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/configurator.py b/configurator.py index c491e3f..b14d528 100755 --- a/configurator.py +++ b/configurator.py @@ -526,6 +526,10 @@ INDEX = Template(r""" top: 0.75rem; right: 10px; } + + .cursor-pointer { + cursor: pointer; + } @@ -2743,37 +2747,40 @@ INDEX = Template(r""" @@ -1477,6 +1486,14 @@ INDEX = Template(r""" OK +
@@ -1524,7 +1541,7 @@ INDEX = Template(r"""
- +
@@ -2748,6 +2765,7 @@ INDEX = Template(r""" From bb3c188b4474e91859770373fa903d03e8df9ed7 Mon Sep 17 00:00:00 2001 From: Atoxhybrid Date: Tue, 2 Jan 2018 13:51:11 +0100 Subject: [PATCH 7/8] Removed debug code --- configurator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/configurator.py b/configurator.py index 19ebebc..6273647 100755 --- a/configurator.py +++ b/configurator.py @@ -2781,7 +2781,6 @@ function check_lint() lint_status.text("error"); lint_status.removeClass("green-text grey-text"); lint_status.addClass("cursor-pointer red-text"); - console.log(err); lint_error = err.message; } } else { From 34fbc4ff0bf6be9c3b15b8638bb2e9fc3b0e7d39 Mon Sep 17 00:00:00 2001 From: Daniel Perna Date: Tue, 2 Jan 2018 20:49:47 +0100 Subject: [PATCH 8/8] Added Linting, IPv6 --- changelog.txt | 3 +- configurator.py | 2 +- dev.html | 82 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/changelog.txt b/changelog.txt index f297a81..1622740 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,5 @@ -Version 0.2.4 (2017-11-nn) +Version 0.2.4 (2018-01-02) +- Added YAML linting @AtoxIO - Added IPv6 support @danielperna84 Version 0.2.3 (2017-11-12) diff --git a/configurator.py b/configurator.py index 6273647..260198d 100755 --- a/configurator.py +++ b/configurator.py @@ -66,7 +66,7 @@ SO.setLevel(LOGLEVEL) SO.setFormatter(logging.Formatter('%(levelname)s:%(asctime)s:%(name)s:%(message)s')) LOG.addHandler(SO) RELEASEURL = "https://api.github.com/repos/danielperna84/hass-configurator/releases/latest" -VERSION = "0.2.3" +VERSION = "0.2.4" BASEDIR = "." DEV = False HTTPD = None diff --git a/dev.html b/dev.html index 71a67bc..34f3b61 100644 --- a/dev.html +++ b/dev.html @@ -442,6 +442,24 @@ 100% { background-color: #f5f5f5; } } + #lint-status { + position: absolute; + top: 0.75rem; + right: 10px; + } + + .cursor-pointer { + cursor: pointer; + } + + #modal_lint.modal { + width: 80%; + } + + #modal_lint textarea { + resize: none; + height: auto; + } @@ -1389,6 +1407,14 @@ OK
+
@@ -1436,6 +1462,7 @@
+
@@ -2209,6 +2236,7 @@ editor.session.getUndoManager().markClean(); $('.markdirty').each(function(i, o){o.classList.remove('red');}); $('.hidesave').css('opacity', 0); + check_lint(); }); } } @@ -2653,6 +2681,58 @@ foldstatus = !foldstatus; } + + + - + \ No newline at end of file