Beispiel #1
0
 def POST(self):
     data = web.input()
     data.ip = web.ctx.ip
     log.info('[idsc]ChenckPay:%s', data)
     act_cls = ACTS[CB_ACT_PAY]
     code, desc = act_cls.ChenckPay(sdk, data)
     log.info('[idsc]finish ChenckPay:%s', (code, desc))
     if code == CODE_SUCC:
         return json.dumps({'err_code':0, 'desc':desc})
     else:
         return json.dumps({'err_code':1, 'desc':desc})
Beispiel #2
0
 def POST(self):
     data = web.input()
     data.ip = web.ctx.ip
     log.info('[idsc]callback:%s', data)
     act_cls = ACTS[CB_ACT_PAY]
     try:
         code, desc = act_cls.GET(sdk, data)
     except:
         log.log_except()
         return json.dumps({'success':0, 'desc':'sys error'})
     log.info('[idsc]callbacked:%s', (code, desc))
     if code == CODE_SUCC:
         return json.dumps({'success':1, 'desc':desc})
     else:
         return json.dumps({'success':0, 'desc':desc})
Beispiel #3
0
 def new(cls, pid, type, items, rid=0):
     o = cls()
     o.data.pid = pid
     o.data.type = type
     o.data.items = json.dumps(items) #items是列表对象
     o.data.rid = rid
     o.items = items
     return o
Beispiel #4
0
 def pack(self, msg):
     if DEBUG_PACK: log.debug('pack:%s', msg)
     tag = msg.pop('_tag')
     if is_ujson:
         #ujson支持object对象,并且直接输出最短结构
         data = json.dumps(msg, ensure_ascii=False)
     else:
         data = json.dumps(msg, ensure_ascii=False,
                 default=self._json_default,
                 separators=(',', ':'))
         #ensure_ascii=False时,json输出unicode, ujson输出utf8str
         if isinstance(data, unicode):
             data = data.encode('utf-8')
     if self.ZIP:
         data = compress(data, ZLIB_LEVEL)
     if self.AES:
         data = self.aes_encrypt(data)
     l = len(data)
     return struct.pack('%s%ds' % (self._head_fmt, l), tag, l, data)
Beispiel #5
0
 def POST(self):
     data = web.input()
     act_cls = ACTS[CB_ACT_PAY]
     rs = act_cls.check_accout(sdk, data)
     log.debug('[ids]Login:%s', rs)
     return json.dumps(rs)
Beispiel #6
0
 def POST(self):
     data = web.input()
     act_cls = ACTS[CB_ACT_PAY]
     rs = act_cls.get_server_list(sdk, data)
     log.debug('[ids]Server:%s', rs)
     return json.dumps(rs)
Beispiel #7
0
def make_result(code, desc):
    if code == CODE_SUCC:
        return 'Success'
    return json.dumps(dict(ErrorCode=code, ErrorDesc=desc))
Beispiel #8
0
 def POST(self):
     data = web.input()
     act_cls = ACTS[CB_ACT_PAY]
     rs = act_cls.check_accout(sdk, data)
     log.debug('[ids]Login:%s', rs)
     return json.dumps(rs)
Beispiel #9
0
def make_result(code, desc):
    if code == CODE_SUCC:
        return json.dumps({'status': 'success'})
    return ''
Beispiel #10
0
 def GET(self):
     """ /api/91pay?CooOrderSerial=xxxx """
     data = web.input(_method='GET')
     rs, code, desc = sdk91.check_pay(data['CooOrderSerial'])
     return json.dumps((int(rs), code, desc))
Beispiel #11
0
def encode_json(data):
    """ 加密数据 """
    data = json.dumps(data, separators=(',', ':'))
    if not AES:
        return data
    return aes_encrypt(data)
Beispiel #12
0
 def GET(self):
     p = psutil.Process(os.getpid())
     # blocking
     cpu = p.get_cpu_percent()
     return json.dumps({'cpu': cpu})
Beispiel #13
0
 def GET(self):
     """ /api/91login?sid=xxxx&session=xxxxx """
     data = web.input(_method='GET')
     log.debug('sdk91.login:%s', data)
     rs, code, desc = sdk91.login(data['sid'], data['session'])
     return json.dumps((int(rs), code, desc))
Beispiel #14
0
def make_result(code, desc):
    return json.dumps(dict(ErrorCode=code, ErrorDesc=desc))
Beispiel #15
0
 def GET(self):
     """ /api/91pay?CooOrderSerial=xxxx """
     data = web.input(_method='GET')
     rs, code, desc = sdk91.check_pay(data['CooOrderSerial'])
     return json.dumps((int(rs), code, desc))
Beispiel #16
0
def make_result(code, desc):
    if code == CODE_SUCC:
        return 'Success'
    return json.dumps(dict(ErrorCode=code, ErrorDesc=desc))
Beispiel #17
0
 def POST(self):
     data = web.input()
     act_cls = ACTS[CB_ACT_PAY]
     rs = act_cls.get_server_list(sdk, data)
     log.debug('[ids]Server:%s', rs)
     return json.dumps(rs)
Beispiel #18
0
def make_result(code, desc):
    return json.dumps(dict(ErrorCode=code, ErrorDesc=desc))
Beispiel #19
0
def make_result(code, desc):
    if code == CODE_SUCC:
        return json.dumps({'status':'success'})
    return ''