-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) error where logs did not have passwords and other items censore…
…d and UNDEFINED on first startup (#8777) * (fix) error where logs did not have passwords and other items censored (fix) error on first startup of UNDEFINED comparison if page loads before the error viewer has loaded (refactor) move ErrorViewer and WarningViewer into a sinlge class called WebErrorViewer and add utility functions, which cleaned up code and moved it to sickchill.logging.weblog (refactor) move sickchill.oldbeard.classes to sickchill.providers.result_classes Signed-off-by: miigotu <[email protected]> * (refactor) add missed changes in mako Signed-off-by: miigotu <[email protected]> * (fix) depends: explicitly include appdirs in dependencies and upgrade all yarn and poetry dependencies Signed-off-by: miigotu <[email protected]> --------- Signed-off-by: miigotu <[email protected]>
- Loading branch information
Showing
30 changed files
with
186 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import datetime | ||
import logging | ||
import sys | ||
from logging import ERROR, WARNING | ||
|
||
from sickchill.helper.common import dateTimeFormat | ||
from sickchill.oldbeard.notifiers import notify_logged_error | ||
|
||
|
||
class __WebErrorViewer(object): | ||
""" | ||
Keeps a static list of UIErrors to be displayed on the UI and allows | ||
the list to be cleared. | ||
""" | ||
|
||
__errors = [] | ||
__warnings = [] | ||
|
||
def __init__(self): | ||
self.__errors = [] | ||
self.__warnings = [] | ||
|
||
def __len__(self): | ||
return self.len() | ||
|
||
def add_error(self, error): | ||
self.__errors = [e for e in self.__errors if e.message != error.message] | ||
self.__errors.append(error) | ||
|
||
def add_warning(self, warning): | ||
self.__warnings = [w for w in self.__warnings if w.message != warning.message] | ||
self.__warnings.append(warning) | ||
|
||
def add(self, record): | ||
if record.levelno in (ERROR, WARNING): | ||
ui_error = UIError(record.msg, record.levelno) | ||
if record.levelno == ERROR: | ||
self.add_error(ui_error) | ||
if record.levelno == WARNING: | ||
self.add_warning(ui_error) | ||
|
||
if record.levelno == ERROR: | ||
notify_logged_error(ui_error) | ||
|
||
def get_errors(self): | ||
return self.__errors | ||
|
||
def get_warnings(self): | ||
return self.__warnings | ||
|
||
def have_errors(self): | ||
return len(self.__errors) | ||
|
||
def have_warnings(self): | ||
return len(self.__warnings) | ||
|
||
def clear_errors(self): | ||
self.__errors = [] | ||
|
||
def clear_warnings(self): | ||
self.__warnings = [] | ||
|
||
def clear(self, level: str) -> str: | ||
level = logging.getLevelName(level.upper()) | ||
if level == logging.ERROR: | ||
message = "Error logs cleared" | ||
self.clear_errors() | ||
elif level == logging.WARNING: | ||
message = "Warning logs cleared" | ||
self.clear_warnings() | ||
else: | ||
message = "Warning and Error logs cleared" | ||
self.clear_warnings() | ||
self.clear_errors() | ||
|
||
return message | ||
|
||
def num_errors(self): | ||
return len(self.__errors) | ||
|
||
def num_warnings(self): | ||
return len(self.__warnings) | ||
|
||
def has_errors(self): | ||
return len(self.__errors) > 0 | ||
|
||
def has_warnings(self): | ||
return len(self.__warnings) > 0 | ||
|
||
def len(self): | ||
return self.num_errors() + self.num_warnings() | ||
|
||
|
||
WebErrorViewer = __WebErrorViewer() | ||
|
||
|
||
class UIError(object): | ||
""" | ||
Represents an error to be displayed in the web UI. | ||
""" | ||
|
||
def __init__(self, message, level): | ||
self.title = sys.exc_info()[-2] or message | ||
self.message = message | ||
self.time = datetime.datetime.now().strftime(dateTimeFormat) | ||
self.level = level |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# Author: Marvin Pinto <[email protected]> | ||
# Author: Dennis Lutter <[email protected]> | ||
import time | ||
from typing import TYPE_CHECKING | ||
|
||
import requests | ||
|
||
from sickchill import logger, settings | ||
from sickchill.oldbeard.classes import UIError | ||
from sickchill.oldbeard.common import ( | ||
NOTIFY_DOWNLOAD, | ||
NOTIFY_LOGIN, | ||
|
@@ -18,6 +18,10 @@ | |
) | ||
from sickchill.oldbeard.helpers import make_session | ||
|
||
if TYPE_CHECKING: | ||
from sickchill.logging.weblog import UIError | ||
|
||
|
||
API_URL = "https://api.pushover.net/1/messages.json" | ||
|
||
|
||
|
@@ -128,7 +132,7 @@ def notify_login(self, ipaddress=""): | |
title = notifyStrings[NOTIFY_LOGIN] | ||
self._notify_pushover(title, update_text.format(ipaddress)) | ||
|
||
def notify_logged_error(self, ui_error: UIError): | ||
def notify_logged_error(self, ui_error: "UIError"): | ||
if settings.USE_PUSHOVER: | ||
self._notify_pushover(title=ui_error.title, message=ui_error.message) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.