comparison feedworm.py @ 194:2c91b5653878

enable/disable using the proxy via a preference setting
author dirk
date Fri, 07 Oct 2011 07:00:44 +0200
parents 5b131f82057d
children 66d1efcb8e8a
comparison
equal deleted inserted replaced
193:c345a26febc2 194:2c91b5653878
5 import BackendFactory 5 import BackendFactory
6 import logging 6 import logging
7 import sys 7 import sys
8 8
9 def setupProxy(preferences): 9 def setupProxy(preferences):
10 if preferences.isProxyConfigured(): 10 if preferences.isProxyConfigured() and preferences.useProxy():
11 proxyHost = preferences.proxyHost() 11 proxyHost = preferences.proxyHost()
12 proxyPort = preferences.proxyPort() 12 proxyPort = preferences.proxyPort()
13 proxy = QNetworkProxy(QNetworkProxy.HttpProxy, proxyHost, proxyPort) 13 proxy = QNetworkProxy(QNetworkProxy.HttpProxy, proxyHost, proxyPort)
14 QNetworkProxy.setApplicationProxy(proxy) 14 QNetworkProxy.setApplicationProxy(proxy)
15 15
16 if __name__ == '__main__': 16 if __name__ == '__main__':
17 logging.basicConfig(level=logging.DEBUG) 17 logging.basicConfig(level=logging.DEBUG)
18 backend = BackendFactory.createBackend() 18 backend = BackendFactory.createBackend()
19 preferences = backend.preferences() 19 preferences = backend.preferences()
20 setupProxy(preferences) 20 setupProxy(preferences)