Esempio n. 1
0
def main():
    if len(sys.argv) != 2:
        print(f'Usage: python {sys.argv[0]} behavior_ids.txt')
        sys.exit()

    username = input('Username: '******'Error: Invalid username and/or password.')
        sys.exit()

    filename = sys.argv[1]
    with open(filename) as behavior_file:
        behavior_ids = [behavior_id.strip() for behavior_id in behavior_file]

    info = {'behaviors': {'behavior': []}}

    for behavior_id in behavior_ids:
        behavior = {'id': behavior_id}
        info['behaviors']['behavior'].append(behavior)

    status = lotame.put('behaviors/ignored', info).status_code
    if status == 204:
        print('Successfully ignored behaviors.')
    else:
        print('Error: Could not ignore behaviors.')

    lotame.cleanup()
Esempio n. 2
0
def main():
    if len(sys.argv) != 2:
        print(f'Usage: python {sys.argv[0]} audience_ids.txt')
        sys.exit()

    username = input('Username: '******'Error: Invalid username and/or password.')
        sys.exit()

    recency = input('Recency (in days): ')
    recency = str(int(recency) * 24 * 60)  # Convert secs to days

    filename = sys.argv[1]
    with open(filename) as audience_ids:
        for audience_id in audience_ids:
            audience_id = audience_id.strip()

            info = lotame.get(f'audiences/{audience_id}').json()
            component = info['definition']['component']
            add_recency(component, recency)
            info['definition']['component'] = component
            response = lotame.put(f'audiences/{audience_id}', info)
            status = response.status_code

            print(f'Audience {audience_id} | HTTP {status}')

    lotame.cleanup()
Esempio n. 3
0
def main():
    if len(sys.argv) != 2:
        print(f'Usage: python {sys.argv[0]} audience_ids.txt')
        sys.exit()

    username = input('Username: '******'Error: Incorrect username and/or password.')
        sys.exit()

    filename = sys.argv[1]
    with open(filename) as file:
        for audience_id in file:
            audience_id = audience_id.strip()

            info = lotame.get(f'audiences/{audience_id}').json()
            if info['generate_apr']:
                print(f'APR already active for audience {audience_id}')
            else:
                info['generate_apr'] = True
                response = lotame.put(f'audiences/{audience_id}', info)
                status = response.status_code
                print(f'Audience {audience_id} | HTTP {status}')

    lotame.cleanup()
def put_audience_info(audience_id, audience_info):
    """Updates an audience."""
    status = lotame.put(f'audiences/{audience_id}', audience_info).status_code

    if status != 204:
        return False

    return True
def set_audience_info(audience_id, info):
    response = lotame.put(f'audiences/{audience_id}', info)

    status = response.status_code
    if status != 204:
        return False

    return True
def categorize(node_id, info):
    endpoint = f'hierarchies/nodes/{node_id}/categorizedBehaviors'
    response = lotame.put(endpoint, info)

    status = response.status_code
    if status != 204:
        return False

    return True
def main():
    if len(sys.argv) != 2:
        print(f'Usage: python {sys.argv[0]} audience_ids.txt')
        sys.exit()

    username = input('Username: '******'Error: Username and/or password invalid.')
        sys.exit()

    print('Change all audiences to...')
    print('1. Enrich')
    print('2. Extend')
    audience_type = 0
    while audience_type not in [1, 2]:
        audience_type = int(input('Choose: '))

    filename = sys.argv[1]
    with open(filename) as file:
        for audience_id in file:
            audience_id = audience_id.strip()

            info = lotame.get('audiences/{audience_id}').json()

            # Set appropriate option, or skip to next audience if already set
            if audience_type == 1:
                if info['overlapOnly']:
                    print('Audience {audience_id} already correct.')
                    continue
                info['overlapOnly'] = True  # Enrich
            else:
                if not info['overlapOnly']:
                    print('Audience {audience_id} already correct.')
                    continue
                info['overlapOnly'] = False  # Extend

            status = lotame.put('audiences/{audience_id}', info).status_code
            print('Audience {audience_id} | HTTP {status}')

    lotame.cleanup()
Esempio n. 8
0
def main():
    if len(sys.argv) == 1:
        print(f'Usage: python {sys.argv[0]} aliases.xlsx')
        sys.exit()

    username = input('Username: '******'Error: Invalid username or password.')
        sys.exit()

    option = 0
    while option not in ['1', '2']:
        print('Select option:')
        print('1. Replace variants')
        print('2. Append variants')
        option = input('Option: ')

    filename = sys.argv[1]
    workbook = openpyxl.load_workbook(filename)
    sheet_names = workbook.get_sheet_names()
    sheet = workbook.get_sheet_by_name(sheet_names[0])

    for row in range(2, sheet.max_row + 1):
        behavior_id = str(sheet[f'A{row}'].value)
        new_alias = str(sheet[f'B{row}'].value)

        endpoint = f'behaviors/{behavior_id}/aliases'
        info = lotame.get(endpoint).json()

        if option == '1':  # Replace
            info['alias'] = [new_alias]
        else:  # Append
            info['alias'].append(new_alias)

        status = lotame.put(endpoint, info).status_code

        print(f'Behavior {behavior_id} | HTTP {status}')

    lotame.cleanup()
def main():
    if len(sys.argv) != 2:
        print(f'Usage: python {sys.argv[0]} campaign_ids.txt')
        sys.exit()

    username = input('Username: '******'Error: Invalid username and/or password.')
        sys.exit()

    filename = sys.argv[1]
    with open(filename) as campaign_file:
        campaign_ids = [campaign_id.strip() for campaign_id in campaign_file]

    for campaign_id in campaign_ids:
        response = lotame.get(f'campaigns/{campaign_id}')

        status = response.status_code
        if status != 200:
            print(f'Could not retrieve campaign {campaign_id}')
            continue

        campaign_info = response.json()
        campaign_info['activateStats'] = False

        response = lotame.put(f'campaigns/{campaign_id}', campaign_info)

        status = response.status_code
        if status == 200:
            print(f'Deactivated stats for campaign {campaign_id}')
        else:
            print(f'Could not deactivate stats for campaign {campaign_id}')

    lotame.cleanup()
Esempio n. 10
0
def set_audience_info(audience_id, info):
    status = lotame.put(f'audiences/{audience_id}', info).status_code
    return bool(status == 204)