mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
handle proxy config in libanki
This commit is contained in:
parent
d143a50358
commit
cf7ed9ea2f
3 changed files with 0 additions and 85 deletions
|
@ -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
|
||||
######################################################################
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -248,33 +248,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string><b>Proxy</b><br>If your system needs a proxy to access the internet, enter your details below.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="proxyHost"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@ -288,16 +261,6 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Some settings will take effect after you restart Anki.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
|
@ -435,7 +398,6 @@
|
|||
<tabstop>syncMedia</tabstop>
|
||||
<tabstop>syncOnProgramOpen</tabstop>
|
||||
<tabstop>syncDeauth</tabstop>
|
||||
<tabstop>proxyHost</tabstop>
|
||||
<tabstop>numBackups</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
|
|
Loading…
Reference in a new issue