From 00a0d35020a4bb37f6563751e008f34f07b64d98 Mon Sep 17 00:00:00 2001 From: Safihre Date: Wed, 17 Jun 2020 21:48:48 +0200 Subject: [PATCH] Use sabnzbd.__version__ consistently --- sabnzbd/getipaddress.py | 2 +- sabnzbd/interface.py | 2 +- sabnzbd/misc.py | 2 +- sabnzbd/rating.py | 2 +- sabnzbd/rss.py | 2 +- sabnzbd/urlgrabber.py | 2 +- tests/test_urlgrabber.py | 4 +--- 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sabnzbd/getipaddress.py b/sabnzbd/getipaddress.py index 2bcf15d..2213285 100644 --- a/sabnzbd/getipaddress.py +++ b/sabnzbd/getipaddress.py @@ -97,7 +97,7 @@ def publicipv4(): # put the selftest_host's IPv4 address into the URL req = urllib.request.Request("http://" + selftest_ipv4 + "/") # specify the User-Agent, because certain sites refuse connections with "python urllib2" as User-Agent: - req.add_header("User-Agent", "SABnzbd/%s" % sabnzbd.version.__version__) + req.add_header("User-Agent", "SABnzbd/%s" % sabnzbd.__version__) # specify the Host, because we only provide the IPv4 address in the URL: req.add_header("Host", sabnzbd.cfg.selftest_host()) # get the response, timeout 2 seconds, in case the website is not accessible diff --git a/sabnzbd/interface.py b/sabnzbd/interface.py index 169d2fe..c1c1346 100644 --- a/sabnzbd/interface.py +++ b/sabnzbd/interface.py @@ -1113,7 +1113,7 @@ class ConfigPage: conf = build_header(sabnzbd.WEB_DIR_CONFIG) conf["configfn"] = clip_path(config.get_filename()) conf["cmdline"] = sabnzbd.CMDLINE - conf["build"] = sabnzbd.version.__baseline__[:7] + conf["build"] = sabnzbd.__baseline__[:7] conf["have_unzip"] = bool(sabnzbd.newsunpack.ZIP_COMMAND) conf["have_7zip"] = bool(sabnzbd.newsunpack.SEVEN_COMMAND) diff --git a/sabnzbd/misc.py b/sabnzbd/misc.py index 7bfc27a..09d68de 100644 --- a/sabnzbd/misc.py +++ b/sabnzbd/misc.py @@ -333,7 +333,7 @@ def get_from_url(url): """ Retrieve URL and return content """ try: req = urllib.request.Request(url) - req.add_header("User-Agent", "SABnzbd/%s" % sabnzbd.version.__version__) + req.add_header("User-Agent", "SABnzbd/%s" % sabnzbd.__version__) with urllib.request.urlopen(req) as response: return ubtou(response.read()) except: diff --git a/sabnzbd/rating.py b/sabnzbd/rating.py index 67b80fe..ad16c8f 100644 --- a/sabnzbd/rating.py +++ b/sabnzbd/rating.py @@ -290,7 +290,7 @@ class Rating(Thread): requests = [] _headers = { - "User-agent": "SABnzbd+/%s" % sabnzbd.version.__version__, + "User-agent": "SABnzbd/%s" % sabnzbd.__version__, "Content-type": "application/x-www-form-urlencoded", } rating = self._get_rating_by_indexer( diff --git a/sabnzbd/rss.py b/sabnzbd/rss.py index 7d4e110..6472694 100644 --- a/sabnzbd/rss.py +++ b/sabnzbd/rss.py @@ -274,7 +274,7 @@ class RSSQueue: first = (feed not in self.jobs) and ignoreFirst # Add SABnzbd's custom User Agent - feedparser.USER_AGENT = "SABnzbd+/%s" % sabnzbd.version.__version__ + feedparser.USER_AGENT = "SABnzbd/%s" % sabnzbd.__version__ # Read the RSS feed msg = None diff --git a/sabnzbd/urlgrabber.py b/sabnzbd/urlgrabber.py index f881e27..261e3cd 100644 --- a/sabnzbd/urlgrabber.py +++ b/sabnzbd/urlgrabber.py @@ -348,7 +348,7 @@ def _build_request(url): req = urllib.request.Request(url) # Add headers - req.add_header("User-Agent", "SABnzbd/%s" % sabnzbd.version.__version__) + req.add_header("User-Agent", "SABnzbd/%s" % sabnzbd.__version__) req.add_header("Accept-encoding", "gzip") if user_passwd: req.add_header("Authorization", "Basic " + ubtou(base64.b64encode(utob(user_passwd))).strip()) diff --git a/tests/test_urlgrabber.py b/tests/test_urlgrabber.py index 32cadef..0734ef3 100644 --- a/tests/test_urlgrabber.py +++ b/tests/test_urlgrabber.py @@ -95,9 +95,7 @@ class TestBuildRequest: def test_user_agent(self): # Verify the User-Agent string - assert ("SABnzbd+/%s" % sabnzbd.version.__version__) in self._runner( - self.httpbin.url + "/user-agent", 200, True - ) + assert ("SABnzbd/%s" % sabnzbd.__version__) in self._runner(self.httpbin.url + "/user-agent", 200, True) def test_http_userpass(self): usr = "abcdefghijklm01234"