From 4c0c25aea6e0dbac7809d4ca83f05d156f9fdaf6 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Fri, 10 Apr 2020 07:22:09 +0100 Subject: [PATCH 1/2] Fix AttributeError in anime manager while editing show (part deux). --- CHANGES.md | 7 ++++++- sickbeard/anime.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cccede9..2d00130 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,9 @@ -### 0.21.25 (2020-04-10 01:50:00 UTC) +### 0.21.26 (2020-04-10 07:20:00 UTC) + +* Fix AttributeError in anime manager while editing show (part deux) + + +### 0.21.25 (2020-04-10 01:50:00 UTC) * Fix Kodi uniqueid tag not validated during import * Change slightly improve performance iterating metadata providers diff --git a/sickbeard/anime.py b/sickbeard/anime.py index 59b057f..3a1c330 100644 --- a/sickbeard/anime.py +++ b/sickbeard/anime.py @@ -174,7 +174,7 @@ def short_group_names(groups): pass if isinstance(adba_result, LoginFirstResponse): break - if None is adba_result or not adba_result.hasattr('datalines', None): + if None is adba_result or not hasattr(adba_result, 'datalines'): continue for line in adba_result.datalines: if line['shortname']: From 90612262f483442165f1e6ce61dc5663bfff8333 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Fri, 10 Apr 2020 23:52:32 +0100 Subject: [PATCH 2/2] Fix use lib logger instead of global logger. Change use 'adba' as central logger name. Fix use the referenced obj in %s , %r. Fix logger in fuzzywuzzy (replace global logging). Change improve providers import. Fix filter_iter, map_iter type string. --- CHANGES.md | 3 ++- lib/_23.py | 6 +++--- lib/adba/__init__.py | 10 +++++----- lib/adba/aniDBAbstracter.py | 6 +++--- lib/adba/aniDBfileInfo.py | 4 ++-- lib/adba/aniDBlink.py | 10 +++++----- lib/fuzzywuzzy/process.py | 9 ++++++--- sickbeard/providers/__init__.py | 2 +- 8 files changed, 27 insertions(+), 23 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2d00130..f35c59a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ -### 0.21.26 (2020-04-10 07:20:00 UTC) +### 0.21.26 (2020-04-13 00:30:00 UTC) * Fix AttributeError in anime manager while editing show (part deux) +* Fix use lib logger instead of global logger ### 0.21.25 (2020-04-10 01:50:00 UTC) diff --git a/lib/_23.py b/lib/_23.py index 61dd110..0318f89 100644 --- a/lib/_23.py +++ b/lib/_23.py @@ -30,7 +30,7 @@ if False: # resolve typing imports # ---------------------- # noinspection PyUnresolvedReferences - from typing import Any, AnyStr, Callable, Dict, Iterator, List, Optional, Tuple, Union + from typing import Any, AnyStr, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union # ------------------- # resolve pyc imports # ------------------- @@ -42,8 +42,8 @@ if False: PY38 = version_info[0:2] >= (3, 8) """ one off consumables (Iterators) """ -filter_iter = moves.filter # type: Callable[[], Iterator] -map_iter = moves.map # type: Callable[[], Iterator] +filter_iter = moves.filter # type: Callable[[Callable, Iterable], Iterator] +map_iter = moves.map # type: Callable[[Callable, ...], Iterator] def map_consume(*args): diff --git a/lib/adba/__init__.py b/lib/adba/__init__.py index d2c1b88..bd8fdd8 100644 --- a/lib/adba/__init__.py +++ b/lib/adba/__init__.py @@ -31,7 +31,7 @@ from .aniDBAbstracter import Anime, Episode version = 100 -logger = logging.getLogger(__name__) +logger = logging.getLogger('adba') logger.addHandler(logging.NullHandler()) @@ -189,13 +189,13 @@ class Connection(threading.Thread): self._username = username self._password = password if False is self.is_alive(): - logging.debug("You wanted to keep this thing alive!") + logger.debug("You wanted to keep this thing alive!") if False is self._iamALIVE: - logging.info("Starting thread now...") + logger.info("Starting thread now...") self.start() self._iamALIVE = True else: - logging.info("not starting thread seems like it is already running. this must be a _reAuthenticate") + logger.info("not starting thread seems like it is already running. this must be a _reAuthenticate") config = ConfigParser() config.read(self.SessionFile) @@ -224,7 +224,7 @@ class Connection(threading.Thread): try: self.handle(AuthCommand(username, password, 3, self.clientname, self.clientver, nat, 1, 'utf8', mtu), callback) except Exception as error: - logger.debug('Auth command with exception %r', error) + logger.debug('Auth command with exception %r' % error) # we force a config file with logged out to ensure a known state if an exception occurs, forcing us to log in again config['DEFAULT'] = {'loggedin': 'yes', 'sessionkey': str(self.link.session or ''), 'exception': str(error), 'lastcommandtime': repr(time())} diff --git a/lib/adba/aniDBAbstracter.py b/lib/adba/aniDBAbstracter.py index 2725a9c..06b2339 100644 --- a/lib/adba/aniDBAbstracter.py +++ b/lib/adba/aniDBAbstracter.py @@ -30,7 +30,7 @@ from .aniDBfileInfo import read_anidb_xml from _23 import decode_str -logger = logging.getLogger(__name__) +logger = logging.getLogger('adba') logger.addHandler(logging.NullHandler()) @@ -281,7 +281,7 @@ class Episode(aniDBabstractObject): try: self.aniDB.mylistadd(size=self.size, ed2k=self.ed2k, state=state, viewed=viewed, source=source, storage=storage, other=other) except Exception as e: - logger.exception("Exception: %s", e) + logger.exception("Exception: %s" % e) else: # TODO: add the name or something logger.info("Added the episode to anidb") @@ -292,7 +292,7 @@ class Episode(aniDBabstractObject): try: self.aniDB.mylistdel(size=self.size, ed2k=self.ed2k) except Exception as e: - logger.exception("Exception: %s", e) + logger.exception("Exception: %s" % e) else: logger.info("Deleted the episode from anidb") diff --git a/lib/adba/aniDBfileInfo.py b/lib/adba/aniDBfileInfo.py index 1a31275..809ff89 100644 --- a/lib/adba/aniDBfileInfo.py +++ b/lib/adba/aniDBfileInfo.py @@ -27,7 +27,7 @@ import time import xml.etree.cElementTree as etree -logger = logging.getLogger(__name__) +logger = logging.getLogger('adba') logger.addHandler(logging.NullHandler()) @@ -140,7 +140,7 @@ def _remove_file_failed(file): try: os.remove(file) except OSError: - logger.warning("Error occurred while trying to remove file %s", file) + logger.warning("Error occurred while trying to remove file %s" % file) def download_file(url, filename): diff --git a/lib/adba/aniDBlink.py b/lib/adba/aniDBlink.py index 40e9ce1..af04c9c 100644 --- a/lib/adba/aniDBlink.py +++ b/lib/adba/aniDBlink.py @@ -26,7 +26,7 @@ from time import time, sleep from .aniDBerrors import * from .aniDBresponses import ResponseResolver -logger = logging.getLogger(__name__) +logger = logging.getLogger('adba') logger.addHandler(logging.NullHandler()) @@ -99,9 +99,9 @@ class AniDBLink(threading.Thread): self._handle_timeouts() continue except OSError as error: - logger.exception('Exception: %s', error) + logger.exception('Exception: %s' % error) break - logger.debug("NetIO < %r", data) + logger.debug("NetIO < %r" % data) try: for i in range(2): try: @@ -109,10 +109,10 @@ class AniDBLink(threading.Thread): resp = None if tmp[:2] == b'\x00\x00': tmp = zlib.decompressobj().decompress(tmp[2:]) - logger.debug("UnZip | %r", tmp) + logger.debug("UnZip | %r" % tmp) resp = ResponseResolver(tmp) except Exception as e: - logger.exception('Exception: %s', e) + logger.exception('Exception: %s' % e) sys.excepthook(*sys.exc_info()) self.crypt = None self.session = None diff --git a/lib/fuzzywuzzy/process.py b/lib/fuzzywuzzy/process.py index 4d73248..b79c332 100644 --- a/lib/fuzzywuzzy/process.py +++ b/lib/fuzzywuzzy/process.py @@ -6,6 +6,9 @@ import heapq import logging from functools import partial +logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) + default_scorer = fuzz.WRatio @@ -78,9 +81,9 @@ def extractWithoutOrder(query, choices, processor=default_processor, scorer=defa processed_query = processor(query) if len(processed_query) == 0: - logging.warning(u"Applied processor reduces input query to empty string, " - "all comparisons will have score 0. " - "[Query: \'{0}\']".format(query)) + logger.warning(u"Applied processor reduces input query to empty string, " + "all comparisons will have score 0. " + "[Query: \'{0}\']".format(query)) # Don't run full_process twice if scorer in [fuzz.WRatio, fuzz.QRatio, diff --git a/sickbeard/providers/__init__.py b/sickbeard/providers/__init__.py index 0731763..4fbbb10 100755 --- a/sickbeard/providers/__init__.py +++ b/sickbeard/providers/__init__.py @@ -17,7 +17,7 @@ # along with SickGear. If not, see . import importlib -from os import sys +import sys from . import generic, newznab from .newznab import NewznabConstants