simplify some logging calls

This commit is contained in:
Mike Fährmann
2019-12-10 21:30:08 +01:00
parent c9ef1b21c3
commit c4702ec9b6
4 changed files with 6 additions and 6 deletions

View File

@@ -57,7 +57,7 @@ def load(files=None, strict=False, fmt="json"):
confdict = parsefunc(file) confdict = parsefunc(file)
except OSError as exc: except OSError as exc:
if strict: if strict:
log.error("%s", exc) log.error(exc)
sys.exit(1) sys.exit(1)
except Exception as exc: except Exception as exc:
log.warning("Could not parse '%s': %s", path, exc) log.warning("Could not parse '%s': %s", path, exc)

View File

@@ -99,7 +99,7 @@ class HttpDownloader(DownloaderBase):
msg = str(exc) msg = str(exc)
continue continue
except Exception as exc: except Exception as exc:
self.log.warning("%s", exc) self.log.warning(exc)
return False return False
# check response # check response
@@ -116,7 +116,7 @@ class HttpDownloader(DownloaderBase):
msg = "'{} {}' for '{}'".format(code, response.reason, url) msg = "'{} {}' for '{}'".format(code, response.reason, url)
if code == 429 or 500 <= code < 600: # Server Error if code == 429 or 500 <= code < 600: # Server Error
continue continue
self.log.warning("%s", msg) self.log.warning(msg)
return False return False
size = text.parse_int(size) size = text.parse_int(size)

View File

@@ -243,7 +243,7 @@ class PinterestAPI():
if response.status_code == 404 or response.history: if response.status_code == 404 or response.history:
resource = self.extractor.subcategory.rpartition("-")[2] resource = self.extractor.subcategory.rpartition("-")[2]
raise exception.NotFoundError(resource) raise exception.NotFoundError(resource)
self.extractor.log.debug("%s", response.text) self.extractor.log.debug("Server response: %s", response.text)
raise exception.StopExtraction("API request failed") raise exception.StopExtraction("API request failed")
def _pagination(self, resource, options): def _pagination(self, resource, options):

View File

@@ -156,8 +156,8 @@ class TumblrExtractor(Extractor):
invalid = types - POST_TYPES invalid = types - POST_TYPES
if invalid: if invalid:
types = types & POST_TYPES types = types & POST_TYPES
self.log.warning('invalid post types: "%s"', self.log.warning("Invalid post types: '%s'",
'", "'.join(sorted(invalid))) "', '".join(sorted(invalid)))
return types return types
@staticmethod @staticmethod