Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # vim:fileencoding=utf-8
- from __future__ import absolute_import, division, unicode_literals
- from logging import getLogger
- from constance import config
- from requests.auth import HTTPBasicAuth
- from zeep import Client as SOAPClient
- from zeep.transports import Transport
- logger = getLogger(__name__)
- class SoapService(object):
- transport = None
- client = None
- def __init__(self):
- self.transport = Transport(
- http_auth=HTTPBasicAuth(
- username=config.ALLOINCOGNITO_BASIC_LOGIN_V2,
- password=config.ALLOINCOGNITO_BASIC_PASSWORD_V2,
- ),
- timeout=config.ALLOINCOGNITO_LOADER_TIMEOUT_V2,
- verify=False
- )
- self.client = SOAPClient(
- wsdl=config.ALLOINCOGNITO_WSDL_PATH_V2,
- transport=self.transport
- )
- def get_all_numbers(self):
- i = 1
- numbers = []
- while True:
- try:
- data = self.client.service.GetNumList(
- login=config.ALLOINCOGNITO_METHOD_LOGIN_V2,
- password=config.ALLOINCOGNITO_METHOD_PASSWORD_V2,
- pageSize=config.ALLOINCOGNITO_PAGE_SIZE,
- pageIndex=i
- )["Items"]["Num"]
- except KeyError:
- raise Exception(u"Метод GetNumList вернул данные, имеющие не верный формат")
- if len(data) < 1:
- break
- i += 1
- numbers.append(data)
- return numbers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement