当前位置: 首页>>代码示例>>Python>>正文


Python QNetworkProxy.setUser方法代码示例

本文整理汇总了Python中PyQt4.QtNetwork.QNetworkProxy.setUser方法的典型用法代码示例。如果您正苦于以下问题:Python QNetworkProxy.setUser方法的具体用法?Python QNetworkProxy.setUser怎么用?Python QNetworkProxy.setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtNetwork.QNetworkProxy的用法示例。


在下文中一共展示了QNetworkProxy.setUser方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_proxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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
开发者ID:CharlesRethman,项目名称:inasafe,代码行数:27,代码来源:proxy.py

示例2: set_proxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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()
开发者ID:picklingjar,项目名称:spynner,代码行数:30,代码来源:browser.py

示例3: configureProxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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)
开发者ID:handloomweaver,项目名称:Ghost.py,代码行数:27,代码来源:NetworkAccessManager.py

示例4: get_proxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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
开发者ID:YassineGIS,项目名称:OSMData,代码行数:37,代码来源:operating_system.py

示例5: configure_proxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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)
开发者ID:iddqdidkfa,项目名称:scudcloud,代码行数:11,代码来源:wrapper.py

示例6: setTempProxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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)
开发者ID:kumaran-5555,项目名称:Webscrapping,代码行数:13,代码来源:webkitBrowser.py

示例7: _set_proxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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))
开发者ID:BryanSchacht,项目名称:nuxeo-drive,代码行数:16,代码来源:dialog.py

示例8: prox

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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)
开发者ID:leodarengosse,项目名称:GeoIGN,代码行数:34,代码来源:geo_ign.py

示例9: applySettings

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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)
开发者ID:bodil,项目名称:feedlol,代码行数:18,代码来源:SettingsDialog.py

示例10: get_proxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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
开发者ID:kartoza,项目名称:sg-diagram-downloader,代码行数:46,代码来源:proxy.py

示例11: configure_proxy

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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);
开发者ID:benslawski,项目名称:jimmy_jr,代码行数:21,代码来源:browser.py

示例12: __init__

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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()
开发者ID:bodil,项目名称:feedlol,代码行数:80,代码来源:FeedLol.py

示例13: QCoreApplication

# 需要导入模块: from PyQt4.QtNetwork import QNetworkProxy [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkProxy import setUser [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_())

开发者ID:Governa,项目名称:Camelot,代码行数:31,代码来源:http_proxy.py


注:本文中的PyQt4.QtNetwork.QNetworkProxy.setUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。