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
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
def CmdOfflineMsgonDo(from_name,msg): if not funcs.isAdmin(from_name): return 'you are not administrator' users = funcs.getOfflineMsgOnUserListFromCache() ret_str = u'offline msg on user below:\n' for gtalk in users: user_data = funcs.getUserByName(gtalk) ret_str += u'%s(%s)\n' % (user_data.nickname,gtalk) return ret_str.encode('utf-8')
def CmdOfflineMsgonDo(from_name, msg): if not funcs.isAdmin(from_name): return 'you are not administrator' users = funcs.getOfflineMsgOnUserListFromCache() ret_str = u'offline msg on user below:\n' for gtalk in users: user_data = funcs.getUserByName(gtalk) ret_str += u'%s(%s)\n' % (user_data.nickname, gtalk) return ret_str.encode('utf-8')