From 47938cf5c2619c9f3a826af4abf54a51f0414aa3 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 13 Apr 2016 10:48:45 +0200 Subject: [PATCH] DoUtils: use authenticate instead of dontSignout --- resources/lib/PlexAPI.py | 3 +-- resources/lib/PlexFunctions.py | 3 +-- resources/lib/downloadutils.py | 12 ++++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 5b01ad5e..bd46c793 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -291,8 +291,7 @@ class PlexAPI(): answer = self.doUtils(url, authenticate=False, headerOptions=headerOptions, - verifySSL=verifySSL, - dontSignout=True) + verifySSL=verifySSL) if answer is False: self.logMsg("Could not connect to %s" % url, 0) count += 1 diff --git a/resources/lib/PlexFunctions.py b/resources/lib/PlexFunctions.py index 0a549981..35dc794e 100644 --- a/resources/lib/PlexFunctions.py +++ b/resources/lib/PlexFunctions.py @@ -421,8 +421,7 @@ def PMSHttpsEnabled(url): doUtils = downloadutils.DownloadUtils().downloadUrl res = doUtils('https://%s/identity' % url, authenticate=False, - verifySSL=False, - dontSignout=True) + verifySSL=False) try: res.attrib except: diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index bdb1cabb..bc558843 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -145,8 +145,7 @@ class DownloadUtils(): return r def downloadUrl(self, url, type="GET", postBody=None, parameters=None, - authenticate=True, headerOptions=None, verifySSL=True, - dontSignout=False): + authenticate=True, headerOptions=None, verifySSL=True): """ Override SSL check with verifySSL=False @@ -200,7 +199,7 @@ class DownloadUtils(): # THE EXCEPTIONS except requests.exceptions.ConnectionError as e: # Connection error - if dontSignout is False: + if authenticate is False: self.logMsg("Server unreachable at: %s" % url, -1) self.logMsg(e, 2) # Make the addon aware of status @@ -233,6 +232,11 @@ class DownloadUtils(): self.logMsg(e, 2) return False + except requests.exceptions.TooManyRedirects as e: + self.logMsg("Too many redirects connecting to: %s" % url, -1) + self.logMsg(e, 2) + return False + except requests.exceptions.RequestException as e: self.logMsg("Unknown error connecting to: %s" % url, -1) self.logMsg("Error message: %s" % e, 2) @@ -255,7 +259,7 @@ class DownloadUtils(): return True elif r.status_code == 401: - if dontSignout is True: + if authenticate is False: # Called when checking a connect - no need for rash action return 401 r.encoding = 'utf-8'