Пример #1
0
def main(account_id, passcode, region, path_json, path_csv, type_of_download):

    clevertap = CleverTap(account_id, passcode, region=region)
    result = []

    if type_of_download not in ["event", "profile"]:
        raise Exception("unknown record type %s" % type)
        return

    start_time = datetime.datetime.now()
    print("Downloading...")
    try:
        with open(path_json) as data_file:
            data = json.load(data_file)
        if type_of_download == "profile":
            result = clevertap.profiles(data, MAX_BATCH_SIZE)
        elif type_of_download == "event":
            result = clevertap.events(data, MAX_BATCH_SIZE)
        _convert_to_csv(result, path_csv)

    except Exception as e:
        print(e)

    finally:
        end_time = datetime.datetime.now()
        processing_time = end_time - start_time
        print(("Processing Time: %s" % processing_time))
Пример #2
0
def main(account_id, passcode, region, path, mapping_path, type, dryrun):
    clevertap = CleverTap(account_id, passcode, region=region)
    data = []

    if type not in ["event", "profile"]:
        raise Exception("unknown record type %s" % type)
        return

    mapping = None
    if mapping_path is not None:
        try:
            with open(mapping_path) as mapping_file:
                mapping = json.load(mapping_file)
        except Exception, e:
            print e
            pass
Пример #3
0
def main(account_id, passcode, path, type, dryrun):
    clevertap = CleverTap(account_id, passcode)
    data = []

    if type not in ["event", "profile"]:
        raise Exception("unknown record type %s" % type)
        return

    if type == "event":
        raise NotImplementedError("Event handling not yet implemented")
        return

    f = open(path, 'rt')
    try:
        reader = csv.DictReader(f)
        for row in reader:
            record = process_raw_record(row, type)
            if record is not None:
                if dryrun:
                    print record
                data.append(record)
            else:
                print "unable to process row skipping: %s" % row

        count = len(data)
        if count <= 0:
            print "no records to process"
            f.close()
            return

        if not dryrun:
            print "starting upload for %s records" % count

        processed = 0
        while processed < count:
            remaining = count - processed
            batch_size = MAX_BATCH_SIZE if remaining > MAX_BATCH_SIZE else remaining
            batch = data[processed:processed + batch_size]
            if not dryrun:
                res = clevertap.upload(batch)
                print res
            processed += batch_size

        print "processed %s records" % processed

    except Exception, e:
        print e
Пример #4
0
 def setUp(self):
     self.clevertap = CleverTap(CT_ACCOUNT_ID, CT_ACCOUNT_PASSCODE)
import random

import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)

TABLE_NAME = "quotes"
INDEX_NAME = "PersonalityTypeIndex"

CT_ACCOUNT_ID = "6Z8-64Z-644Z"
CT_ACCOUNT_PASSCODE = "WVE-SAD-OAAL"

QUOTE_BYTE_LENGTH = 40

try:
    clevertap = CleverTap(CT_ACCOUNT_ID, CT_ACCOUNT_PASSCODE)
except Exception, e:
    logger.error(e)
    clevertap = None

try:
    dynamo = boto3.resource('dynamodb').Table(TABLE_NAME)
except Exception, e:
    logger.error(e)
    dynamo = None

LENGTH_BY_PREFIX = [
    (0xC0, 2),  # first byte mask, total codepoint length
    (0xE0, 3),
    (0xF0, 4),
    (0xF8, 5),