本文整理汇总了Python中suds.transport.http.HttpTransport类的典型用法代码示例。如果您正苦于以下问题:Python HttpTransport类的具体用法?Python HttpTransport怎么用?Python HttpTransport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HttpTransport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, **kwargs):
"""
@param kwargs: Keyword arguments.
- B{proxy} - An http proxy to be specified on requests.
The proxy is defined as {protocol:proxy,}
- type: I{dict}
- default: {}
- B{timeout} - Set the url open timeout (seconds).
- type: I{float}
- default: 90
- B{username} - The username used for http authentication.
- type: I{str}
- default: None
- B{password} - The password used for http authentication.
- type: I{str}
- default: None
- B{unverified_context} - Use an unverified context for the
connection, i.e. disabling HTTPS certificate validation.
- type: I{bool}
- default: False
"""
HttpTransport.__init__(self, **kwargs)
self.pm = urllib.request.HTTPPasswordMgrWithDefaultRealm()
if self.options.unverified_context:
import ssl
self.HTTPSHandler = urllib.request.HTTPSHandler(context=ssl._create_unverified_context())
else:
self.HTTPSHandler = urllib.request.HTTPSHandler()
开发者ID:ticosax,项目名称:suds-ng,代码行数:30,代码来源:https.py
示例2: auth
def auth(ver, type, username, password):
if ver == 2:
if type == 'up':
auth_client = Client(AUTH_URL_ver2, username = username, password = password) #version 2.0
SID = auth_client.service.authenticate()
return SID
elif type == 'ip':
auth_client = Client(AUTH_URL_ver2)
SID = auth_client.service.authenticate()
return SID
else:
print "Type either 'ip' or 'up'. 'ip' for ip access, 'up' for username/password access"
elif ver == 3:
if type == 'up':
username_password = ['username_password'][username]
#Your username/password from a purchased subscription should go here!
auth = HttpTransport()
auth_sender = urllib2.build_opener(HTTPAuthSender(username_password))
auth.urlopener = auth_sender
auth_client = Client(AUTH_URL_ver3, transport = auth)
SID = auth_client.service.authenticate()
return SID
elif type == 'ip':
auth_client = Client(AUTH_URL_ver3) #comment out if using username, password. #version 3.0
SID = auth_client.service.authenticate()
return SID
else:
print "Type either 'ip' or 'up'. 'ip' for ip access, 'up' for username/password access. username is an integer, password can be a null value for version 3."
else:
print "Authentication failed. Invalid version. Your request was not supported by this authentication module."
开发者ID:ahdoki,项目名称:tasters-choice,代码行数:31,代码来源:auth.py
示例3: search_lite
def search_lite(fieldtag, searchterm, ver, count, SID):
#fieldtag must be 'PN = ' or 'CD ='
http = HttpTransport()
opener = urllib2.build_opener(HTTPSudsPreprocessor(SID))
http.urlopener = opener
client_obj = Client(SEARCH_LITE_URL[int(ver - 2)], transport = http, retxml = True)
query = fieldtag + '=' + searchterm
#construct query and retrieve field parameters
qparams = {
'databaseId' : 'DIIDW',
'userQuery' : query,
'queryLanguage' : 'en',
'editions' : [{
'collection' : 'DIIDW',
'edition' : 'CDerwent',
},{
'collection' : 'DIIDW',
'edition' : 'MDerwent',
},{
'collection' : 'DIIDW',
'edition' : 'EDerwent',
}]
}
rparams = {
'count' : count, # 1-500
'firstRecord' : 1,
'sortField' : [{
'name' : 'TC',
'sort' : 'D',
}]
}
result = client_obj.service.search(qparams, rparams)
return result
开发者ID:ahdoki,项目名称:tasters-choice,代码行数:34,代码来源:search.py
示例4: __init__
def __init__(self, slug=None, session=None, related_objects=None, timeout=None):
self.related_objects = related_objects or ()
self.slug = slug
self.timeout = timeout
# super won't work because not using new style class
HttpTransport.__init__(self)
self._session = session or security_requests.SecuritySession()
开发者ID:matllubos,项目名称:django-security,代码行数:7,代码来源:security_suds.py
示例5: initSearchClient
def initSearchClient(self):
print 'initialize search....'
http = HttpTransport()
opener = urllib2.build_opener(HTTPSudsPreprocessor(self.SID))
http.urlopener = opener
self.client['search'] = Client(self.url['search'], transport = http)
print 'searching initializtion done'
开发者ID:cadop,项目名称:pyWOS,代码行数:7,代码来源:DownloadData.py
示例6: _add_sid
def _add_sid(self):
"""Create URL opener with authentication token as header."""
opener = urllib2.build_opener()
opener.addheaders = [('Cookie', 'SID="'+self.sid_token+'"')]
http = HttpTransport()
http.urlopener = opener
self._establish_search_client(http)
开发者ID:MSU-Libraries,项目名称:wos,代码行数:7,代码来源:wos.py
示例7: __init__
def __init__(self, key, cert, *args, **kwargs):
"""
@param key: full path for the client's private key file
@param cert: full path for the client's PEM certificate file
"""
HttpTransport.__init__(self, *args, **kwargs)
self.key = key
self.cert = cert
开发者ID:AlainRoy,项目名称:htcondor,代码行数:8,代码来源:https.py
示例8: __init__
def __init__(self, key, cert, *args, **kwargs):
"""
@param key: full path for the client's private key file
@param cert: full path for the client's PEM certificate file
"""
HttpTransport.__init__(self, *args, **kwargs)
self.key = key
self.cert = cert
self.urlopener = u2.build_opener(self._get_auth_handler())
开发者ID:ssorj,项目名称:boneyard,代码行数:9,代码来源:https.py
示例9: open
def open(self, request):
url = request.url
if url.startswith('file:'):
return HttpTransport.open(self, request)
else:
resp = self._session.get(url)
resp.raise_for_status()
return BytesIO(resp.content)
开发者ID:matllubos,项目名称:django-security,代码行数:8,代码来源:security_suds.py
示例10: u2handlers
def u2handlers(self):
try:
from ntlm import HTTPNtlmAuthHandler
except ImportError:
raise Exception("Cannot import python-ntlm module")
handlers = HttpTransport.u2handlers(self)
handlers.append(HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(self.pm))
return handlers
开发者ID:dilawar,项目名称:moose-gui,代码行数:8,代码来源:https.py
示例11: send
def send(self, request):
self.addcredentials(request)
r = XMLParser.parse(request.message.decode('ascii'))
data = dump_records(r)
request.message = data
request.headers['Content-Type'] = 'application/soap+msbin1'
# request.message = request.message()
return HttpTransport.send(self, request)
开发者ID:nettosama,项目名称:py-jmmclient,代码行数:8,代码来源:jmmclient.py
示例12: send
def send(self, request):
request.headers['Accept-encoding'] = 'gzip'
result = HttpTransport.send(self, request)
if ('content-encoding' in result.headers and
result.headers['content-encoding'] == 'gzip') :
buf = BytesIO(result.message)
f = gzip.GzipFile(fileobj=buf)
result.message = f.read()
return result
开发者ID:PlantFactory,项目名称:pyfiap,代码行数:9,代码来源:fiap.py
示例13: __init__
def __init__(self, **kwargs):
"""
@param kwargs: Keyword arguments.
- B{proxy} - An http proxy to be specified on requests.
The proxy is defined as {protocol:proxy,}
- type: I{dict}
- default: {}
- B{timeout} - Set the url open timeout (seconds).
- type: I{float}
- default: 90
- B{username} - The username used for http authentication.
- type: I{str}
- default: None
- B{password} - The password used for http authentication.
- type: I{str}
- default: None
"""
HttpTransport.__init__(self, **kwargs)
self.pm = u2.HTTPPasswordMgrWithDefaultRealm()
开发者ID:JasonSupena,项目名称:suds,代码行数:19,代码来源:https.py
示例14: search
def search(fieldtag, searchterm, ver, count, SID):
'''
Makes a search query to the database.
:param fieldtag: fieldtag must be 'PN = ' or 'CD ='
:param searchterm: search term. in this case, the patent number.
:param ver: version 2 or 3. refer to the thomson reuters documentation.
:param count: requested retrieval count.
:param SID: Session ID.
:return: output xml.
'''
http = HttpTransport()
opener = urllib2.build_opener(HTTPSudsPreprocessor(SID))
http.urlopener = opener
client_obj = Client(SEARCH_URL[int(ver - 2)], transport = http, retxml = True)
query = fieldtag + '=' + searchterm
#construct query and retrieve field parameters
qparams = {
'databaseId' : 'DIIDW',
'userQuery' : query,
'queryLanguage' : 'en',
'editions' : [{
'collection' : 'DIIDW',
'edition' : 'CDerwent',
},{
'collection' : 'DIIDW',
'edition' : 'MDerwent',
},{
'collection' : 'DIIDW',
'edition' : 'EDerwent',
}]
}
rparams = {
'count' : count, # 1-500
'firstRecord' : 1,
'sortField' : [{
'name' : 'Relevance',
'sort' : 'D',
}]
}
result = client_obj.service.search(qparams, rparams)
return result
开发者ID:ahdoki,项目名称:tasters-choice,代码行数:43,代码来源:search.py
示例15: send
def send(self, request):
request.headers['Accept-encoding'] = 'gzip'
result = HttpTransport.send(self, request)
if result.headers['content-encoding'] == 'gzip':
try:
result.message = gzip.decompress(result.message)
except OSError:
pass
return result
开发者ID:freerambo,项目名称:pyfiap,代码行数:11,代码来源:fiap.py
示例16: __init__
def __init__(self, **kwargs):
"""
Provides a throttled HTTP transport for respecting rate limits
on rate-restricted SOAP APIs using :mod:`suds`.
This class is a :class:`suds.transport.Transport` subclass
based on the default ``HttpAuthenticated`` transport.
:param minimum_spacing: Minimum number of seconds between requests.
Default 0.
:type minimum_spacing: int
.. todo::
Use redis or so to coordinate between threads to allow a
maximum requests per hour/day limit.
"""
self._minumum_spacing = kwargs.pop('minimum_spacing', 0)
self._last_called = int(time.time())
HttpTransport.__init__(self, **kwargs)
开发者ID:chintal,项目名称:tendril,代码行数:20,代码来源:www.py
示例17: u2handlers
def u2handlers(self):
# try to import ntlm support
try:
from ntlm3 import HTTPNtlmAuthHandler
except ImportError:
raise Exception("Cannot import python-ntlm3 module")
handlers = HttpTransport.u2handlers(self)
handlers.append(HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(
password_mgr=self.pm,header='Negotiate')
)
return handlers
开发者ID:ctxis,项目名称:lather,代码行数:11,代码来源:https.py
示例18: search
def search(query, SID):
url = client = {}
http = HttpTransport()
opener = urllib2.build_opener(HTTPSudsPreprocessor(SID))
http.urlopener = opener
url['search'] = 'http://search.webofknowledge.com/esti/wokmws/ws/WokSearch?wsdl'
client['search'] = Client(url['search'], transport = http)
qparams = {
'databaseId' : 'WOS',
'userQuery' : query,
'queryLanguage' : 'en'
}
rparams = {
'count' : 100, # 1-100
'firstRecord' : 1
}
return client['search'].service.search(qparams, rparams)
开发者ID:apgoldst,项目名称:wok_search,代码行数:21,代码来源:wok_soap_2.py
示例19: __init__
def __init__(self, **kwargs):
"""
@param kwargs: Keyword arguments.
- B{proxy} - An http proxy to be specified on requests.
The proxy is defined as {protocol:proxy,}
- type: I{dict}
- default: {}
- B{cache} - The http I{transport} cache. May be set (None) for no caching.
- type: L{Cache}
- default: L{NoCache}
- B{username} - The username used for http authentication.
- type: I{str}
- default: None
- B{password} - The password used for http authentication.
- type: I{str}
- default: None
"""
HttpTransport.__init__(self, **kwargs)
self.pm = u2.HTTPPasswordMgrWithDefaultRealm()
self.handler = u2.HTTPBasicAuthHandler(self.pm)
self.urlopener = u2.build_opener(self.handler)
开发者ID:tic-ull,项目名称:defensatfc-proto,代码行数:21,代码来源:https.py
示例20: retrieve_by_id_lite
def retrieve_by_id_lite(input_term, ver, start_record, max_count, SID):
'''
This is a method used for lite services.
:param input_term: input search term.
:param ver: Version 2 or 3. Refer to Thomson Reuters Documentation for details.
:param start_record: starting record point
:param max_count: maximum request count
:param SID: Session ID.
:return: output xml
'''
http = HttpTransport()
opener = urllib2.build_opener(HTTPSudsPreprocessor(SID))
http.urlopener = opener
client_obj = Client(SEARCH_LITE_URL[int(ver - 2)], transport = http, retxml = True)
rparams = {
'count' : max_count, # 1-100
'firstRecord' : start_record,
'sortField' : [{
'name' : 'Relevance',
'sort' : 'D',
}]
}
cited_results = client_obj.service.retrieveById('DIIDW', input_term, 'en', rparams)
return cited_results
开发者ID:ahdoki,项目名称:tasters-choice,代码行数:24,代码来源:retrieveById.py
注:本文中的suds.transport.http.HttpTransport类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论