예제 #1
0
파일: redisdata.py 프로젝트: zhaozw/hall37
def redis_get_config(options, rkey):
    datas = _getLastOkDefines(options)
    rdb = datas['pokerdict']['config_redis']
    conn = tydb.get_redis_conn(rdb)
    data = conn.get(rkey)
    del conn
    return strutil.loads(data)
예제 #2
0
def redis_get_config(options, rkey):
    datas = _getLastOkDefines(options)
    rdb = datas['pokerdict']['config_redis']
    conn = tydb.get_redis_conn(rdb)
    data = conn.get(rkey)
    del conn
    return strutil.loads(data)
예제 #3
0
파일: actions.py 프로젝트: zhaozw/hall37
 def _check_param_roomConf(self, key, params, extend_tag):
     value = runhttp.getParamStr(key)
     try:
         value = strutil.loads(value)
         return None, value
     except:
         return 'roomConf must json string', None
예제 #4
0
파일: actions.py 프로젝트: zhaozw/hall37
 def _check_param_roomConf(self, key, params, extend_tag):
     value = runhttp.getParamStr(key)
     try:
         value = strutil.loads(value)
         return None, value
     except:
         return 'roomConf must json string', None
예제 #5
0
파일: hotfix.py 프로젝트: zhaozw/hall37
def printErrorRet(ret):
    if ret.find('"error"') >= 0 :
        actlog.log('ERROR !!')
        try:
            errs = strutil.loads(ret)
            for sid in errs :
                actlog.log('============ EXCEPTIONS OF %s ============' % (sid))
                excs = errs[sid]['error']
                l = excs.split('\n')
                for x in l :
                    if x != '' :
                        actlog.log(x)
        except:
            actlog.log('ERROR !!', ret)
        actlog.log('ERROR !!')
        return 1
    else:
        actlog.log(ret)
    return 0
예제 #6
0
파일: hotfix.py 프로젝트: zhaozw/hall37
def printErrorRet(ret):
    if ret.find('"error"') >= 0:
        actlog.log('ERROR !!')
        try:
            errs = strutil.loads(ret)
            for sid in errs:
                actlog.log('============ EXCEPTIONS OF %s ============' %
                           (sid))
                excs = errs[sid]['error']
                l = excs.split('\n')
                for x in l:
                    if x != '':
                        actlog.log(x)
        except:
            actlog.log('ERROR !!', ret)
        actlog.log('ERROR !!')
        return 1
    else:
        actlog.log(ret)
    return 0
예제 #7
0
def action(options, integrate=0):
    '''
    装载并检测服务启动配置文件
    '''
    serverlist = options.serverlist
    setattr(options, 'hotfixpy', HOTCODE)
    setattr(options, 'hotfixwait', 1)
    x = 0
    serverIds = []
    for srv in serverlist :
        x += 1
        serverIds.append(srv['type'] + srv['id'])
    serverIds = ','.join(serverIds)
    setattr(options, 'serverIds', serverIds)
    if integrate == 0 :
        actlog.log('get configure status->', serverIds)
    ret = hotfix.action(options, 0)

    config_redis = options.pokerdict['config_redis']
    rconn = tydb.get_redis_conn(config_redis)
    clen = rconn.llen(_CHANGE_KEYS_NAME)
    try:
        datas = strutil.loads(ret)
    except:
        actlog.log('ERROR !!', ret)
        if integrate == 0 :
            return 0
        return 0, 0
    
    confOks = []
    confNgs = []
    errors = []
    errorids = []
    for sid in datas :
        if isinstance(datas[sid], dict):
            cidx = datas[sid].get('CINDEX', None)
            cerrs = datas[sid].get('ERRORS', [])
        else:
            cidx = ''
            cerrs = []
            actlog.log('ERROR !!!! ', sid, datas[sid])
        if cerrs :
            errorids.append(sid)
            for cerr in cerrs :
                erritem = [cerr.get('exception', None), cerr.get('tarceback', None)]
                if not erritem in errors :
                    errors.append(erritem)

        if isinstance(cidx, int) :
            if cidx >= clen :
                confOks.append(sid)
            else:
                confNgs.append(sid)
        else:
            actlog.error('ERROR !!', sid, 'GET STATUS ERROR !!', datas[sid])
    
    if errors :
        actlog.log('ERROR IDS =', ','.join(errorids))
        actlog.log('========== ERROR !!!! BEGINE ========')
        for x in errors :
            actlog.log('========== Exception ========')
            for l in x[0] :
                for m in l.split('\n') :
                    if m :
                        actlog.log(m)
            actlog.log('========== Traceback ========')
            for l in x[1] :
                for m in l.split('\n') :
                    if m :
                        actlog.log(m)
        actlog.log('========== ERROR !!!! END ========')
        raise Exception('Remote Exception')
        if integrate == 0 :
            return 0
        else:
            return 0, 0

    if integrate == 0 :    
        actlog.log('THE CONFIGURE KEY INDEX =', clen)
        actlog.log('TOTAL_COUNT =', len(serverlist) , 'OK_COUNT =', len(confOks), 'DELAY_COUNT =', len(confNgs))
        actlog.log('CONFIGURE_STATUS = %0.2d' % (int(float(len(confOks)) / len(datas) * 100)) + '%')
    if integrate == 0 :
        return 1
    else:
        return len(confOks), len(serverlist)
예제 #8
0
파일: actions.py 프로젝트: zhaozw/hall37
    def do_http_debug_action(self, action):

        if action == 'redis_clear_all':
            result = redisdata.redis_clear_all(self.options)

        userId = runhttp.getParamInt('userId', 0)
        gameId = runhttp.getParamInt('gameId', 0)
        key = runhttp.getParamStr('key', '')
        value = runhttp.getParamStr('value', '')

        if action == 'redis_search_all_userdata':
            result = redisdata.redis_search_all_userdata(self.options, userId)

        if action == 'html_redirect':
            datas = redisdata._getLastOkDefines(self.options)
            httpgame = datas['pokerdict']['http_game']
            rurl = runhttp.getParamStr('url')
            if os.environ.get('RUN_IN_DOCKER', 0):
                # 在开发docker模式下,需要替换为外部HALL37HTTP端口号(此端口由nginx代理服务)
                refhost = runhttp.getParamStr('refhost')
                tks = refhost.split(':')
                tks[-1] = os.environ.get('PORT_NGINX', '80')
                httpgame = ':'.join(tks)
            result = rurl.replace('${http_game}', httpgame)

        if action == 'redis_get_userdata':
            result = redisdata.redis_get_userdata(self.options, userId)

        if action == 'redis_set_userdata':
            result = redisdata.redis_set_userdata(self.options, userId, key,
                                                  value)

        if action == 'redis_get_gamedata':
            result = redisdata.redis_get_gamedata(self.options, userId, gameId)

        if action == 'redis_set_gamedata':
            result = redisdata.redis_set_gamedata(self.options, userId, gameId,
                                                  key, value)

        if action == 'redis_get_map_clientid':
            result = redisdata.redis_get_config(self.options,
                                                'poker:map.clientid')

        if action == 'redis_get_map_productid':
            result = redisdata.redis_get_config(self.options,
                                                'poker:map.productid')

        if action == 'redis_get_map_activityid':
            result = redisdata.redis_get_config(self.options,
                                                'poker:map.activityid')

        if action == 'redis_get_map_evnetid':
            result = redisdata.redis_get_config(self.options,
                                                'poker:map.bieventid')

        if action == 'redis_del_userdata':
            result = redisdata.redis_del_userdata(self.options, userId)

        if action == 'redis_del_gamedata':
            result = redisdata.redis_del_gamedata(self.options, userId, gameId)

        if action == 'redis_del_day1st':
            result = redisdata.redis_del_weakdata(self.options, userId, False)

        if action == 'redis_del_daylogin':
            result = redisdata.redis_del_weakdata(self.options, userId, True)

        if action == 'redis_get_usertime':
            result = redisdata.redis_get_usertime(self.options, userId)

        if action == 'redis_command':
            cmdline = runhttp.getParamStr('command', '')
            cmdline = strutil.loads(cmdline)
            ralias = runhttp.getParamStr('redisalias', '')
            roomId = runhttp.getParamInt('roomId', 0)
            result = redisdata.redis_do_command(self.options, userId, roomId,
                                                ralias, cmdline)

        datas = redisdata._getLastOkDefines(self.options)
        httpgame = datas['pokerdict']['http_game']
        if action == 'putmsg':
            httpgame = httpgame + '/v1/putmsg'
            result = tyhttp.dohttpquery(httpgame, runhttp.getDict())

        if action == 'get_room_info':
            httpgame = httpgame + '/_http_manager_get_room_details'
            result = tyhttp.dohttpquery(httpgame, runhttp.getDict())

        if action == 'hotfix_code':
            from optparse import Values
            options = Values()
            setattr(options, 'poker_path', self.options.pokerpath)
            setattr(options, 'hotfixpy', runhttp.getParamStr('hotfixpy'))
            setattr(options, 'hotfixwait', 1)
            setattr(options, 'serverIds', runhttp.getParamStr('serverIds'))
            result = hotfix.action(options, 0)

        if isinstance(result, (long, int, float, bool)):
            result = str(result)
        if isinstance(result, (list, tuple, dict, set)):
            result = json.dumps(result,
                                indent=2,
                                sort_keys=True,
                                ensure_ascii=False)
        if not isinstance(result, (str, unicode)):
            result = str(result)
        result = result.replace('<', '&lt;')
        result = result.replace('>', '&gt;')
        result = result.replace('\r', '')
        result = result.replace('\n', '<br>')
        result = result.replace('\\n', '<br>')
        result = result.replace(' ', '&nbsp;')
        result = result.replace('\\\\x', '\\x')
        mo = MsgPack()
        mo.setCmd(action)
        mo.setResult('ok', 1)
        mo.setResult('text', result)
        return mo
예제 #9
0
파일: actions.py 프로젝트: zhaozw/hall37
 def _check_param_action_uuids(self, key, params, extend_tag):
     value = runhttp.getParamStr(key, '')
     value = strutil.loads(value, ignoreException=1)
     if isinstance(value, list) and len(value) >= 0:
         return None, value
     return 'the action_uuids error', None
예제 #10
0
파일: actions.py 프로젝트: zhaozw/hall37
 def _check_param_action_params(self, key, params, extend_tag):
     value = runhttp.getParamStr(key, '')
     value = strutil.loads(value, ignoreException=True)
     if isinstance(value, (list, dict)):
         return None, value
     return 'the action params error', None