Beispiel #1
0
def test_service_details_response():
    service, options, handler = le.COMMAND_SERVICE['details']
    client = Client(le.wsdl(service))
    soap = SoapClient(client, client.service.consulterMesuresDetaillees.method)
    resp_file = os.path.join(DATA_DIR,
                             'consulterMesuresDetailleesResponse.xml')
    with open(resp_file) as stream:
        resp = soap.succeeded(soap.method.binding.input, stream.read())
        data = le.services.measures_resp2py(resp)
        assert len(data) == 8
        assert data[0] == (
            datetime.datetime(2020, 2, 29, 23, tzinfo=le.services.UTC),
            100,
        )
Beispiel #2
0
 def connect(self):
     try:
         self.client = SoapClient(self.url + '/xmds.php?WSDL&v=' +
                                  str(self.ver))
     except exceptions.IOError, err:
         print '---- xmds: connection io error ----'
         self.client = None
Beispiel #3
0
    def make(self, authenticator: Authenticator):
        """Build and configure soap client"""
        if self._client is None:
            self._client = SoapClient(self._local_url, faults=False, cachingpolicy=0)

            if self.debug:
                logging.basicConfig(level=logging.INFO)
                logging.getLogger('suds.client').setLevel(logging.DEBUG)
                logging.getLogger('suds.transport').setLevel(logging.DEBUG)
                logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
                logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
            else:
                logging.getLogger('suds').setLevel(logging.INFO)

        # FIXME
        # Need make copy by suds.client.clone() method,
        # but now got this issue https://bitbucket.org/jurko/suds/issues/7/recursion-depth-reached
        # cl = self._client.clone()

        cl = self._client

        cl.set_options(location=authenticator.endpoint)

        security = Security()
        token = UsernameToken('*', '*')
        security.tokens.append(token)
        cl.set_options(wsse=security)

        element_oauth = Element('oAuth', ns=('etns', 'http://exacttarget.com'))
        element_oauth_token = Element('oAuthToken').setText(authenticator.auth_legacy_token)
        element_oauth.append(element_oauth_token)
        cl.set_options(soapheaders=[element_oauth])

        return cl
Beispiel #4
0
    def get_order_status(self, order_number):
        ''' Returns the status of the supplied order number '''
        #url = self.get_url("orderservice")
        #operation = 'orderStatus'
        #request_url = "%s/%s?orderNumber=%s&username=%s&password=%s" % (url, operation, order_number, self.username, self.password)
        #pass
        retval = dict()

        client = SoapClient(self.get_url("orderupdate"))
        resp = client.factory.create("getOrderStatusResponse")
        resp = client.service.getOrderStatus(order_number)
        if resp is None:
            return dict()

        retval['order_num'] = str(resp.order.orderNbr)
        retval['order_status'] = str(resp.order.orderStatus)
        retval['units'] = list()

        for u in resp.units.unit:
            unit = dict()
            unit['unit_num'] = int(u.unitNbr)
            unit['unit_status'] = str(u.unitStatus)
            unit['sceneid'] = str(u.orderingId)
            retval['units'].append(unit)

        return retval
Beispiel #5
0
    def order_scenes(self, scene_list):
        ''' Orders scenes from the massloader.  Be sure to call verifyscenes before allowing this to happen '''

        client = SoapClient(self.get_url("massloader"))
        tramorder = client.factory.create('order')
        tramscenes = client.factory.create('scenes')
        tramorder.scenes = tramscenes
        for scene in scene_list:
            tramscene = client.factory.create('scene')
            tramscene.sceneId = scene.name
            tramscene.productName = self.get_product_code(scene.name)
            tramscene.recipeId = null()
            tramscene.unitComment = null()
            tramscene.parameters = null()
            tramorder.scenes.scene.append(tramscene)
        tramorder.externalRefNumber = '111111'
        tramorder.orderComment = null()
        tramorder.priority = 5
        #tramorder.registrationId = '252380'
        tramorder.registrationId = self.get_tram_id()
        tramorder.requestor = 'EE'
        tramorder.roleId = null()

        try:
            response = client.service.submitOrder(tramorder)
            return response
        except Exception, e:
            print("An error occurred submitting the order to tram: %s" % (e))
            #log error
            return -1
Beispiel #6
0
 def __init__(self, *args, **kwargs):
     super(LTASoapService, self).__init__(*args, **kwargs)
     if config.mode in ('dev', 'tst'):
         logger.info('Building SoapClient for:{0}'.format(self.url))
     self.client = SoapClient(self.url,
                              location=self.location,
                              cache=self.build_object_cache())
Beispiel #7
0
 def connect(self):
     try:
         self.__client = SoapClient(self.__url + "/xmds.php?WSDL&v=" +
                                    str(self.__ver))
     except exceptions.IOError, err:
         log.error(err)
         self.__client = None
Beispiel #8
0
 def connect(self):
     try:
         self.client = SoapClient(self.url + '/xmds.php?WSDL&v=' +
                                  str(self.ver))
     except exceptions.IOError as err:
         print('---- xmds: connection io error ----')
         self.client = None
     return self.client is not None
Beispiel #9
0
def get_k18_result_b64(file_ori_b64, ext):
    try:
        ret = SoapClient(k18_url).service.TransResumeByJsonStringForFileBase64(
            username=k18_username,
            pwd=k18_password,
            content=file_ori_b64,
            ext="." + ext)
        ret = json.loads(ret)
    except:
        ret = None
    return ret
Beispiel #10
0
    def get_available_orders(self):
        ''' Returns all the orders that were submitted for ESPA through EE '''
        returnVal = dict()

        client = SoapClient(self.get_url("orderdelivery"))
        resp = client.factory.create("getAvailableOrdersResponse")

        try:
            resp = client.service.getAvailableOrders("ESPA")
        except Exception, e:
            print e
            raise e
Beispiel #11
0
 def update_order(self, order_number, unit_number, status):
     ''' Update the status of orders that ESPA is working on '''
     client = SoapClient(self.get_url("orderupdate"))
     resp = client.factory.create("StatusOrderReturn")
     try:
         resp = client.service.setOrderStatus(
             orderNumber=str(order_number),
             systemId="EXTERNAL",
             newStatus=str(status),
             unitRangeBegin=int(unit_number),
             unitRangeEnd=int(unit_number))
     except Exception, e:
         return (False, e, None)
Beispiel #12
0
    def send(self, number, message):
        client = SoapClient(self.soapservice)

        response = client.service.XmsRequest(
            self.template.format(userid=self.user,
                                 password=self.password,
                                 sender=self.sender,
                                 message=message,
                                 number=number))

        try:
            response = objectify(response)
            return str(response), response.get('mobile', None)
        except:
            return 'error', response
Beispiel #13
0
 def authenticate(self, username, password):
     ''' This will authenticate a username/password against the LTA
         user registration service.  If the call succeeds then we return
         the users contactId (which should be used on our side for any
         database records as it shouldn't change) but if it fails then
         we will return None '''
     client = SoapClient(self.get_url("registration"))
     resp = client.factory.create("loginUserResponse")
     try:
         resp = client.service.loginUser(username, password)
         return resp
     except Exception, e:
         print("Authentication Failure for user:%s" % username)
         print e
         return None
Beispiel #14
0
    def __init__(self):
        soap_url = 'https://portal.velleman.eu/ServicePortal/WebServices/ProductServices.asmx?WSDL'
        #wsdl_url = 'https://portal.velleman.eu/ServicePortal/WebServices/ProductServices.asmx?WSDL'
        wsdl_url = 'file://' + os.path.join(os.path.dirname(__file__),
                                            'ProductServices.wsdl')

        #       self.client = SoapClient(url=wsdl_url, location=soap_url, transport=HttpAuthenticated(), username='******', password='******')
        #
        self.client = SoapClient(url=wsdl_url, location=soap_url)
        #
        cache = self.client.options.cache
        cache.setduration(days=10)
        #
        token = self.client.factory.create('AuthenticationHeader')
        token.Username = '******'
        token.Password = '******'
        self.client.set_options(soapheaders=token)
Beispiel #15
0
 def __init__(self, *args, **kw):
     SoapClient.__init__(self, *args, **kw)
     self.messages = {}
Beispiel #16
0
 def last_received(self, d=None):
     SoapClient.last_received(self, d)
     return self._conversation('rx', d)
Beispiel #17
0
 def last_sent(self, d=None):
     SoapClient.last_sent(self, d)
     return self._conversation('tx', d)
Beispiel #18
0
 def __init__(self, *args, **kwargs):
     super(LTASoapService, self).__init__(*args, **kwargs)
     logger.info('Building SoapClient for:{0}'.format(self.url))
     self.client = SoapClient(self.url, cache=self.build_object_cache())
Beispiel #19
0
 def __init__(self, *args, **kw):
     SoapClient.__init__(self, *args, **kw)
     self.messages = {}
Beispiel #20
0
 def last_sent(self, d=None):
     SoapClient.last_sent(self, d)
     return self._conversation('tx', d)
Beispiel #21
0
 def last_received(self, d=None):
     SoapClient.last_received(self, d)
     return self._conversation('rx', d)
Beispiel #22
0
 def setup(self, ip):
     self.client = SoapClient('http://%s/%s' % (ip, self.wsdl_path))