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


Python Client.add_prefix方法代码示例

本文整理汇总了Python中suds.client.Client.add_prefix方法的典型用法代码示例。如果您正苦于以下问题:Python Client.add_prefix方法的具体用法?Python Client.add_prefix怎么用?Python Client.add_prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在suds.client.Client的用法示例。


在下文中一共展示了Client.add_prefix方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_user_client

# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import add_prefix [as 别名]
def get_user_client():
    """
    Returns a soap client object.

    If an object has already been created, we recyle it,
    otherwise, a new one is created and returned.

    """
    app = webapp2.get_app()
    request = webapp2.get_request()

    username = request.registry["session"].get("username")
    password = request.registry["session"].get("password")
    user_key = "user_client:{}".format(username)

    # check if we already have the client
    user_client = app.registry.get(user_key)
    if not user_client:
        user_client = Client(USR_URL, cache=None)
        user_client.add_prefix("srv", "http://service.user.core.mtrak.digi.com")
        user_client.add_prefix("vo", "http://vo.user.core.mtrak.digi.com/xsd")

        app.registry[user_key] = user_client

    user_client.set_options(soapheaders=(Element("username").setText(username), Element("password").setText(password)))

    return user_client
开发者ID:digidotcom,项目名称:map-idigi,代码行数:29,代码来源:user_client.py

示例2: get_lgn_client

# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import add_prefix [as 别名]
def get_lgn_client():
    '''
    Returns a soap client object.

    If an object has already been created, we recyle it,
    otherwise, a new one is created and returned.

    '''
    app = webapp2.get_app()
    request = webapp2.get_request()

    username = request.registry['session'].get('username')
    password = request.registry['session'].get('password')
    lgn_key = 'lgn_client:{}'.format(username)

    # Check if we already have the client
    lgn_client = app.registry.get(lgn_key)

    if not lgn_client:
        lgn_client = Client(LGN_URL, cache=None)
        lgn_client.add_prefix(
            'srv', "http://service.login.core.mtrak.digi.com")
        lgn_client.add_prefix(
            'vo', "http://vo.login.core.mtrak.digi.com/xsd")

        app.registry[lgn_key] = lgn_client

    lgn_client.set_options(soapheaders=(
        Element('username').setText(username),
        Element('password').setText(password)))

    return lgn_client
开发者ID:digidotcom,项目名称:map-idigi,代码行数:34,代码来源:lgn_client.py

示例3: SoapConnection

# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import add_prefix [as 别名]
class SoapConnection(object):

    def __init__(self, url=None, sessionid=None, app_name=None):
        if url is None:
            port = config.getint('hydra_client', 'port', 80)
            domain = config.get('hydra_client', 'domain', '127.0.0.1')
            path = config.get('hydra_client', 'soap_path', 'soap')
            #The domain may or may not specify the protocol, so do a check.
            if domain.find('http') == -1:
                self.url = "http://%s:%s/%s?wsdl" % (domain, port, path)
            else:
                self.url = "%s:%s/%s?wsdl" % (domain, port, path)
        else:
            log.info("Using user-defined URL: %s", url)
            port = _get_port(url)
            hostname = _get_hostname(url)
            path = _get_path(url)
            protocol = _get_protocol(url)
            self.url = "%s://%s:%s%s/soap?wsdl" % (protocol, hostname, port, path)
        log.info("Setting URL %s", self.url)

        self.app_name = app_name
        self.sessionid = sessionid
        self.retxml = False
        self.client = Client(self.url,
                             timeout=3600,
                             plugins=[FixNamespace()],
                             retxml=self.retxml)
        self.client.add_prefix('hyd', 'soap_server.hydra_complexmodels')

        cache = self.client.options.cache
        cache.setduration(days=10)

    def login(self, username=None, password=None):
        """Establish a connection to the specified server. If the URL of the
        server is not specified as an argument of this function, the URL
        defined in the configuration file is used."""

        # Connect
        token = self.client.factory.create('RequestHeader')
        if self.sessionid is None:
            if username is None:
                user = config.get('hydra_client', 'user')
            if password is None:
                passwd = config.get('hydra_client', 'password')
            login_response = self.client.service.login(user, passwd)
            token.user_id = login_response.user_id
            sessionid = login_response.sessionid
            token.username = user

        token.sessionid = sessionid
        self.client.set_options(soapheaders=token)

        return session_id
开发者ID:UMWRG,项目名称:HydraPlatform,代码行数:56,代码来源:connection.py

示例4: connect

# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import add_prefix [as 别名]
def connect(url=None):
    if url is None:
        port = config.getint('hydra_server', 'port', '8080')
        domain = config.get('hydra_server', 'domain', 'localhost')
        path = config.get('hydra_server', 'soap_path', 'soap')
        if path:
            if path[0] == '/':
                path = path[1:]
            url = 'http://%s:%s/%s?wsdl' % (domain, port, path)
        else:
            url = 'http://%s:%s?wsdl' % (domain, port)

    client = Client(url, plugins=[FixNamespace()])

    cache = client.options.cache
    cache.setduration(days=10)

    client.add_prefix('hyd', 'soap_server.hydra_complexmodels')
    return client
开发者ID:UMWRG,项目名称:HydraPlatform,代码行数:21,代码来源:util.py

示例5: get_device_client

# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import add_prefix [as 别名]
def get_device_client():
    '''
    Returns a soap client object.

    If an object has already been created, we recyle it,
    otherwise, a new one is created and returned.

    '''
    app = webapp2.get_app()
    request = webapp2.get_request()

    # check if we already have the client
    username = request.registry['session'].get('username')
    password = request.registry['session'].get('password')
    device_key = 'device_client:{}'.format(username)

    # check if we aleady have the client
    device_client = app.registry.get(device_key)
    if not device_client:
        device_client = Client(DEV_URL, cache=None)
        device_client.add_prefix(
            'rsp', "http://response.devicemanagement.core.mtrak.digi.com/xsd")
        device_client.add_prefix(
            'srv', "http://service.devicemanagement.core.mtrak.digi.com")
        device_client.add_prefix(
            'vo', "http://vo.devicemanagement.core.mtrak.digi.com/xsd")

        app.registry[device_key] = device_client

    device_client.set_options(soapheaders=(
        Element('username').setText(username),
        Element('password').setText(password)))

    return device_client
开发者ID:digidotcom,项目名称:map-idigi,代码行数:36,代码来源:device_client.py

示例6: Fiskalizacija

# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import add_prefix [as 别名]
class Fiskalizacija():
    
    def __init__(self, msgtype, wsdl, key, cert, cr, uid, oe_obj=None):
        self.set_start_time() 
        self.wsdl=wsdl  
        self.key=key 
        self.cert=cert
        self.msgtype=msgtype
        self.oe_obj=oe_obj
        self.oe_id=oe_obj and oe_obj.id or 0 #openerp id racuna ili pprostora ili 0 za echo i ostalo
        self.cr=cr            #openerp cursor radi log-a 
        self.uid=uid          #openerp cursor radi log-a 
        SetFiskalFilePaths(key, cert)
        self.client2 = Client(wsdl, cache=None, prettyxml=True, timeout=15, faults=False, plugins=[DodajPotpis()] ) 
        self.client2.add_prefix('tns', 'http://www.apis-it.hr/fin/2012/types/f73')
        self.zaglavlje = self.client2.factory.create('tns:Zaglavlje')
        if msgtype in ('echo'):
            pass
        elif msgtype in ('prostor_prijava', 'prostor_odjava', 'PoslovniProstor'):
            #self.zaglavlje = self.client2.factory.create('tns:Zaglavlje')
            self.prostor = self.client2.factory.create('tns:PoslovniProstor')
        elif msgtype in ('racun', 'racun_ponovo', 'Racun'):
            #self.zaglavlje = self.client2.factory.create('tns:Zaglavlje')
            self.racun = self.client2.factory.create('tns:Racun') 
        self.greska =''

    def time_formated(self): 
        tstamp = zagreb_now() 
        v_date='%02d.%02d.%02d' % (tstamp.day, tstamp.month, tstamp.year)
        v_datum_vrijeme='%02d.%02d.%02dT%02d:%02d:%02d' % (tstamp.day, tstamp.month, tstamp.year, tstamp.hour, tstamp.minute, tstamp.second)
        v_datum_racun='%02d.%02d.%02d %02d:%02d:%02d' % (tstamp.day, tstamp.month, tstamp.year, tstamp.hour, tstamp.minute, tstamp.second)
        vrijeme={'datum':v_date,                    #vrijeme SAD
                 'datum_vrijeme':v_datum_vrijeme,   # format za zaglavlje XML poruke
                 'datum_racun':v_datum_racun,       # format za ispis na računu
                 'time_stamp':tstamp}               # timestamp, za zapis i izračun vremena obrade
        return vrijeme

    def set_start_time(self):
        self.start_time = self.time_formated()

    def set_stop_time(self):
        self.stop_time = self.time_formated()
        
    def log_fiskal(self):
        fiskal_prostor_id = invoice_id = None
        if self.msgtype in ('echo'):
            fiskal_prostor_id = self.oe_id
        elif self.msgtype in ('prostor_prijava', 'prostor_odjava', 'PoslovniProstor'):
            fiskal_prostor_id = self.oe_id
        elif self.msgtype in ('racun', 'racun_ponovo', 'Racun'):
            invoice_id = self.oe_id
        company_id = self.oe_obj and self.oe_obj.company_id and self.oe_obj.company_id.id or 1
                     
        self.set_stop_time()
        t_obrada = self.stop_time['time_stamp'] - self.start_time['time_stamp']
        time_obr='%s.%s s'%(t_obrada.seconds, t_obrada.microseconds)
        
        self.cr.execute("""
            INSERT INTO fiskal_log(
                         user_id, create_uid, create_date
                        ,name, type, time_stamp 
                        ,sadrzaj, odgovor, greska
                        ,fiskal_prostor_id, invoice_id, time_obr
                        ,company_id )
                VALUES ( %s, %s, %s,  %s, %s, %s,  %s, %s, %s,  %s, %s, %s, %s );
            """, ( self.uid, self.uid, datetime.now(),
                   self.zaglavlje.IdPoruke, self.msgtype, datetime.now(),
                   str(self.poruka_zahtjev), str(self.poruka_odgovor), self.greska,
                   fiskal_prostor_id, invoice_id, time_obr,
                   company_id
                  ) 
        )

    def echo(self):
        try:
            odgovor = self.client2.service.echo('TEST PORUKA')
            poruka_zahtjev =  self.client2.last_sent().str()
            self.poruka_zahtjev =  self.client2.last_sent()
            self.poruka_odgovor = odgovor
        except:
            #return 'No ECHO reply','TEST PORUKA'
            poruka_zahtjev='TEST PORUKA' #TODO pitat suds di je zapelo...
            self.greska ='Ostale greske - Nema Odgovor! '
        finally:
            self.log_fiskal()
        return self.poruka_odgovor

    def posalji_prostor(self):
        res=False
        try:
            odgovor=self.client2.service.poslovniProstor(self.zaglavlje, self.prostor)
            self.poruka_zahtjev =  self.client2.last_sent()
            self.poruka_odgovor = odgovor
            if odgovor[0] == 200:
                res = True
            elif odgovor[0] == 500:
                self.greska = '=>'.join(( odgovor[1]['Greske'][0][0]['SifraGreske'],
                                          odgovor[1]['Greske'][0][0]['PorukaGreske'].replace('http://www.apis-it.hr/fin/2012/types/','')
                                       ))
        except:
#.........这里部分代码省略.........
开发者ID:jerko,项目名称:fiskal_v70,代码行数:103,代码来源:fiskal.py

示例7: getInventory

# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import add_prefix [as 别名]
    def getInventory(self, network, station='*', location='*', channel='*',
                     starttime=UTCDateTime(), endtime=UTCDateTime(),
                     instruments=True, min_latitude=-90, max_latitude=90,
                     min_longitude=-180, max_longitude=180,
                     modified_after=None, format='SUDS'):
        """
        Returns information about the available networks and stations in that
        particular space/time region.

        :type network: str
        :param network: Network code, e.g. ``'BW'``.
        :type station: str
        :param station: Station code, e.g. ``'MANZ'``. Station code may contain
            wild cards.
        :type location: str
        :param location: Location code, e.g. ``'01'``. Location code may
            contain wild cards.
        :type channel: str
        :param channel: Channel code, e.g. ``'EHE'``. Channel code may contain
            wild cards.
        :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime`
        :param starttime: Start date and time.
        :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime`
        :param endtime: End date and time.
        :type instruments: boolean, optional
        :param instruments: Include instrument data. Default is ``True``.
        :type min_latitude: float, optional
        :param min_latitude: Minimum latitude, defaults to ``-90.0``
        :type max_latitude: float, optional
        :param max_latitude: Maximum latitude, defaults to ``90.0``
        :type min_longitude: float, optional
        :param min_longitude: Minimum longitude, defaults to ``-180.0``
        :type max_longitude: float, optional
        :param max_longitude: Maximum longitude, defaults to ``180.0``.
        :type modified_after: :class:`~obspy.core.utcdatetime.UTCDateTime`,
            optional
        :param modified_after: Returns only data modified after given date.
            Default is ``None``, returning all available data.
        :type format: ``'XML'`` or ``'SUDS'``, optional
        :param format: Output format. Either returns a XML document or a
            parsed SUDS object. Defaults to ``SUDS``.
        :return: XML document or a parsed SUDS object containing inventory
            information.

        .. rubric:: Example

        >>> from obspy.neries import Client
        >>> from obspy import UTCDateTime
        >>> client = Client(user='[email protected]')
        >>> dt = UTCDateTime("2011-01-01T00:00:00")
        >>> result = client.getInventory('GE', 'SNAA', '', 'BHZ', dt, dt+10,
        ...                              instruments=True)
        >>> paz = result.ArclinkInventory.inventory.responsePAZ
        >>> print(paz.poles)  # doctest: +ELLIPSIS
        (-0.037004,0.037016) (-0.037004,-0.037016) (-251.33,0.0) ...
        """
        # enable logging if debug option is set
        if self.debug:
            import logging
            logging.basicConfig(level=logging.INFO)
            logging.getLogger('suds.client').setLevel(logging.DEBUG)
        # initialize client
        client = SudsClient(SEISMOLINK_WSDL,
                            retxml=(format == 'XML'))
        # set prefixes for easier debugging
        client.add_prefix('gml', 'http://www.opengis.net/gml')
        client.add_prefix('ogc', 'http://www.opengis.net/ogc')
        client.add_prefix('xlin', 'http://www.w3.org/1999/xlink')
        client.add_prefix('urn', 'urn:xml:seisml:orfeus:neries:org')
        # set cache of 5 days
        cache = client.options.cache
        cache.setduration(days=5)
        # create user token
        usertoken = client.factory.create('UserTokenType')
        usertoken.email = self.user
        usertoken.password = self.password
        usertoken.label = self.user_agent.replace(' ', '_')
        usertoken.locale = ""
        # create station filter
        stationid = client.factory.create('StationIdentifierType')
        stationid.NetworkCode = network
        stationid.StationCode = station
        stationid.ChannelCode = channel
        stationid.LocId = location
        stationid.TimeSpan.TimePeriod.beginPosition = \
            UTCDateTime(starttime).strftime("%Y-%m-%dT%H:%M:%S")
        stationid.TimeSpan.TimePeriod.endPosition = \
            UTCDateTime(endtime).strftime("%Y-%m-%dT%H:%M:%S")
        # create spatial filters
        spatialbounds = client.factory.create('SpatialBoundsType')
        spatialbounds.BoundingBox.PropertyName = "e gero"
        spatialbounds.BoundingBox.Envelope.lowerCorner = "%f %f" %\
            (min(min_latitude, max_latitude),
             min(min_longitude, max_longitude))
        spatialbounds.BoundingBox.Envelope.upperCorner = "%f %f" %\
            (max(min_latitude, max_latitude),
             max(min_longitude, max_longitude))
        # instruments attribute
        if instruments:
            client.options.plugins.append(
#.........这里部分代码省略.........
开发者ID:jandog8990,项目名称:obspy,代码行数:103,代码来源:client.py

示例8: Fiskalizacija

# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import add_prefix [as 别名]
class Fiskalizacija():
    def init(self, msgtype, wsdl, key, cert, oe_id=None):
        #file paths for wsdl, key, cert
        self.wsdl = wsdl  
        self.key = key 
        self.cert = cert
        self.msgtype =msgtype
        self.oe_id = oe_id or 0 #openerp id racuna ili pprostora ili 0 za echo i ostalo

        SetFiskalFilePaths(key, cert)

        self.client2 = Client(wsdl, cache=None, prettyxml=True, timeout=15, faults=False, plugins=[DodajPotpis()] ) 
        self.client2.add_prefix('tns', 'http://www.apis-it.hr/fin/2012/types/f73')
        self.zaglavlje = self.client2.factory.create('tns:Zaglavlje')

        if msgtype in ('echo'):
            pass
        elif msgtype in ('prostor_prijava', 'prostor_odjava', 'PoslovniProstor'):
            self.prostor = self.client2.factory.create('tns:PoslovniProstor')
        elif msgtype in ('racun', 'racun_ponovo', 'Racun'):
            self.racun = self.client2.factory.create('tns:Racun') 

    def time_formated(self): 
        tstamp = zagreb_now() #datetime.datetime.now() this was server def. tz time
        v_date='%02d.%02d.%02d' % (tstamp.day, tstamp.month, tstamp.year)
        v_datum_vrijeme='%02d.%02d.%02dT%02d:%02d:%02d' % (tstamp.day, tstamp.month, tstamp.year, tstamp.hour, tstamp.minute, tstamp.second)
        v_datum_racun='%02d.%02d.%02d %02d:%02d:%02d' % (tstamp.day, tstamp.month, tstamp.year, tstamp.hour, tstamp.minute, tstamp.second)
        vrijeme={'datum':v_date,                    #vrijeme SAD
                 'datum_vrijeme':v_datum_vrijeme,   # format za zaglavlje XML poruke
                 'datum_racun':v_datum_racun,       # format za ispis na računu
                 'time_stamp':tstamp}               # timestamp, za zapis i izračun vremena obrade
        return vrijeme
        
        
    def set_start_time(self):
        self.start_time = self.time_formated()

    def set_stop_time(self):
        self.stop_time = self.time_formated()

    def echo(self):
        try:
            pingtest=self.client2.service.echo('TEST PORUKA')
            poruka_zahtjev =  self.client2.last_sent().str()
            return pingtest, poruka_zahtjev
        except:
            return 'No ECHO reply','TEST PORUKA'

    def posalji_prostor(self):
        try:
            odgovor=self.client2.service.poslovniProstor(self.zaglavlje, self.pp)
            poruka_zahtjev =  self.client2.last_sent().str()
            poruka_odgovor = str(odgovor)
            return poruka_odgovor, poruka_zahtjev
        except:
            return 'Error - no reply!', poruka

    def izracunaj_zastitni_kod(self):    
        self.racun.ZastKod = self.get_zastitni_kod(self.racun.Oib,
                                                  self.racun.DatVrijeme,
                                                  str(self.racun.BrRac.BrOznRac),
                                                  self.racun.BrRac.OznPosPr,
                                                  self.racun.BrRac.OznNapUr,
                                                  str(self.racun.IznosUkupno)
                                                  )

    def get_zastitni_kod(self, Oib, DatVrijeme, BrOznRac, OznPosPr, OznNapUr, IznosUkupno):    
        medjurezultat = ''.join((Oib, DatVrijeme, BrOznRac, OznPosPr, OznNapUr, IznosUkupno)) 
        pkey = RSA.load_key(keyFile)
        signature = pkey.sign(hashlib.sha1(medjurezultat).digest())
        return hashlib.md5(signature).hexdigest()

    def posalji_racun(self):
        try:
            return self.client2.service.racuni(self.zaglavlje, self.racun)
        except:
            pass#a=self.client2.service.racuni(self.zaglavlje, self.racun)
            return 'greška u slanju podataka' 

    def generiraj_poruku(self):
        self.client2.options.nosend = True
        poruka = str(self.client2.service.racuni(self.zaglavlje, self.racun).envelope)
        self.client2.options.nosend = False
        return poruka
开发者ID:badbole,项目名称:testing61,代码行数:86,代码来源:fiskal.py


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