From e8fd6922a0dfd98b8cf85d7a7834e353d1c6ace1 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 4 Jun 2009 17:42:45 +0900 Subject: [PATCH] patches from richard: fix typo, more robust proxy error checking --- ankiqt/ui/getshared.py | 19 ++++++++++++++++++- ankiqt/ui/main.py | 4 +++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ankiqt/ui/getshared.py b/ankiqt/ui/getshared.py index 6379d95bd..d1300d024 100644 --- a/ankiqt/ui/getshared.py +++ b/ankiqt/ui/getshared.py @@ -71,8 +71,25 @@ class GetShared(QDialog): self.parent.setProgressParent(None) self.form.search.setFocus() if err: + errorString = self.http.errorString() + else: + # double check ... make sure http status code was valid + # this is to counter bugs in handling proxy responses + respHeader = self.http.lastResponse() + if respHeader.isValid(): + statusCode = respHeader.statusCode() + if statusCode < 200 or statusCode >= 300: + err = True + errorString = respHeader.reasonPhrase() + else: + err = True + errorString = "Invalid HTTP header received!" + + if err: + if self.parent.config['proxyHost']: + errorString += "\n" + _("Please check the proxy settings.") showInfo(_("Unable to connect to server.") + "\n" + - self.http.errorString(), parent=self) + errorString, parent=self) self.close() return data = self.http.readAll() diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 3a75a7716..36c00ec35 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -1956,6 +1956,8 @@ it to your friends. msg = _("""\

Sync Failed

Couldn't contact Anki Online. Please check your internet connection.""") + if self.config['proxyHost']: + msg += _(" Also check your proxy settings.") if self.config['syncInMsgBox']: ui.utils.showWarning(msg) else: @@ -2592,7 +2594,7 @@ Consider backing up your media directory first.""")) proxy.setPort(self.config['proxyPort']) if self.config['proxyUser']: proxy.setUser(self.config['proxyUser']) - proxy.setPass(self.config['proxyPass']) + proxy.setPassword(self.config['proxyPass']) QNetworkProxy.setApplicationProxy(proxy) # python proxy = "http://"