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


Python http.HttpTransport类代码示例

本文整理汇总了Python中suds.transport.http.HttpTransport的典型用法代码示例。如果您正苦于以下问题:Python HttpTransport类的具体用法?Python HttpTransport怎么用?Python HttpTransport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HttpTransport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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