From cf7ed9ea2fa183b8e3cd4010a30eadf2a9f485d0 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 22 May 2012 14:14:59 +0900 Subject: [PATCH] handle proxy config in libanki --- aqt/preferences.py | 2 -- aqt/profiles.py | 45 ----------------------------------------- designer/preferences.ui | 38 ---------------------------------- 3 files changed, 85 deletions(-) diff --git a/aqt/preferences.py b/aqt/preferences.py index ee6060c5c..8da5e0174 100644 --- a/aqt/preferences.py +++ b/aqt/preferences.py @@ -85,7 +85,6 @@ class Preferences(QDialog): else: self.connect(self.form.syncDeauth, SIGNAL("clicked()"), self.onSyncDeauth) - self.form.proxyHost.setText(self.prof['proxyHost']) def _hideAuth(self): self.form.syncDeauth.setShown(False) @@ -100,7 +99,6 @@ Not currently enabled; click the sync button in the main window to enable.""")) def updateNetwork(self): self.prof['autoSync'] = self.form.syncOnProgramOpen.isChecked() self.prof['syncMedia'] = self.form.syncMedia.isChecked() - self.prof['proxyHost'] = unicode(self.form.proxyHost.text()) # Backup ###################################################################### diff --git a/aqt/profiles.py b/aqt/profiles.py index 27f0f8c4f..3cb50abf2 100644 --- a/aqt/profiles.py +++ b/aqt/profiles.py @@ -12,7 +12,6 @@ from anki.db import DB from anki.utils import isMac, isWin, intTime, checksum from anki.lang import langs from aqt.utils import showWarning, fontForPlatform -from httplib2 import ProxyInfo import anki.sync import aqt.forms @@ -53,8 +52,6 @@ profileConf = dict( syncKey=None, syncMedia=True, autoSync=True, - proxyHost='', # despite the name, stores full URL - proxyType=3, ) class ProfileManager(object): @@ -139,7 +136,6 @@ computer.""")) if name != "_global": self.name = name self.profile = prof - self.setupProxy() return True def save(self): @@ -285,44 +281,3 @@ create table if not exists profiles sql = "update profiles set data = ? where name = ?" self.db.execute(sql, cPickle.dumps(self.meta), "_global") self.db.commit() - - # Proxy handling - ###################################################################### - - def setupProxy(self): - prof = self.profile - # export proxy settings - if prof['proxyHost'] == "off": - # force off; override environment - anki.sync.HTTP_PROXY = None - elif prof['proxyHost']: - url = prof['proxyHost'] - anki.sync.HTTP_PROXY = ProxyInfo.from_url( - url, self.proxyMethod(url)) - else: - # set in env? - p = ProxyInfo.from_environment() - if not p: - # platform-specific fetch - url = None - if isWin: - r = urllib.getproxies_registry() - if 'https' in r: - url = r['https'] - elif 'http' in r: - url = r['http'] - elif isMac: - r = urllib.getproxies_macosx_sysconf() - if 'https' in r: - url = r['https'] - elif 'http' in r: - url = r['http'] - if url: - p = ProxyInfo.from_url(url, self.proxyMethod(url)) - anki.sync.HTTP_PROXY = p - - def proxyMethod(self, url): - if url.lower().startswith("https"): - return "https" - else: - return "http" diff --git a/designer/preferences.ui b/designer/preferences.ui index 4d22dbeef..8d161a721 100644 --- a/designer/preferences.ui +++ b/designer/preferences.ui @@ -248,33 +248,6 @@ - - - - <b>Proxy</b><br>If your system needs a proxy to access the internet, enter your details below. - - - true - - - - - - - 6 - - - - - URL - - - - - - - - @@ -288,16 +261,6 @@ - - - - Some settings will take effect after you restart Anki. - - - Qt::AlignCenter - - - @@ -435,7 +398,6 @@ syncMedia syncOnProgramOpen syncDeauth - proxyHost numBackups buttonBox tabWidget