Exemplo n.º 1
0
def getUserData(campaign, id):
    data = []
    clo = campaign.lower()
    print "inside getUserData, "+clo+", and id: "+str(id)
    if clo in "external":
        data = get_external_data(id)
        print "Got external data: "+str(data)
    elif clo.startswith("all"):       # Actually, all in campaig.lower()
        print "Starts with all"
        #cx = pymysql.connect(user='******', password='******',database='jerry_live', host="db02")
        cu = db.cursor()
        cu.execute(QUERRY[clo])
        for x in cu:
            data.append(x)
    elif clo in "testing":
        print "Testing campaign"
        # data = [["919818261929","Arabic"],["917838310825","English"],["971559052361","Arabic"]]
        data = get_testing_sheet().get_all_values()[1:]     # Gives data in list of list format, skipping the header row
    elif clo in "custom":
        print "Custom campaign"
        data = get_custom_sheet().get_all_values()[1:]     # Gives data in list of list format, skipping the header row
    elif clo.startswith("cust_"):
        print "starts with cust_"
        data = get_custom_sheet(clo).get_all_values()[1:]
    else:
        print "Different: "+clo
        #cx = pymysql.connect(user='******', password='******',database='cerberus_live', host="db02")
        cu = db.cursor()
        cu.execute(QUERRY['other'],campaign)
        for x in cu:
            data.append(x)
    blocked_list = set([a[0]+','+a[1] for a in get_block_sheet().get_all_values()[1:]])
    data = [a for a in data if ','.join([a[0], a[1]]) not in blocked_list]
    return data
Exemplo n.º 2
0
def getUserData(event):
    """ Get the [phone, language] or [phone, language, country] for the customers """
    data = []
    campaign = event['campaign']
    id = event['id']
    clo = campaign.lower()
    print "inside getUserData, " + clo + ", and id: " + str(id)
    if clo in ["external", "segment"]:  # Main priority
        data = get_external_data(event)
        print "Got external data: " + str(data)
    elif clo.startswith("all"):  # Actually, all in campaig.lower()
        print "Starts with all"
        cu = db.cursor()
        cu.execute(QUERRY[clo])
        for x in cu:
            data.append(x)
    elif clo in "testing":
        print "Testing campaign"
        data = get_testing_sheet().get_all_values()[1:]  # Gives data in list of list format, skipping the header row
    elif clo in "custom":
        print "Custom campaign"
        data = get_custom_sheet().get_all_values()[1:]  # Gives data in list of list format, skipping the header row
    elif clo.startswith("cust_"):
        print "starts with cust_"
        data = get_custom_sheet(clo).get_all_values()[1:]
    else:
        print "Different: " + clo
        cu = db.cursor()
        cu.execute(QUERRY['other'], campaign)
        for x in cu:
            data.append(x)
    blocked_set = get_block_set()
    data = map(
        lambda k: [str(k[0]).strip('+ ').replace('-', '')] + list(k[1:]),
        [x for x in data if len(x) >= 2]
    )
    data = [a for a in data if ','.join(a[0:2]) not in blocked_set]
    return data