예제 #1
0
def select_by_udid(unique_device_id, bit, ratio_min=0):
    if not unique_device_id or unique_device_id.strip() == '':
        return False
    ss = unique_device_id.split('v')
    if not ss:
        return False
    remainder = try_parse(unique_device_id.split('v')[0][-bit:], int, 0)
    return True if remainder < ratio_min else False
예제 #2
0
def select_by_udid_group(unique_device_id, bit, divide=()):
    if not unique_device_id or unique_device_id.strip() == '':
        return 0
    ss = unique_device_id.split('v')
    if not ss:
        return 0
    remainder = try_parse(unique_device_id.split('v')[0][-bit:], int, 0)
    for i, c in enumerate(divide):
        if remainder < c:
            return i+1
    return len(divide) + 1
예제 #3
0
def get_udid_timestamp(udid):
    """
    sample: 15181922390020607v6.5
    :param udid:
    :return: seconds
    """
    if not udid or len(udid) < 17:
        return 0
    elif udid.startswith('mg'):
        ss = udid.split('_')
        if len(ss) > 1:
            x = ObjectId(ss[1])
            return int(time.mktime(x.generation_time.timetuple()))
    else:
        ts = try_parse(udid[:17], int, 0)
        return ts / 10000000
    return 0
예제 #4
0
def select_by_udid_gte_time(udid, seconds):
    """
    udid 生成时间超过seconds, 返回True
    :param udid:
    :return: bool
    """
    if not udid or len(udid) < 17:
        return False
    try:
        if udid.find('mgd') == 0:
            # android udid format(mongodb id) parse, sample: mgd14_5c823b4ee5640901a5f952de
            ts = int(udid[6:14], 16)
        else:
            # iphone udid format parse, sample: 15135695090020466v6.3
            ts = try_parse(udid[:10], int, 0)
        return time.time() - ts > seconds
    except Exception as e:
        pass
    return False
def get_udid_idfa_db(unique_device_id, ):
    if not unique_device_id:
        return 1
    remain = try_parse(unique_device_id.split('v')[0][-2:], int, 0)
    return remain / 10 + 1