本文整理汇总了Python中PyQt4.QtNetwork.QNetworkProxy.setPassword方法的典型用法代码示例。如果您正苦于以下问题:Python QNetworkProxy.setPassword方法的具体用法?Python QNetworkProxy.setPassword怎么用?Python QNetworkProxy.setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtNetwork.QNetworkProxy
的用法示例。
在下文中一共展示了QNetworkProxy.setPassword方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_proxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def get_proxy():
"""Adaption by source of Plugin Installer - Version 1.0.10"""
settings = QSettings()
settings.beginGroup("proxy")
if settings.value("/proxyEnabled", False, type=bool):
proxy = QNetworkProxy()
proxyType = settings.value("/proxyType", 0, type=int)
if proxyType in ["1", "Socks5Proxy"]:
proxy.setType(QNetworkProxy.Socks5Proxy)
elif proxyType in ["2", "NoProxy"]:
proxy.setType(QNetworkProxy.NoProxy)
elif proxyType in ["3", "HttpProxy"]:
proxy.setType(QNetworkProxy.HttpProxy)
elif proxyType in ["4", "HttpCachingProxy"] and QT_VERSION >= 0X040400:
proxy.setType(QNetworkProxy.HttpCachingProxy)
elif proxyType in ["5", "FtpCachingProxy"] and QT_VERSION >= 0X040400:
proxy.setType(QNetworkProxy.FtpCachingProxy)
else:
proxy.setType(QNetworkProxy.DefaultProxy)
proxy.setHostName(settings.value("/proxyHost"))
proxy.setPort(settings.value("/proxyPort", type=int))
proxy.setUser(settings.value("/proxyUser"))
proxy.setPassword(settings.value("/proxyPassword"))
settings.endGroup()
return proxy
示例2: set_proxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def set_proxy(self, string_proxy):
"""Set proxy [http|socks5]://username:[email protected]:port"""
urlinfo = urlparse.urlparse(string_proxy)
proxy = QNetworkProxy()
if urlinfo.scheme == 'socks5' :
proxy.setType(1)
elif urlinfo.scheme == 'http' :
proxy.setType(3)
else :
proxy.setType(2)
self.manager.setProxy(proxy)
return self.manager.proxy()
proxy.setHostName(urlinfo.hostname)
proxy.setPort(urlinfo.port)
if urlinfo.username != None :
proxy.setUser(urlinfo.username)
else :
proxy.setUser('')
if urlinfo.password != None :
proxy.setPassword(urlinfo.password)
else :
proxy.setPassword('')
self.manager.setProxy(proxy)
return self.manager.proxy()
示例3: configureProxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def configureProxy(self, host, port, user=None, password=None):
"""Add a proxy configuration for the Network Requests.
:param host: the proxy host
:param port: the proxy port
:param user: if the proxy has authentication this param sets
the user to be used. It should be None if it's not required to
access with a user
:param password: if the proxy has authentication this param sets
the password to be used. It should be None if it's not required to
access with a password
"""
proxy = QNetworkProxy()
proxy.setType(QNetworkProxy.HttpProxy)
proxy.setHostName(host)
proxy.setPort(port)
if user is not None:
proxy.setUser(user)
if password is not None:
proxy.setPassword(password)
self._proxyAuth = (user, password)
self.setProxy(proxy)
示例4: get_proxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def get_proxy():
"""
Get a proxy according to QSettings
@return: proxy
@rtype: QNetworkProxy
"""
s = QSettings()
if s.value('proxy/proxyEnabled', '') == 'true':
proxy_type = s.value('proxy/proxyType', '')
proxy_host = s.value('proxy/proxyHost', '')
proxy_port = s.value('proxy/proxyPort', '')
proxy_user = s.value('proxy/proxyUser', '')
proxy_password = s.value('proxy/proxyPassword', '')
proxy = QNetworkProxy()
if proxy_type == 'DefaultProxy':
proxy.setType(QNetworkProxy.DefaultProxy)
elif proxy_type == 'Socks5Proxy':
proxy.setType(QNetworkProxy.Socks5Proxy)
elif proxy_type == 'HttpProxy':
proxy.setType(QNetworkProxy.HttpProxy)
elif proxy_type == 'HttpCachingProxy':
proxy.setType(QNetworkProxy.HttpCachingProxy)
elif proxy_type == 'FtpCachingProxy':
proxy.setType(QNetworkProxy.FtpCachingProxy)
proxy.setHostName(proxy_host)
proxy.setPort(int(proxy_port))
proxy.setUser(proxy_user)
proxy.setPassword(proxy_password)
return proxy
else:
return None
示例5: configure_proxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def configure_proxy(self):
proxy = urlparse(os.environ.get('http_proxy') or os.environ.get('HTTP_PROXY'))
if proxy.hostname is not None and proxy.port is not None:
q_network_proxy = QNetworkProxy(QNetworkProxy.HttpProxy, proxy.hostname, proxy.port)
if proxy.username is not None:
q_network_proxy.setUser(proxy.username)
if proxy.password is not None:
q_network_proxy.setPassword(proxy.password)
QNetworkProxy.setApplicationProxy(q_network_proxy)
示例6: setTempProxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def setTempProxy(self, host, port=None, username=None, password=None):
proxy = QNetworkProxy()
proxy.setType(QNetworkProxy.HttpProxy)
if username:
proxy.setUser(username)
if password:
proxy.setPassword(password)
if port:
proxy.setPort(port)
proxy.setHostName(host)
self.page().networkAccessManager().setProxy(proxy)
示例7: _set_proxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def _set_proxy(self, manager):
proxy_settings = manager.get_proxy_settings()
if proxy_settings.config == 'Manual':
if proxy_settings.server and proxy_settings.port:
proxy = QNetworkProxy(QNetworkProxy.HttpProxy, hostName=proxy_settings.server,
port=int(proxy_settings.port))
if proxy_settings.authenticated:
proxy.setPassword(proxy_settings.password)
proxy.setUser(proxy_settings.username)
QNetworkProxy.setApplicationProxy(proxy)
elif proxy_settings.config == 'System':
QNetworkProxyFactory.setUseSystemConfiguration(True)
else:
QNetworkProxy.setApplicationProxy(QNetworkProxy(QNetworkProxy.NoProxy))
示例8: prox
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def prox(self,mode,user,password,host,port):
proxy = QNetworkProxy()
if mode == "DefaultProxy":
proxy.setType(QNetworkProxy.DefaultProxy)
elif mode == "Socks5Proxy":
proxy.setType(QNetworkProxy.Socks5Proxy)
proxy.setHostName(host)
proxy.setPort(int(port))
proxy.setUser(self.usern)
proxy.setPassword(self.passw)
QNetworkProxy.setApplicationProxy(proxy)
elif mode == "HttpProxy":
proxy.setType(QNetworkProxy.HttpProxy)
proxy.setHostName(host)
proxy.setPort(int(port))
proxy.setUser(self.usern)
proxy.setPassword(self.passw)
QNetworkProxy.setApplicationProxy(proxy)
elif mode == "HttpCachingProxy":
proxy.setType(QNetworkProxy.HttpCachingProxy)
proxy.setHostName(host)
proxy.setPort(int(port))
proxy.setUser(self.usern)
proxy.setPassword(self.passw)
QNetworkProxy.setApplicationProxy(proxy)
elif mode == "FtpCachingProxy":
proxy.setType(QNetworkProxy.FtpCachingProxy)
proxy.setHostName(host)
proxy.setPort(int(port))
proxy.setUser(self.usern)
proxy.setPassword(self.passw)
QNetworkProxy.setApplicationProxy(proxy)
示例9: applySettings
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def applySettings(self):
if self.feedView.siteServer.session.user != str(self.ffNickname.text()) or self.feedView.siteServer.session.remoteKey != str(self.ffRemoteKey.text()):
self.feedView.siteServer.session.user = str(self.ffNickname.text())
self.feedView.siteServer.session.remoteKey = str(self.ffRemoteKey.text())
self.feedView.goHome()
proxy = QNetworkProxy()
proxyType = self.proxyType.currentIndex()
proxy.setType( (proxyType == 2) and QNetworkProxy.Socks5Proxy or ( (proxyType == 1) and QNetworkProxy.HttpProxy or QNetworkProxy.NoProxy ) )
if proxyType:
proxy.setHostName(self.proxyHost.text())
proxy.setPort(self.proxyPort.value())
if self.proxyAuth.checkState() == Qt.Checked:
proxy.setUser(self.proxyAuthUser.text())
proxy.setPassword(self.proxyAuthPassword.text())
QNetworkProxy.setApplicationProxy(proxy)
示例10: get_proxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def get_proxy():
"""Adaption by source of Plugin Installer - Version 1.0.10
:returns: Get proxy that currently used.
:rtype: QNetworkProxy
"""
settings = QSettings()
settings.beginGroup('proxy')
enabled = settings.value('/proxyEnabled', False, type=bool)
if not enabled:
return None
proxy = QNetworkProxy()
try:
proxy_type = settings.value('/proxyType', 0, type=int)
except TypeError:
# Catch for this:
# TypeError: unable to convert a QVariant of type 10 to a
# QMetaType of type 2
# TODO: can we do anything to handle this more gracefully? TS
settings.setValue('/proxyType', 0)
return proxy
if proxy_type in ['1', 'Socks5Proxy']:
proxy.setType(QNetworkProxy.Socks5Proxy)
elif proxy_type in ['2', 'NoProxy']:
proxy.setType(QNetworkProxy.NoProxy)
elif proxy_type in ['3', 'HttpProxy']:
proxy.setType(QNetworkProxy.HttpProxy)
elif proxy_type in ['4', 'HttpCachingProxy'] and QT_VERSION >= 0X040400:
proxy.setType(QNetworkProxy.HttpCachingProxy)
elif proxy_type in ['5', 'FtpCachingProxy'] and QT_VERSION >= 0X040400:
proxy.setType(QNetworkProxy.FtpCachingProxy)
else:
proxy.setType(QNetworkProxy.DefaultProxy)
proxy.setHostName(settings.value('/proxyHost'))
proxy.setPort(settings.value('/proxyPort', type=int))
user = settings.value('/proxyUser', type=str)
password = settings.value('/proxyPassword', type=str)
if user is not None:
proxy.setUser(user)
if password is not None and user is not None:
proxy.setPassword(password)
settings.endGroup()
return proxy
示例11: configure_proxy
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def configure_proxy(cls, hostname, port, user=None, password=None,
proxy_type=QNetworkProxy.HttpProxy):
"""
Configure network proxy layer.
@param proxy_type: see QNetworkProxy.ProxyType. Default: HttpProxy.
@param hostname: Proxy hostname.
@param port: Proxy port.
@param username: Proxy username (optional).
@param passwrod: Proxy password (optional).
"""
proxy = QNetworkProxy()
proxy.setType(proxy_type)
proxy.setHostName(hostname)
proxy.setPort(port)
if user and password is not None:
proxy.setUser(user)
proxy.setPassword(password)
QNetworkProxy.setApplicationProxy(proxy);
示例12: __init__
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
def __init__(self, parent = None):
QMainWindow.__init__(self, parent)
self.setWindowTitle("FeedLol")
self.aboutAction = QAction(QIcon("data/icons/help-about.svg"), "&About FeedLol...", self)
self.connect(self.aboutAction, SIGNAL("triggered()"), self.slotAbout)
self.reloadAction = QAction(QIcon("data/icons/view-refresh.svg"), "&Reload", self)
self.reloadAction.setShortcut(QKeySequence.Refresh)
self.homeAction = QAction(QIcon("data/icons/go-home.svg"), "Go &Home", self)
self.homeAction.setShortcut("Alt+Home")
self.userAction = QAction(QIcon("data/icons/user-identity.svg"), "&Me", self)
self.userAction.setShortcut("Ctrl+M")
self.logoutAction = QAction(QIcon("data/icons/dialog-close.svg"), "Log&out", self)
self.logoutAction.setShortcut(QKeySequence.Close)
self.settingsAction = QAction(QIcon("data/icons/configure.svg"), "&Preferences...", self)
self.connect(self.settingsAction, SIGNAL("triggered()"), self.slotSettings)
self.toolbar = QToolBar("Toolbar", self)
self.toolbar.setObjectName("toolbar")
self.toolbar.addAction(self.homeAction)
self.toolbar.addAction(self.userAction)
self.toolbar.addAction(self.reloadAction)
self.toolbar.addSeparator()
self.toolbar.addAction(self.logoutAction)
self.toolbar.addSeparator()
self.toolbar.addAction(self.settingsAction)
self.toolbar.addAction(self.aboutAction)
self.addToolBar(self.toolbar)
self.loadStatus = QProgressBar(self)
self.loadStatus.setRange(0, 100)
self.loadStatus.setMaximumWidth(200)
self.loadStatus.setTextVisible(False)
self.loadStatus.hide()
self.statusBar().addPermanentWidget(self.loadStatus)
self.feedView = FeedView(self)
self.setCentralWidget(self.feedView)
self.connect(self.feedView, SIGNAL("titleChanged(const QString&)"), self.slotSetTitle)
self.connect(self.feedView, SIGNAL("statusBarMessage(const QString&)"), self.statusBar(), SLOT("showMessage(const QString&)"))
self.connect(self.feedView, SIGNAL("loadStarted()"), self.loadStart)
self.connect(self.feedView, SIGNAL("loadFinished(bool)"), self.loadStop)
self.connect(self.feedView, SIGNAL("loadProgress(int)"), self.loadProgress)
self.connect(self.reloadAction, SIGNAL("triggered()"), self.feedView.reload)
self.connect(self.homeAction, SIGNAL("triggered()"), self.feedView.goHome)
self.connect(self.userAction, SIGNAL("triggered()"), self.feedView.goToUserPage)
self.connect(self.logoutAction, SIGNAL("triggered()"), self.feedView.logout)
self.connect(self.feedView.page(), SIGNAL("linkHovered(const QString&, const QString&, const QString&)"), self.linkHovered)
self.settingsDialog = SettingsDialog(self.feedView, self)
settings = QSettings()
if settings.contains("proxy/type"):
proxy = QNetworkProxy()
proxyType = settings.value("proxy/type").toInt()[0]
proxy.setType( (proxyType == 2) and QNetworkProxy.Socks5Proxy or ( (proxyType == 1) and QNetworkProxy.HttpProxy or QNetworkProxy.NoProxy ) )
if proxy.type() != QNetworkProxy.NoProxy:
proxy.setHostName(settings.value("proxy/host").toString())
proxy.setPort(settings.value("proxy/port").toInt()[0])
if settings.value("proxy/user").toString():
proxy.setUser(settings.value("proxy/user").toString())
proxy.setPassword(settings.value("proxy/password").toString())
QNetworkProxy.setApplicationProxy(proxy)
if settings.contains("mainWindow/geometry"):
self.restoreGeometry(settings.value("mainWindow/geometry").toByteArray())
else:
self.resize(320,480)
if settings.contains("mainWindow/state"):
self.restoreState(settings.value("mainWindow/state").toByteArray())
self.feedView.goHome()
示例13: QCoreApplication
# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setPassword [as 别名]
if proxy_socket.error() != QTcpSocket.RemoteHostClosedError:
url = proxy_socket.property('url').toUrl()
error_string = proxy_socket.errorString()
if self.debug:
self.log.write('Error for %s %s\n\n' % (url, error_string))
proxy_socket.deleteLater()
if __name__ == '__main__':
app = QCoreApplication(sys.argv)
server = HTTPProxy()
manager = QNetworkAccessManager()
manager.finished.connect(server.stopServing)
manager.finished.connect(app.quit)
proxy = QNetworkProxy()
proxy.setType(QNetworkProxy.HttpProxy)
proxy.setHostName('127.0.0.1')
proxy.setPort(server.port())
proxy.setUser(server.username)
proxy.setPassword(server.password)
manager.setProxy(proxy)
reply = manager.get(QNetworkRequest(QUrl('http://aws.amazon.com/')))
sys.exit(app.exec_())