From 9c28c30ec8d3c95f7746d46ac8aeb664b3fdfbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 14 Oct 2018 09:32:16 -0400 Subject: [PATCH] Add link to restart and manage KeyboardInterrupt --- bazarr.py | 9 ++++++--- bazarr/main.py | 6 +++++- views/menu.tpl | 26 +++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/bazarr.py b/bazarr.py index d9cc8f0d4..44dbd0828 100644 --- a/bazarr.py +++ b/bazarr.py @@ -29,10 +29,13 @@ dir_name = os.path.dirname(__file__) def start_bazarr(): script = [sys.executable, os.path.normcase(os.path.join(globals()['dir_name'], 'bazarr/main.py'))] + globals()['arguments'] - ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT) + ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT, stdin=sp.PIPE) logging.info("Bazarr starting...") - for line in iter(ep.stdout.readline, ''): - sys.stdout.write(line) + try: + for line in iter(ep.stdout.readline, ''): + sys.stdout.write(line) + except KeyboardInterrupt: + pass if __name__ == '__main__': diff --git a/bazarr/main.py b/bazarr/main.py index aba9d0b97..4804312ec 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1693,4 +1693,8 @@ warnings.simplefilter("ignore", DeprecationWarning) server = CherryPyWSGIServer((str(ip), int(port)), app) logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url)) -server.start() \ No newline at end of file +try: + print('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url)) + server.start() +except KeyboardInterrupt: + shutdown() diff --git a/views/menu.tpl b/views/menu.tpl index 9c98a29e8..af62aa4a1 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -117,11 +117,11 @@ % c.close() % if restart_required[1] == '1' and restart_required[0] == '1': -