--- a/WebBrowser/SafeBrowsing/SafeBrowsingManager.py Wed Apr 11 19:57:23 2018 +0200 +++ b/WebBrowser/SafeBrowsing/SafeBrowsingManager.py Thu Apr 12 19:12:36 2018 +0200 @@ -260,7 +260,10 @@ threatListsForRemove = {} for threatList, _clientState in self.__cache.getThreatLists(): threatListsForRemove[repr(threatList)] = threatList - threatLists = self.__apiClient.getThreatLists() + threatLists, error = self.__apiClient.getThreatLists() + if error: + return False, error + maximum = len(threatLists) current = 0 self.progressMessage.emit(self.tr("Updating threat lists"), maximum) @@ -292,8 +295,11 @@ clientStates = {} for threatList, clientState in threatLists: clientStates[threatList.asTuple()] = clientState - threatsUpdateResponses = \ + threatsUpdateResponses, error = \ self.__apiClient.getThreatsUpdate(clientStates) + if error: + return False, error + maximum = len(threatsUpdateResponses) current = 0 self.progressMessage.emit(self.tr("Updating hash prefixes"), maximum) @@ -379,11 +385,11 @@ @param url URL to be checked @type str or QUrl - @return list of threat lists the URL was found in - @rtype list of ThreatList + @return tuple containing the list of threat lists the URL was found in + and an error message + @rtype tuple of (list of ThreatList, str) @exception ValueError raised for an invalid URL """ - # TODO: extend to return error string in case of issues if self.isEnabled(): if self.__useLookupApi: if isinstance(url, str): @@ -392,9 +398,9 @@ if url.isEmpty(): raise ValueError("Empty URL given.") - listNames = self.__apiClient.lookupUrl(url, self.__platforms) - if listNames: - return listNames + listNames, error = \ + self.__apiClient.lookupUrl(url, self.__platforms) + return listNames, error else: if isinstance(url, QUrl): urlStr = url.toString().strip() @@ -406,10 +412,10 @@ urlHashes = SafeBrowsingUrl(urlStr).hashes() listNames = self.__lookupHashes(urlHashes) - if listNames: - return listNames + + return listNames, "" - return None + return None, "" def __lookupHashes(self, fullHashes): """