From e3212dd98ff45bd7208e03f1d005132c19de224f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 27 Mar 2017 13:22:02 +0200 Subject: [PATCH] fix some smaller stuff - remove support for old windows config paths - catch exception if cache-database can't be opened - fix username/password settings for unit tests - rename variable 'max_tries' to 'retries' --- gallery_dl/cache.py | 2 +- gallery_dl/config.py | 2 -- gallery_dl/downloader/http.py | 6 +++--- test/test_extractors.py | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gallery_dl/cache.py b/gallery_dl/cache.py index b95b43de..742dbea3 100644 --- a/gallery_dl/cache.py +++ b/gallery_dl/cache.py @@ -213,6 +213,6 @@ memcache = build_cache_decorator(MEMCACHE) try: DBCACHE = DatabaseCache() cache = build_cache_decorator(MEMCACHE, DBCACHE) -except RuntimeError(): +except (RuntimeError, sqlite3.OperationalError): DBCACHE = None cache = memcache diff --git a/gallery_dl/config.py b/gallery_dl/config.py index 662ce826..88fede98 100644 --- a/gallery_dl/config.py +++ b/gallery_dl/config.py @@ -23,9 +23,7 @@ _config = {} if os.name == "nt": _default_configs = [ - r"~\.config\gallery-dl\config.json", r"%USERPROFILE%\gallery-dl\config.json", - r"~\.gallery-dl.conf", r"%USERPROFILE%\gallery-dl.conf", ] else: diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 5cd2f7a6..8f27d14f 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -18,7 +18,7 @@ from .. import config class Downloader(BasicDownloader): - max_tries = config.interpolate(("downloader", "http", "retries",), 5) + retries = config.interpolate(("downloader", "http", "retries",), 5) timeout = config.interpolate(("downloader", "http", "timeout",), None) def __init__(self, output): @@ -32,8 +32,8 @@ class Downloader(BasicDownloader): while True: tries += 1 if tries > 1: - self.out.error(pathfmt.path, msg, tries-1, self.max_tries) - if tries > self.max_tries: + self.out.error(pathfmt.path, msg, tries-1, self.retries) + if tries > self.retries: return time.sleep(1) diff --git a/test/test_extractors.py b/test/test_extractors.py index 6419c215..7d13ec50 100644 --- a/test/test_extractors.py +++ b/test/test_extractors.py @@ -18,8 +18,8 @@ class TestExtractors(unittest.TestCase): name = "gallerydl" email = "gallerydl@openaliasbox.org" config.set(("cache", "file"), ":memory:") - config.set(("username",), name) - config.set(("password",), name) + config.set(("extractor", "username"), name) + config.set(("extractor", "password"), name) config.set(("extractor", "nijie", "username"), email) config.set(("extractor", "seiga", "username"), email)