예제 #1
0
 def GETRATE(self, args):
     if self._rates is None:
         t.userlog('Loading rates')
         f = urllib.request.urlopen(
             'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'
         )
         x = et.fromstring(f.read().decode('utf8'))
         self._rates = {}
         for r in x.findall('.//*[@currency]'):
             self._rates[r.attrib['currency']] = float(r.attrib['rate'])
     return t.tpreturn(t.TPSUCCESS, 0,
                       {'RATE': self._rates[args['CURRENCY'][0]]})
예제 #2
0
 def PROXY(self, data, name, flags):
     future = asyncio.run_coroutine_threadsafe(
         on_service(name, data, flags), loop)
     rval, rcode, data = future.result(timeout=5)
     return t.tpreturn(rval, rcode, data)
예제 #3
0
 def RELOAD(self, args):
     t.userlog('Singleton called with' + str(args))
     self._rates = None
     return t.tpreturn(t.TPSUCCESS, 0, {})
예제 #4
0
파일: db.py 프로젝트: uldisa/tuxedo-python
 def DB(self, args):
     dbc = self.db.cursor()
     dbc.execute('insert into pymsg(msg) values (:1)',
                 ['Hello from python'])
     return t.tpreturn(t.TPSUCCESS, 0, args)
예제 #5
0
 def MEMGET(self, args):
     args['VALUE'] = []
     for key in args['KEY']:
         args['VALUE'].append(self.db.get(key, ''))
     return t.tpreturn(t.TPSUCCESS, 0, args)
예제 #6
0
 def MEMPUT(self, args):
     for key, value in zip(args['KEY'], args['VALUE']):
         self.db[key] = value
     return t.tpreturn(t.TPSUCCESS, 0, {})
예제 #7
0
파일: app.py 프로젝트: aivarsk/tuxedo-nats
 def TUX2(self, data):
     if "TA_STATUS" not in data:
         data["TA_STATUS"] = []
     data["TA_STATUS"].append("Hello from TUX2")
     _, _, data = t.tpcall("NATS1", data, t.TPNOTRAN)
     return t.tpreturn(t.TPSUCCESS, 0, data)
예제 #8
0
파일: app.py 프로젝트: aivarsk/tuxedo-nats
 def TUX1(self, data):
     if "TA_STATUS" not in data:
         data["TA_STATUS"] = []
     data["TA_STATUS"].append("Hello from TUX1")
     return t.tpreturn(t.TPSUCCESS, 0, data)