From 97012e3e3f2e7c7286805bad47f2ec7135fd5adb Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Mon, 19 Dec 2016 23:38:28 +0100 Subject: [PATCH 01/19] removed config.yml --- server/config.yml | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 server/config.yml diff --git a/server/config.yml b/server/config.yml deleted file mode 100644 index f22dd70..0000000 --- a/server/config.yml +++ /dev/null @@ -1,10 +0,0 @@ -sys_name: MyLED -log_level: INFO - -Strip: - driver: Dummy - num_leds: 488 - max_clock_speed_hz: 4000000 # [Hz] 4 MHz is the maximum for "large" strips of more than 500 LEDs. - initial_brightness: 50 # integer from 0 to 100 - max_brightness: 75 # maximum brightness - gamma: 2.8 # for gamma correction, put 1 to turn it off From 82a3c9916d415438aeddbaa81902876b0cbadb06 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Mon, 19 Dec 2016 23:39:59 +0100 Subject: [PATCH 02/19] updated .gitignore --- .gitignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d6209ad..0203b5a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,11 +5,11 @@ Thumbs.db .idea/ # any specific configuration -config.py +config.yml # setuptools server/dist *.egg-info -# tests -tests/ +# temporary stuff +playground/ From 5002133665da9ee506b2c2300927e397907d9f02 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 13:04:38 +0100 Subject: [PATCH 03/19] reformatted greeting --- server/server.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/server/server.py b/server/server.py index 17da522..af6f715 100644 --- a/server/server.py +++ b/server/server.py @@ -28,12 +28,17 @@ __version__ = '0.2pre-dev' -logo = """ +greeting = """ _______ ___ __ < / __ \__ \ _____/ /_ ____ _ _______ / / / / /_/ // ___/ __ \/ __ \ | /| / / ___/ / / /_/ / __/(__ ) / / / /_/ / |/ |/ (__ ) -/_/\____/____/____/_/ /_/\____/|__/|__/____/ v{}""" +/_/\____/____/____/_/ /_/\____/|__/|__/____/ version: {version} + +This is free software. You are welcome to redistribute +it under the conditions of the GNU Public License v2. +For details, see https://www.gnu.org/licenses/gpl-2.0.html +""" # configuration user_config = get_configuration() @@ -42,14 +47,8 @@ logger = logging.getLogger('102shows.server') coloredlogs.install(level=user_config.log_level) -# friendly greetings -print(logo.format(__version__)) -print() -print("This is free software. You are welcome to redistribute") -print("it under the conditions of the GNU Public License v2.") -print("For details, see https://www.gnu.org/licenses/gpl-2.0.html") -print() -print() +# friendly greeting +print(greeting.format(version=__version__), end='\n\n\n') # start the server! server = MQTTControl(user_config) # initialize the server... From 437adea1623c8bdf202a8f577d6c9b84432b3d59 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 13:04:56 +0100 Subject: [PATCH 04/19] added unittests for verify.py --- server/helpers/test_verify.py | 134 ++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 server/helpers/test_verify.py diff --git a/server/helpers/test_verify.py b/server/helpers/test_verify.py new file mode 100644 index 0000000..b384499 --- /dev/null +++ b/server/helpers/test_verify.py @@ -0,0 +1,134 @@ +import unittest + +from helpers import verify +from helpers.exceptions import * + + +class TestVerifyNumeric(unittest.TestCase): + def test_string_fails(self): + self.assertRaises(InvalidParameters, verify.numeric, candidate="6.7") + + def test_out_of_bounds_fails(self): + self.assertRaises(InvalidParameters, verify.numeric, candidate=3.98, minimum=5.0, maximum=10.0) + + def test_max_bounds_passes(self): + self.assertIsNone(verify.numeric(candidate=5.123, minimum=1.0, maximum=10.0)) + + def test_is_min_bound_passes(self): + self.assertIsNone(verify.numeric(candidate=1.0, minimum=1.0, maximum=10.0)) + + def test_is_max_bound_passes(self): + self.assertIsNone(verify.numeric(candidate=10.0, minimum=1.0, maximum=10.0)) + + +class TestVerifyNotNegativeNumeric(unittest.TestCase): + def test_null_int_passes(self): + self.assertIsNone(verify.not_negative_numeric(candidate=0)) + + def test_null_float_passes(self): + self.assertIsNone(verify.not_negative_numeric(candidate=0.0)) + + def test_positive_passes(self): + self.assertIsNone(verify.not_negative_numeric(candidate=1.3)) + + def test_negative_fails(self): + self.assertRaises(InvalidParameters, verify.not_negative_numeric, candidate=-2.4) + + +class TestVerifyPositiveNumeric(unittest.TestCase): + def test_null_int_fails(self): + self.assertRaises(InvalidParameters, verify.positive_numeric, candidate=0) + + def test_null_float_fails(self): + self.assertRaises(InvalidParameters, verify.positive_numeric, candidate=0.0) + + def test_positive_passes(self): + self.assertIsNone(verify.positive_numeric(candidate=1.3)) + + def test_negative_fails(self): + self.assertRaises(InvalidParameters, verify.positive_numeric, candidate=-2.4) + + +class TestVerifyInteger(unittest.TestCase): + def test_string_fails(self): + self.assertRaises(InvalidParameters, verify.integer, candidate="6") + + def test_out_of_bounds_fails(self): + self.assertRaises(InvalidParameters, verify.integer, candidate=3, minimum=5, maximum=10) + + def test_max_bounds_passes(self): + self.assertIsNone(verify.integer(candidate=5, minimum=1, maximum=10)) + + def test_is_min_bound_passes(self): + self.assertIsNone(verify.integer(candidate=1, minimum=1, maximum=10)) + + def test_is_max_bound_passes(self): + self.assertIsNone(verify.integer(candidate=10, minimum=1, maximum=10)) + + +class TestVerifyNotNegativeInteger(unittest.TestCase): + def test_null_int_passes(self): + self.assertIsNone(verify.not_negative_integer(candidate=0)) + + def test_null_float_fails(self): + self.assertRaises(InvalidParameters, verify.not_negative_integer, candidate=0.0) + + def test_positive_passes(self): + self.assertIsNone(verify.not_negative_integer(candidate=1)) + + def test_negative_fails(self): + self.assertRaises(InvalidParameters, verify.not_negative_integer, candidate=-2) + + +class TestVerifyPositiveInteger(unittest.TestCase): + def test_null_int_fails(self): + self.assertRaises(InvalidParameters, verify.positive_integer, candidate=0) + + def test_null_float_fails(self): + self.assertRaises(InvalidParameters, verify.positive_integer, candidate=0.0) + + def test_positive_passes(self): + self.assertIsNone(verify.positive_integer(candidate=1)) + + def test_negative_fails(self): + self.assertRaises(InvalidParameters, verify.positive_integer, candidate=-2) + + +class TestVerifyBoolean(unittest.TestCase): + def test_str_fails(self): + self.assertRaises(InvalidParameters, verify.boolean, candidate="True") + + def test_none_fails(self): + self.assertRaises(InvalidParameters, verify.boolean, candidate=None) + + def test_zero_fails(self): + self.assertRaises(InvalidParameters, verify.boolean, candidate=0) + + def test_one_fails(self): + self.assertRaises(InvalidParameters, verify.boolean, candidate=1) + + def test_True_passes(self): + self.assertIsNone(verify.boolean(candidate=True)) + + def test_False_passes(self): + self.assertIsNone(verify.boolean(candidate=False)) + + +class TestVerifyRGBColorTuple(unittest.TestCase): + def test_list_fails(self): + self.assertRaises(InvalidParameters, verify.rgb_color_tuple, candidate=[1, 2, 3]) + + def test_false_dimensional_tuple_fails(self): + self.assertRaises(InvalidParameters, verify.rgb_color_tuple, candidate=(0, 1, 2, 3)) + + def test_smaller_than_0_fails(self): + self.assertRaises(InvalidParameters, verify.rgb_color_tuple, candidate=(-0.5, 1, 2)) + + def test_bigger_than_255_fails(self): + self.assertRaises(InvalidParameters, verify.rgb_color_tuple, candidate=(1, 0.2, 275.8)) + + def test_float_passes(self): + self.assertIsNone(verify.rgb_color_tuple(candidate=(100.1, 101.2, 102.3))) + + def test_int_passes(self): + self.assertIsNone(verify.rgb_color_tuple(candidate=(123, 234, 12))) From 0de308b934c94be580ca21df80239c9ef69fb0c6 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 14:29:24 +0100 Subject: [PATCH 05/19] introduced destructor for drivers --- server/drivers/__init__.py | 12 ++++++++++++ server/drivers/apa102.py | 3 +++ server/drivers/dummy.py | 3 +++ 3 files changed, 18 insertions(+) diff --git a/server/drivers/__init__.py b/server/drivers/__init__.py index 0e7a638..f294a0b 100644 --- a/server/drivers/__init__.py +++ b/server/drivers/__init__.py @@ -52,6 +52,18 @@ def __init__(self, num_leds: int, max_clock_speed_hz: int = 4000000, gamma: floa self.synced_blue_buffer = SyncedArray('f', [0.0] * self.num_leds) self.synced_brightness_buffer = SyncedArray('i', self.brightness_buffer) + def __del__(self): + """ invokes self.close() and deletes all the buffers""" + self.close() + + del self.color_buffer, self.synced_red_buffer, self.synced_green_buffer, self.synced_blue_buffer + del self.brightness_buffer, self.synced_brightness_buffer + + @abstractmethod + def close(self): + """ close the bus connection and clean up remains""" + pass + def freeze(self): """ freezes the strip. All state-changing methods (on_color_change() and on_brightness_change()) diff --git a/server/drivers/apa102.py b/server/drivers/apa102.py index ddad4f3..2d6543f 100644 --- a/server/drivers/apa102.py +++ b/server/drivers/apa102.py @@ -103,6 +103,9 @@ def led_prefix(cls, brightness: int) -> int: return prefix_byte + def close(self): + self.spi.close() + @staticmethod def spi_start_frame() -> list: """ To start a transmission, one must send 32 empty bits """ diff --git a/server/drivers/dummy.py b/server/drivers/dummy.py index 3a1ba00..65d3291 100644 --- a/server/drivers/dummy.py +++ b/server/drivers/dummy.py @@ -34,3 +34,6 @@ def show(self) -> None: g=green, b=blue, brightness=brightness)) + + def close(self): + pass From 9024669ac999c42977e5b49f4968df5ef01152b9 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 14:42:22 +0100 Subject: [PATCH 06/19] corrected typo --- server/lightshows/templates/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lightshows/templates/base.py b/server/lightshows/templates/base.py index 35dfe89..a95cb22 100644 --- a/server/lightshows/templates/base.py +++ b/server/lightshows/templates/base.py @@ -53,7 +53,7 @@ def name(self) -> str: def start(self): """ invokes the run() method and after that synchronizes the shared buffer """ # before - signal.signal(signal.SIGINT, self.stop) # attach stop() to SIGSTOP + signal.signal(signal.SIGINT, self.stop) # attach stop() to SIGINT self.strip.sync_down() self.mqtt.start_listening() From 825079b33f68048aac0204bcdb3279c41f5cb7b1 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 14:43:07 +0100 Subject: [PATCH 07/19] added logging info for driver closing --- server/drivers/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/drivers/__init__.py b/server/drivers/__init__.py index f294a0b..daa43ec 100644 --- a/server/drivers/__init__.py +++ b/server/drivers/__init__.py @@ -59,6 +59,8 @@ def __del__(self): del self.color_buffer, self.synced_red_buffer, self.synced_green_buffer, self.synced_blue_buffer del self.brightness_buffer, self.synced_brightness_buffer + logger.info("Driver successfully closed") + @abstractmethod def close(self): """ close the bus connection and clean up remains""" From c03180c92180271eb32f73259bc78f4cf4d0f379 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 14:44:08 +0100 Subject: [PATCH 08/19] attached SIGTERM handler --- server/mqttcontrol.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/mqttcontrol.py b/server/mqttcontrol.py index 2aa4e97..1ee576c 100644 --- a/server/mqttcontrol.py +++ b/server/mqttcontrol.py @@ -178,5 +178,14 @@ def run(self) -> None: # start a show show to listen for brightness changes and refresh the strip regularly self.start_show("clear", {}) - client.loop_forever() - logger.critical("MQTTControl.py has exited") + try: + signal.signal(signal.SIGTERM, self.stop_controller) # attach stop_controller() to SIGTERM + client.loop_forever() + except KeyboardInterrupt: + self.stop_controller() + finally: + logger.critical("MQTTControl.py has exited") + + def stop_controller(self, signum=None, frame=None): + """ what happens if the controller exits """ + del self.strip # close driver connection From 6eab378cb1eb07e5feb53bd7636d6d417bb084c6 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 17:03:30 +0100 Subject: [PATCH 09/19] put logo and version in separate files --- logo | 6 ++++++ server/helpers/__init__.py | 12 ++++++++++++ server/server.py | 17 +++++++++-------- version | 1 + 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 logo create mode 100644 version diff --git a/logo b/logo new file mode 100644 index 0000000..72d8312 --- /dev/null +++ b/logo @@ -0,0 +1,6 @@ +\033[1;31m + _______ ___ __ + < / __ \__ \ _____/ /_ ____ _ _______ \033[0;32m + / / / / /_/ // ___/ __ \/ __ \ | /| / / ___/ + / / /_/ / __/(__ ) / / / /_/ / |/ |/ (__ ) \033[1;34m +/_/\____/____/____/_/ /_/\____/|__/|__/____/ \033[0m diff --git a/server/helpers/__init__.py b/server/helpers/__init__.py index 2af9a1d..7ae9748 100644 --- a/server/helpers/__init__.py +++ b/server/helpers/__init__.py @@ -7,3 +7,15 @@ """ __all__ = ['color', 'exceptions', 'mqtt', 'preprocessors', 'verify'] + + +def get_logo(filename: str ='../logo') -> str: + with open(filename, encoding='unicode_escape') as file: + contents = file.read() + return contents.rstrip('/n') # return without newline at the end + + +def get_version(filename: str ='../version') -> str: + with open(filename) as file: + contents = file.read() + return contents.rstrip('/n') # return without newline at the end \ No newline at end of file diff --git a/server/server.py b/server/server.py index af6f715..55b7136 100644 --- a/server/server.py +++ b/server/server.py @@ -23,18 +23,15 @@ import coloredlogs +from helpers import get_logo, get_version from helpers.configparser import get_configuration from mqttcontrol import MQTTControl __version__ = '0.2pre-dev' -greeting = """ - _______ ___ __ - < / __ \__ \ _____/ /_ ____ _ _______ - / / / / /_/ // ___/ __ \/ __ \ | /| / / ___/ - / / /_/ / __/(__ ) / / / /_/ / |/ |/ (__ ) -/_/\____/____/____/_/ /_/\____/|__/|__/____/ version: {version} - +logo = get_logo() +version = get_version() +license_hint = """ This is free software. You are welcome to redistribute it under the conditions of the GNU Public License v2. For details, see https://www.gnu.org/licenses/gpl-2.0.html @@ -48,7 +45,11 @@ coloredlogs.install(level=user_config.log_level) # friendly greeting -print(greeting.format(version=__version__), end='\n\n\n') +print(logo + " version: {}".format(version)) +print(license_hint) +print() +print() +print() # start the server! server = MQTTControl(user_config) # initialize the server... diff --git a/version b/version new file mode 100644 index 0000000..ddd514a --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.2-post.rc1 \ No newline at end of file From 5ea720c65a6e95eb3cb1bd84a056298bb6ca5090 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 17:09:51 +0100 Subject: [PATCH 10/19] beauty corrections --- logo | 2 +- server/helpers/__init__.py | 4 ++-- server/server.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/logo b/logo index 72d8312..0dbd9a4 100644 --- a/logo +++ b/logo @@ -3,4 +3,4 @@ < / __ \__ \ _____/ /_ ____ _ _______ \033[0;32m / / / / /_/ // ___/ __ \/ __ \ | /| / / ___/ / / /_/ / __/(__ ) / / / /_/ / |/ |/ (__ ) \033[1;34m -/_/\____/____/____/_/ /_/\____/|__/|__/____/ \033[0m +/_/\____/____/____/_/ /_/\____/|__/|__/____/ \033[0m \ No newline at end of file diff --git a/server/helpers/__init__.py b/server/helpers/__init__.py index 7ae9748..cd7b1f4 100644 --- a/server/helpers/__init__.py +++ b/server/helpers/__init__.py @@ -12,10 +12,10 @@ def get_logo(filename: str ='../logo') -> str: with open(filename, encoding='unicode_escape') as file: contents = file.read() - return contents.rstrip('/n') # return without newline at the end + return contents.rstrip().rstrip() # return without newline at the end def get_version(filename: str ='../version') -> str: with open(filename) as file: contents = file.read() - return contents.rstrip('/n') # return without newline at the end \ No newline at end of file + return contents.rstrip().rstrip() # return without newline at the end diff --git a/server/server.py b/server/server.py index 55b7136..cd5b9d0 100644 --- a/server/server.py +++ b/server/server.py @@ -27,8 +27,7 @@ from helpers.configparser import get_configuration from mqttcontrol import MQTTControl -__version__ = '0.2pre-dev' - +# constants logo = get_logo() version = get_version() license_hint = """ @@ -46,6 +45,7 @@ # friendly greeting print(logo + " version: {}".format(version)) +print() print(license_hint) print() print() From 250a57cb00acb4cca009838d4dcabbeca6bae0e9 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Tue, 20 Dec 2016 18:06:43 +0100 Subject: [PATCH 11/19] added config.example.py --- server/config.example.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 server/config.example.yml diff --git a/server/config.example.yml b/server/config.example.yml new file mode 100644 index 0000000..82fea55 --- /dev/null +++ b/server/config.example.yml @@ -0,0 +1,22 @@ +sys_name: null +log_level: INFO + +Strip: + driver: APA102 + num_leds: null + max_clock_speed_hz: 4000000 # [Hz] 4 MHz is the maximum for "large" strips of more than 500 LEDs. + initial_brightness: 50 # integer from 0 to 100 + max_brightness: 75 # maximum brightness + gamma: 2.8 # for gamma correction, put 1 to turn it off + +MQTT: + prefix: led + general_path: "{prefix}/{sys_name}/show/{show_name}/{command}" + notification_path: "{prefix}/{sys_name}/notification" + username: None + password: None + + Broker: + host: localhost + port: 1883 + keepalive: 60 # [seconds] From 57cfa6a91adfcfb8579fab1659608cbe62e5be39 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Wed, 21 Dec 2016 11:40:33 +0100 Subject: [PATCH 12/19] first prototype of setup.sh (see #20) --- server/setup.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 server/setup.sh diff --git a/server/setup.sh b/server/setup.sh new file mode 100644 index 0000000..58033a3 --- /dev/null +++ b/server/setup.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +RED='\033[0;31m' +LIGHTRED='\033[1;31m' +GREEN='\033[0;32m' +BLUE='\033[0;34m' +LIGHTBLUE='\033[1;34m' +LIGHTCYAN='\033[1;36m' +NOCOLOR='\033[0m' # No Color + +BRANCH='master' + +function status_update() { + echo -e "\n${LIGHTBLUE}$@${NOCOLOR}" +} + +function msg_error() { + echo -e "\n${LIGHTRED}$@${NOCOLOR}" +} + +function msg_success() { + echo -e "\n${GREEN}$@${NOCOLOR}" +} + +function question() { + echo -en "${LIGHTCYAN}$@${NOCOLOR}" +} + +function install() +{ + status_update " => Getting the latest stable release from GitHub" + git clone -b ${BRANCH} https://github.com/Yottabits/102shows.git + rc=$?; if [[ ${rc} == 0 ]]; then # check for success + msg_success " => Download finished! (return code: $rc)" + else + msg_error " => Download failed! (return code: $rc)" + msg_error " Exiting installation!" + exit ${rc} + fi + + + cd 102shows + + rm -rf ./.git # remove git assets + rm ./server/setup.sh # remove this installer + + status_update " => Installing requirements..." + pip3 install -r ./requirements.txt + rc=$?; if [[ ${rc} == 0 ]]; then # check for success + msg_success " => Requirements are ready! (return code: $rc)" + else + msg_error " => Requirements installation failed! (return code: $rc)" + msg_error " Maybe You do not have sufficient rights - try running this script with sudo..." + msg_error " For now I am going to quit the installation." + exit ${rc} + fi + + echo -e "$(cat logo) version: $(cat version)" + echo -e "\n\n" + + question " => Would you like to configure 102shows now? [Y/n] " + read answer + if [ "$answer" != "n" ] && [ "$answer" != "N" ]; then + status_update " => copying config.example.yml to config.yml" + cp ./server/config.example.yml ./server/config.yml + status_update " => starting editor..." + editor ./server/config.yml + else + msg_error " => Before you can start the 102shows server," + msg_error " you must provide a valid configuration file" + msg_error " in \"102shows/server/config.yml\"" + fi + + msg_success " => We successfully installed the 102shows server :-)" + msg_success " - Note that you need to an MQTT broker in order for the server to work" + msg_success " - If you want to use the included UI, you should install it now" + msg_success " You can find the instructions at https://github.com/Yottabits/102shows/wiki/Installation#web-ui" +} + +function main() +{ + question " => Would you like to install 102shows to $PWD/102shows? [y/N] " + read answer + if [ "$answer" == "y" ] || [ "$answer" == "Y" ] + then + install + fi + +} + +main From e9863842770d942f3f84f7c19a2d127e6d62c9d8 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Wed, 21 Dec 2016 11:56:20 +0100 Subject: [PATCH 13/19] force read from /dev/tty --- server/setup.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/setup.sh b/server/setup.sh index 58033a3..3ab114c 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -26,6 +26,14 @@ function question() { echo -en "${LIGHTCYAN}$@${NOCOLOR}" } +function check_tty() { + if ! [[ - t 1 ]]; then + msg_error " => You need an interactive terminal to run this script!" + exit + fi + return +} + function install() { status_update " => Getting the latest stable release from GitHub" @@ -59,7 +67,7 @@ function install() echo -e "\n\n" question " => Would you like to configure 102shows now? [Y/n] " - read answer + read answer copying config.example.yml to config.yml" cp ./server/config.example.yml ./server/config.yml @@ -79,8 +87,9 @@ function install() function main() { + check_tty question " => Would you like to install 102shows to $PWD/102shows? [y/N] " - read answer + read answer Date: Wed, 21 Dec 2016 11:57:21 +0100 Subject: [PATCH 14/19] bugfix --- server/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/setup.sh b/server/setup.sh index 3ab114c..d09ab6d 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -27,7 +27,7 @@ function question() { } function check_tty() { - if ! [[ - t 1 ]]; then + if ! [[ -t 1 ]]; then msg_error " => You need an interactive terminal to run this script!" exit fi From fbd2f50dfa640b9bbff5caf9fcfd7b234c136367 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Wed, 21 Dec 2016 11:59:29 +0100 Subject: [PATCH 15/19] no message --- server/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/setup.sh b/server/setup.sh index d09ab6d..40c88a4 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -27,7 +27,7 @@ function question() { } function check_tty() { - if ! [[ -t 1 ]]; then + if [[ -t 0 ]]; then msg_error " => You need an interactive terminal to run this script!" exit fi From 03320ad26166a5aae4c391a650784a070e51024e Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Wed, 21 Dec 2016 12:07:36 +0100 Subject: [PATCH 16/19] bufix --- server/setup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/setup.sh b/server/setup.sh index 40c88a4..63155ac 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -27,11 +27,10 @@ function question() { } function check_tty() { - if [[ -t 0 ]]; then + if ! [[ -t 1 ]]; then msg_error " => You need an interactive terminal to run this script!" exit fi - return } function install() From 6640824a594a2e180293c5ed061606f7d36cc5ef Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Wed, 21 Dec 2016 12:18:29 +0100 Subject: [PATCH 17/19] removed /dev/tty check --- server/setup.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/server/setup.sh b/server/setup.sh index 63155ac..b895eac 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -26,13 +26,6 @@ function question() { echo -en "${LIGHTCYAN}$@${NOCOLOR}" } -function check_tty() { - if ! [[ -t 1 ]]; then - msg_error " => You need an interactive terminal to run this script!" - exit - fi -} - function install() { status_update " => Getting the latest stable release from GitHub" @@ -66,7 +59,7 @@ function install() echo -e "\n\n" question " => Would you like to configure 102shows now? [Y/n] " - read answer copying config.example.yml to config.yml" cp ./server/config.example.yml ./server/config.yml @@ -88,7 +81,7 @@ function main() { check_tty question " => Would you like to install 102shows to $PWD/102shows? [y/N] " - read answer Date: Wed, 21 Dec 2016 12:35:52 +0100 Subject: [PATCH 18/19] removed check_tty reference --- server/setup.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/server/setup.sh b/server/setup.sh index b895eac..58033a3 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -79,7 +79,6 @@ function install() function main() { - check_tty question " => Would you like to install 102shows to $PWD/102shows? [y/N] " read answer if [ "$answer" == "y" ] || [ "$answer" == "Y" ] From 4e92c4e157f719b491b0b152fb45a857a2761634 Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Wed, 21 Dec 2016 13:58:53 +0100 Subject: [PATCH 19/19] finalized setup.sh (this closes #20) - target branch is now "stable" - .git is not removed anymore - success message tells you how to start the server --- server/setup.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/setup.sh b/server/setup.sh index 58033a3..1486a64 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -8,7 +8,7 @@ LIGHTBLUE='\033[1;34m' LIGHTCYAN='\033[1;36m' NOCOLOR='\033[0m' # No Color -BRANCH='master' +BRANCH='stable' function status_update() { echo -e "\n${LIGHTBLUE}$@${NOCOLOR}" @@ -41,7 +41,6 @@ function install() cd 102shows - rm -rf ./.git # remove git assets rm ./server/setup.sh # remove this installer status_update " => Installing requirements..." @@ -71,10 +70,13 @@ function install() msg_error " in \"102shows/server/config.yml\"" fi - msg_success " => We successfully installed the 102shows server :-)" - msg_success " - Note that you need to an MQTT broker in order for the server to work" - msg_success " - If you want to use the included UI, you should install it now" - msg_success " You can find the instructions at https://github.com/Yottabits/102shows/wiki/Installation#web-ui" + msg_success " + => We successfully installed the 102shows server :-) + - Note that you need to an MQTT broker in order for the server to work + - If you wan t to use the included UI, you should install it now + You can find the instructions at https://git.io/v1x5Os + - To run the server, cd in $PWD/server and execute \"python3 server.py\" + " } function main()