Exemple #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)
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)
Exemple #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
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