예제 #1
0
def doDeviceStats():
    global g_users
    deviceStats = {}
    for user in g_users:
        deviceInfo = user[USERS_DEVICE_INFO]
        di = arsutils.decodeDi(deviceInfo)
        deviceName = di['device_name']
        if deviceStats.has_key(deviceName):
            deviceStats[deviceName] = deviceStats[deviceName] + 1
        else:
            deviceStats[deviceName] = 1

    deviceStatsArr = [item for item in deviceStats.items() if item[1] > 2]
    deviceStatsArr.sort(sortDeviceStatsPred)
    for (deviceName, n) in deviceStatsArr:
        print " %5d : %s" % (n, deviceName)
예제 #2
0
def doDeviceStats():
    global g_users
    deviceStats = {}
    for user in g_users:
        deviceInfo = user[USERS_DEVICE_INFO]
        di = arsutils.decodeDi(deviceInfo)
        deviceName = di['device_name']
        if deviceStats.has_key(deviceName):
            deviceStats[deviceName] = deviceStats[deviceName] + 1
        else:
            deviceStats[deviceName] = 1

    deviceStatsArr = [item for item in deviceStats.items() if item[1] > 2]
    deviceStatsArr.sort(sortDeviceStatsPred)
    for (deviceName, n) in deviceStatsArr:
        print " %5d : %s" % (n, deviceName)
예제 #3
0
def getDeviceStats():
    global g_deviceStats
    if None != g_deviceStats:
        return g_deviceStats
    deviceStats = {}
    # we rely on the fact, that this data is sorted by the 'registration' time,
    # and we use last 100 'registrations' to calculate 'recent' stats
    users = getUsersData()
    usersCount = len(users)
    for userNo in range(usersCount):
        user = users[userNo]
        deviceInfo = user[USERS_DEVICE_INFO]
        di = arsutils.decodeDi(deviceInfo)
        deviceName = di['device_name']
        if deviceStats.has_key(deviceName):
            deviceStats[deviceName].total +=1
        else:
            deviceStats[deviceName] = DeviceStat()
        if userNo > usersCount - 100:
            deviceStats[deviceName].recent += 1
    g_deviceStats = deviceStats
    return deviceStats
예제 #4
0
def getDeviceStats():
    global g_deviceStats
    if None != g_deviceStats:
        return g_deviceStats
    deviceStats = {}
    # we rely on the fact, that this data is sorted by the 'registration' time,
    # and we use last 100 'registrations' to calculate 'recent' stats
    users = getUsersData()
    usersCount = len(users)
    for userNo in range(usersCount):
        user = users[userNo]
        deviceInfo = user[USERS_DEVICE_INFO]
        di = arsutils.decodeDi(deviceInfo)
        deviceName = di['device_name']
        if deviceStats.has_key(deviceName):
            deviceStats[deviceName].total += 1
        else:
            deviceStats[deviceName] = DeviceStat()
        if userNo > usersCount - 100:
            deviceStats[deviceName].recent += 1
    g_deviceStats = deviceStats
    return deviceStats