From 0cdfd7b2fe2e75ce0b6e2021cb47254f3f8f83e5 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Wed, 22 Sep 2021 20:14:58 +0100 Subject: [PATCH] Fix linting --- alerts/player.py | 7 +++++-- alerts/server.py | 6 ++++-- baps_types/alert.py | 3 ++- helpers/alert_manager.py | 2 +- package.json | 2 +- web_server.py | 3 ++- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/alerts/player.py b/alerts/player.py index 1c9b70b..9ed9da8 100644 --- a/alerts/player.py +++ b/alerts/player.py @@ -48,7 +48,9 @@ class PlayerAlertProvider(AlertProvider): "start_time": -1, # Now "id": "no_channels", "title": "There are no players configured.", - "description": "The number of channels configured is {}. Please set to at least 1 on the 'Server Config' page.".format(self._player_count), + "description": "The number of channels configured is {}. \ + Please set to at least 1 on the 'Server Config' page." + .format(self._player_count), "module": MODULE+"Handler", "severity": CRITICAL })] @@ -61,7 +63,8 @@ class PlayerAlertProvider(AlertProvider): "start_time": -1, # Now "id": "player_{}_not_initialised".format(channel), "title": "Player {} is not initialised.".format(channel), - "description": "This typically means the player channel was not able find the configured sound output on the system. Please check the 'Player Config' and Player logs to determine the cause.", + "description": "This typically means the player channel was not able find the configured sound output \ + on the system. Please check the 'Player Config' and Player logs to determine the cause.", "module": MODULE+str(channel), "severity": CRITICAL })) diff --git a/alerts/server.py b/alerts/server.py index 6a07d06..d89e186 100644 --- a/alerts/server.py +++ b/alerts/server.py @@ -37,7 +37,8 @@ class ServerAlertProvider(AlertProvider): "start_time": -1, # Now "id": "api_key_missing", "title": "MyRadio API Key is not configured.", - "description": "This means you will be unable to load show plans, audio items, or tracklist. Please set one on the 'Server Config' page.", + "description": "This means you will be unable to load show plans, audio items, or tracklist. \ + Please set one on the 'Server Config' page.", "module": MODULE, "severity": CRITICAL })] @@ -47,7 +48,8 @@ class ServerAlertProvider(AlertProvider): "start_time": -1, "id": "api_key_missing", "title": "MyRadio API Key seems incorrect.", - "description": "The API key is less than 10 characters, it's probably not a valid one. If it is valid, it shouldn't be.", + "description": "The API key is less than 10 characters, it's probably not a valid one. \ + If it is valid, it shouldn't be.", "module": MODULE, "severity": WARNING })] diff --git a/baps_types/alert.py b/baps_types/alert.py index 05e792a..33ddd76 100644 --- a/baps_types/alert.py +++ b/baps_types/alert.py @@ -56,7 +56,8 @@ class Alert: raise KeyError("Key {} is missing from data to create Alert.".format(key)) # if type(new_data[key]) != type(getattr(self,key)): - # raise TypeError("Key {} has type {}, was expecting {}.".format(key, type(new_data[key]), type(getattr(self,key)))) + # raise TypeError("Key {} has type {}, was expecting {}." + # .format(key, type(new_data[key]), type(getattr(self,key)))) # Account for if the creator didn't want to set a custom time. if key == "start_time" and new_data[key] == -1: diff --git a/helpers/alert_manager.py b/helpers/alert_manager.py index f2ca4fe..53cdaea 100644 --- a/helpers/alert_manager.py +++ b/helpers/alert_manager.py @@ -6,7 +6,7 @@ from importlib import import_module from inspect import getmembers, isclass from sys import modules -from baps_types.alert import CRITICAL, Alert +from baps_types.alert import Alert import alerts diff --git a/package.json b/package.json index f4fb81f..cae6ea8 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "presenter-make": "npm run presenter-install && (rm -r presenter-build || true) && cd presenter && yarn build-baps && cp -r build ../presenter-build && cd ../ && npm install", "test": "echo \"Error: no test specified\" && exit 1", "presenter-start": "cd presenter && yarn start-baps", - "lint": "autopep8 -r -a -a --ignore E402,E226,E24,W50,W690 --max-line-length 127 --in-place --exclude=\"*node_modules*,*venv/*,presenter/*\" . " + "lint": "./venv/bin/autopep8 -r -a -a --ignore E402,E226,E24,W50,W690 --max-line-length 127 --in-place --exclude=\"*node_modules*,*venv/*,presenter/*\" . && ./venv/bin/flake8 . --exclude=\"*node_modules*,*venv/*,presenter/*\" --count --ignore=E402,E226,E24,W50,W690 --max-complexity=25 --max-line-length=127 --statistics" }, "repository": { "type": "git", diff --git a/web_server.py b/web_server.py index 1ba3940..142db8a 100644 --- a/web_server.py +++ b/web_server.py @@ -1,5 +1,5 @@ from sanic import Sanic -from sanic.exceptions import NotFound, ServerError, abort +from sanic.exceptions import NotFound, abort from sanic.response import html, file, redirect from sanic.response import json as resp_json from sanic_cors import CORS @@ -119,6 +119,7 @@ def page_not_found(request, e: Any): "message": "Looks like you fell off the tip of the iceberg."} return render_template("error.html", data=data, status=404) + # Future use. def error_page(code=500, ui_title="500", title="Something went very wrong!", message="Looks like the server fell over. Try viewing the WebServer logs for more details."):