本文整理汇总了Python中PyQt4.QtNetwork.QNetworkProxy.applicationProxy方法的典型用法代码示例。如果您正苦于以下问题:Python QNetworkProxy.applicationProxy方法的具体用法?Python QNetworkProxy.applicationProxy怎么用?Python QNetworkProxy.applicationProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtNetwork.QNetworkProxy
的用法示例。
在下文中一共展示了QNetworkProxy.applicationProxy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: request
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import applicationProxy [as 别名]
def request(self, iri, method="GET", extra_headers=None,
oauth_credentials=None, post_content=None):
"""Return a deferred that will be fired with a Response object."""
uri = self.iri_to_uri(iri)
request = QNetworkRequest(QUrl(uri))
request.setSslConfiguration(self.ssl_config)
headers = yield self.build_request_headers(uri, method, extra_headers,
oauth_credentials)
for key, value in headers.items():
request.setRawHeader(key, value)
post_buffer = QBuffer()
post_buffer.setData(post_content)
try:
result = yield self._perform_request(request, method, post_buffer)
except ProxyUnauthorizedError as e:
app_proxy = QNetworkProxy.applicationProxy()
proxy_host = app_proxy.hostName() if app_proxy else "proxy server"
got_creds = yield self.request_proxy_auth_credentials(
proxy_host, self.proxy_retry)
if got_creds:
self.proxy_retry = True
result = yield self.request(iri, method, extra_headers,
oauth_credentials, post_content)
else:
excp = WebClientError('Proxy creds needed.', e)
defer.returnValue(excp)
defer.returnValue(result)
示例2: saveConfig
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import applicationProxy [as 别名]
def saveConfig(self):
settings = QSettings()
settings.setValue("mainWindow/geometry", QVariant(self.saveGeometry()))
settings.setValue("mainWindow/state", QVariant(self.saveState()))
session = self.feedView.siteServer.session
from cPickle import dumps
session = dumps(session)
settings.setValue("session", QVariant(session))
proxy = QNetworkProxy.applicationProxy()
proxyType = (proxy.type() == QNetworkProxy.Socks5Proxy) and 2 or ( (proxy.type() == QNetworkProxy.HttpProxy) and 1 or 0 )
settings.setValue("proxy/type", QVariant(proxyType))
settings.setValue("proxy/host", QVariant(proxy.hostName()))
settings.setValue("proxy/port", QVariant(proxy.port()))
settings.setValue("proxy/user", QVariant(proxy.user()))
settings.setValue("proxy/password", QVariant(proxy.password()))
示例3: updateSettings
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import applicationProxy [as 别名]
def updateSettings(self):
self.ffNickname.clear()
self.ffRemoteKey.clear()
if self.feedView.siteServer.session.user:
self.ffNickname.setText(self.feedView.siteServer.session.user)
if self.feedView.siteServer.session.remoteKey:
self.ffRemoteKey.setText(self.feedView.siteServer.session.remoteKey)
proxy = QNetworkProxy.applicationProxy()
self.proxyType.setCurrentIndex( (proxy.type() == QNetworkProxy.Socks5Proxy) and 2 or ( (proxy.type() == QNetworkProxy.HttpProxy) and 1 or 0 ) )
if self.proxyType.currentIndex() != 0:
self.proxyHost.setText(proxy.hostName())
self.proxyPort.setValue(proxy.port())
if proxy.user():
self.proxyAuth.setCheckState(Qt.Checked)
self.proxyAuthUser.setText(proxy.user())
self.proxyAuthPassword.setText(proxy.password())