Exemplo n.º 1
0
    def __init__(self, options = {}):
        GenericSoap.SmsDriver.__init__(self, options)

        # Soap Client
        cache = ObjectCache(location = "/tmp/suds.%d" % os.getuid())
        cache.setduration(days = 10)
        self.client = Client(self.url, cache = cache)

        # Authentication
        self.auth = self.client.factory.create('AuthenticationType')
        self.auth.userId = self.options['username']
        self.auth.password = self.options['password']
Exemplo n.º 2
0
    def __init__(self, service, authorization_data=None, environment='production', version='v10', **suds_options):
        """ Initializes a new instance of this class.

        :param service: The service name.
        :type service: str
        :param authorization_data: (optional) The authorization data, if not provided, cannot call operations on service
        :type authorization_data: AuthorizationData or None
        :param environment: (optional) The environment name, can only be 'production' or 'sandbox', the default is 'production'
        :type environment: str
        :param version: to specify the service version, only support v9 and v10, valid input is: 9, 10, 'v9', 'v10', the default is 'v10'
        :param suds_options: The suds options need to pass to suds client
        """

        self._input_service = service
        self._input_environment = environment
        self._authorization_data = authorization_data
        self._refresh_oauth_tokens_automatically = True
        self._version = ServiceClient._format_version(version)

        # TODO This is a temp fix for set default suds temp folder with user info, suds development branch has already fixed it.
        if 'cache' not in suds_options:
            location = path.join(gettempdir(), 'suds', getuser())
            suds_options['cache'] = ObjectCache(location, days=1)
        # set cachingpolicy to 1 to reuse WSDL cache files, otherwise will only reuse XML files
        if 'cachingpolicy' not in suds_options:
            suds_options['cachingpolicy'] = 1
        self._options = suds_options

        self._service = ServiceClient._format_service(service)
        self._environment = ServiceClient._format_environment(environment)

        self._soap_client = Client(self.service_url, **suds_options)
Exemplo n.º 3
0
    def __init__(self,
                 service,
                 authorization_data=None,
                 environment='production',
                 **suds_options):
        """ Initializes a new instance of this class.

        :param service: The service name.
        :type service: str
        :param authorization_data: (optional) The authorization data, if not provided, cannot call operations on service
        :type authorization_data: AuthorizationData or None
        :param environment: (optional) The environment name, can only be 'production' or 'sandbox', the default is 'production'
        :type environment: str
        :param suds_options: The suds options need to pass to suds client
        """

        self._input_service = service
        self._input_environment = environment
        self._authorization_data = authorization_data
        self._refresh_oauth_tokens_automatically = True

        # TODO This is a temp fix for set default suds temp folder with user info, suds development branch has already fixed it.
        if 'cache' not in suds_options:
            location = path.join(gettempdir(), 'suds', getuser())
            suds_options['cache'] = ObjectCache(location, days=1)
        self._options = suds_options

        self._service = ServiceClient._format_service(service)
        self._environment = ServiceClient._format_environment(environment)

        self._soap_client = Client(self.service_url, **suds_options)