本文整理汇总了Python中twisted.web.client.Agent.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Agent.__init__方法的具体用法?Python Agent.__init__怎么用?Python Agent.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.client.Agent
的用法示例。
在下文中一共展示了Agent.__init__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.web.client import Agent [as 别名]
# 或者: from twisted.web.client.Agent import __init__ [as 别名]
def __init__(self, uuid, token, cert_file, throttling=False):
self._uuid = uuid
self._token = None
self._creds = None
self.set_token(token)
factory = getPolicyForHTTPS(cert_file)
pool = self._get_pool()
_Agent.__init__(self, reactor, contextFactory=factory, pool=pool)
示例2: __init__
# 需要导入模块: from twisted.web.client import Agent [as 别名]
# 或者: from twisted.web.client.Agent import __init__ [as 别名]
def __init__(self, gerrit_host, *args, **kwargs):
url_parts = urlparse.urlparse(gerrit_host)
if url_parts.scheme:
self.gerrit_protocol = url_parts.scheme
self.gerrit_host = url_parts.netloc
auth_entry = NETRC.authenticators(self.gerrit_host.partition(':')[0])
if auth_entry:
self.auth_token = 'Basic %s' % (
base64.b64encode('%s:%s' % (auth_entry[0], auth_entry[2])))
else:
self.auth_token = None
Agent.__init__(self, reactor, *args, **kwargs)
示例3: __init__
# 需要导入模块: from twisted.web.client import Agent [as 别名]
# 或者: from twisted.web.client.Agent import __init__ [as 别名]
def __init__(self, reactor,
connectTimeout=None, bindAddress=None,
pool=None, torSocksHostname=None, torSocksPort=None, isolationMode=None):
"""
Create a L{TorAgent}.
@param reactor: A provider of
L{twisted.internet.interfaces.IReactorTCP}
to place outgoing connections.
@type reactor: L{twisted.internet.interfaces.IReactorTCP}.
@param connectTimeout: The amount of time that this L{Agent} will wait
for the peer to accept a connection.
@type connectTimeout: L{float}
@param bindAddress: The local address for client sockets to bind to.
@type bindAddress: L{bytes}
@param pool: An L{HTTPConnectionPool} instance, or C{None}, in which
case a non-persistent L{HTTPConnectionPool} instance will be
created.
@type pool: L{HTTPConnectionPool}
@param torSocksHostname: A C{str} giving the tor SOCKS hostname
that this TorAgent will use for outbound Tor connections.
@param torSocksPort: An C{int} giving the SOCKS port number that will be used
for outbound Tor connections.
@param isolationMode: A Tor circuit isolation mode:
- monoCircuit means always let tor process decide which circuit to use
- circuitPerAgent means always use one tor circuit per agent instance
"""
Agent.__init__(self, reactor,connectTimeout=None, bindAddress=None, pool=None)
self._connectTimeout = connectTimeout
self._bindAddress = bindAddress
self.torSocksHostname = torSocksHostname
self.torSocksPort = torSocksPort
if isolationMode in self.isolationModes:
self.isolationMode = isolationMode
if isolationMode == 'circuitPerAgent':
self.username, self.password = self._genRandomUserPass()
else:
raise TorAgentCircuitIsolationModeNotSupported("Unsupported mode: %r" % (isolationMode,))
示例4: __init__
# 需要导入模块: from twisted.web.client import Agent [as 别名]
# 或者: from twisted.web.client.Agent import __init__ [as 别名]
def __init__(self, *args, **kwargs):
Agent.__init__(self, *args, **kwargs)
示例5: __init__
# 需要导入模块: from twisted.web.client import Agent [as 别名]
# 或者: from twisted.web.client.Agent import __init__ [as 别名]
def __init__(self, reactor, path, **kwargs):
self.path = path
Agent.__init__(self, reactor, **kwargs)
示例6: __init__
# 需要导入模块: from twisted.web.client import Agent [as 别名]
# 或者: from twisted.web.client.Agent import __init__ [as 别名]
def __init__(self, reactor, contextFactory = WebClientContextFactory(),
connectTimeout = None, bindAddress = None):
Agent.__init__(self, reactor, contextFactory)
self._connectTimeout = connectTimeout
self._bindAddress = bindAddress