From 49b884cde78f28b5afb0813637789cea4dd6d44f Mon Sep 17 00:00:00 2001 From: Halali Date: Mon, 18 Feb 2019 12:44:33 +0100 Subject: [PATCH] Continue developing --- bazarr/check_update.py | 4 ++-- bazarr/main.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bazarr/check_update.py b/bazarr/check_update.py index 5255c5e6a..38bcd28cb 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -12,7 +12,7 @@ import json from get_args import args from config import settings, bazarr_url -from queueconfig import q4ws +from queueconfig import q4ws, q4ws_updater def check_releases(): @@ -137,7 +137,7 @@ def check_updates(): update() elif commits_behind == 0: - q4ws.append('BAZZAR is up to date') + q4ws_updater.append('BAZZAR is up to date') logging.info('BAZZAR is up to date') return latest_version diff --git a/bazarr/main.py b/bazarr/main.py index 72d497f9e..601156c0f 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -2010,6 +2010,26 @@ def running_tasks_list(): return dict(tasks=running_tasks) +@route(base_url + 'websocket_updater') +@custom_auth_basic(check_credentials) +def handle_websocket(): + wsock = request.environ.get('wsgi.websocket') + if not wsock: + abort(400, 'Expected WebSocket request.') + + queueconfig.q4ws_updater.clear() + + while True: + try: + if queueconfig.q4ws_updater: + wsock.send(queueconfig.q4ws_updater.popleft()) + gevent.sleep(0.1) + else: + gevent.sleep(0.5) + except WebSocketError: + break + + # Mute DeprecationWarning warnings.simplefilter("ignore", DeprecationWarning) server = WSGIServer((str(settings.general.ip), (int(args.port) if args.port else int(settings.general.port))), app, handler_class=WebSocketHandler)