Exemplo n.º 1
0
def CmdStateDo(from_name,msg):
	if not funcs.isAdmin(from_name):
		return 'you are not administrator'
	ret_msg = ''
	users = DBUser.all().fetch(1000)
	users_count_db = len(users)
	users = funcs.getUserListFromCache()
	users_count_cache = len(users)
	if users_count_cache == users_count_db:
		ret_msg += 'user db and cache count ok:%d\n' % users_count_db
	else:
		ret_msg += 'user db and cache count fail:%d/%d\n' % (users_count_db,users_count_cache)
	users = funcs.getOnlineMsgOnUserListFromCache()
	count0 = len(users)
	users = funcs.getOnlineMsgOffUserListFromCache()
	count1 = len(users)
	users = funcs.getOfflineMsgOnUserListFromCache()
	count2 = len(users)
	users = funcs.getOfflineMsgOffUserListFromCache()
	count3 = len(users)
	if users_count_db == count0+count1 == count2+count3:
		ret_msg += 'user onlinemsgon/onlinemsgoff/offlinemsgon/offlinemsgoff ok:%d/%d/%d/%d\n' % (count0,count1,count2,count3)
	else:
		ret_msg += 'user onlinemsgon/onlinemsgoff/offlinemsgon/offlinemsgoff fail:%d/%d/%d/%d\n' % (count0,count1,count2,count3)
		count0,count1,count2,count3 = funcs.getUserCountFromDb()
		ret_msg += 'DB   onlinemsgon/onlinemsgoff/offlinemsgon/offlinemsgoff fail:%d/%d/%d/%d\n' % (count0,count1,count2,count3)
	return ret_msg
Exemplo n.º 2
0
def CmdStateDo(from_name, msg):
    if not funcs.isAdmin(from_name):
        return 'you are not administrator'
    ret_msg = ''
    users = DBUser.all().fetch(1000)
    users_count_db = len(users)
    users = funcs.getUserListFromCache()
    users_count_cache = len(users)
    if users_count_cache == users_count_db:
        ret_msg += 'user db and cache count ok:%d\n' % users_count_db
    else:
        ret_msg += 'user db and cache count fail:%d/%d\n' % (users_count_db,
                                                             users_count_cache)
    users = funcs.getOnlineMsgOnUserListFromCache()
    count0 = len(users)
    users = funcs.getOnlineMsgOffUserListFromCache()
    count1 = len(users)
    users = funcs.getOfflineMsgOnUserListFromCache()
    count2 = len(users)
    users = funcs.getOfflineMsgOffUserListFromCache()
    count3 = len(users)
    if users_count_db == count0 + count1 == count2 + count3:
        ret_msg += 'user onlinemsgon/onlinemsgoff/offlinemsgon/offlinemsgoff ok:%d/%d/%d/%d\n' % (
            count0, count1, count2, count3)
    else:
        ret_msg += 'user onlinemsgon/onlinemsgoff/offlinemsgon/offlinemsgoff fail:%d/%d/%d/%d\n' % (
            count0, count1, count2, count3)
        count0, count1, count2, count3 = funcs.getUserCountFromDb()
        ret_msg += 'DB   onlinemsgon/onlinemsgoff/offlinemsgon/offlinemsgoff fail:%d/%d/%d/%d\n' % (
            count0, count1, count2, count3)
    return ret_msg
Exemplo n.º 3
0
def CmdGroupInfoDo(from_name,msg):
	if not funcs.isAdmin(from_name):
		return 'you are not administrator'
	if GetCmdNum(msg) != 2:
		return 'error:need days'
	days = int(GetCmdByNum(msg,2))
	time_dot = time.time() - days * 24 * 60 * 60
	all_users_dict = funcs.getUserListFromCache()
	users_dict = funcs.getUserCountList()
	ret_str = u'user info:\n'
	
	for gtalk in all_users_dict.keys():
		if gtalk in users_dict.keys():
			user_data = users_dict[gtalk]
			if user_data['time'] < time_dot:
				ret_str += u'%s[%d],%s\n' % (gtalk,user_data['count'],funcs.getNatureTime2(user_data['time']))
		else:
			ret_str += u'%s[0]\n' % gtalk
	return ret_str.encode('utf-8')
Exemplo n.º 4
0
def CmdGroupInfoDo(from_name, msg):
    if not funcs.isAdmin(from_name):
        return 'you are not administrator'
    if GetCmdNum(msg) != 2:
        return 'error:need days'
    days = int(GetCmdByNum(msg, 2))
    time_dot = time.time() - days * 24 * 60 * 60
    all_users_dict = funcs.getUserListFromCache()
    users_dict = funcs.getUserCountList()
    ret_str = u'user info:\n'

    for gtalk in all_users_dict.keys():
        if gtalk in users_dict.keys():
            user_data = users_dict[gtalk]
            if user_data['time'] < time_dot:
                ret_str += u'%s[%d],%s\n' % (gtalk, user_data['count'],
                                             funcs.getNatureTime2(
                                                 user_data['time']))
        else:
            ret_str += u'%s[0]\n' % gtalk
    return ret_str.encode('utf-8')