def process_texts(texts, friend_name):
    if ('error' in texts):
        print('Error = ', error)
        raise Exception('Error in Response')
    if ('data' not in texts):
        return
    while (len(texts['data']) > 0):
        for text in texts['data']:
            if ('message' not in text):
                continue
            if (friend_name in no_of_messages):
                no_of_messages[friend_name] += 1
                total_chat_length[friend_name] += len(text['message'])
            else:
                no_of_messages[friend_name] = 1
                total_chat_length[friend_name] = len(text['message'])
        if (('paging' in texts) and ('next' in texts['paging'])):
            request_str = texts['paging']['next'].replace('https://graph.facebook.com/', '')
            request_str = request_str.replace('limit=25', 'limit=100')
            success = False
            while (not success):
                try:
                    texts = graph.get(request_str)
                    success = True
                except OAuthError:
                    stdout.write('\nCall Limit Exceeded ! Sleeping for 4 min before retrying !!\n')
                    for i in range(250):
                        stdout.write(('\rSleeing.......%d' % i))
                        stdout.flush()
                        time.sleep(1)
                    stdout.write('Woke Up! Retrying !!\n')
        else:
            texts['data'] = []
def process_texts(texts, friend_name):
    if ('error' in texts):
        print('Error = ', error)
        raise Exception('Error in Response')
    if ('data' not in texts):
        return
    while (len(texts['data']) > 0):
        for text in texts['data']:
            if ('message' not in text):
                continue
            if (friend_name in no_of_messages):
                no_of_messages[friend_name] += 1
                total_chat_length[friend_name] += len(text['message'])
            else:
                no_of_messages[friend_name] = 1
                total_chat_length[friend_name] = len(text['message'])
        if (('paging' in texts) and ('next' in texts['paging'])):
            request_str = texts['paging']['next'].replace('https://graph.facebook.com/', )
            request_str = request_str.replace('limit=25', 'limit=100')
            success = False
            while (not success):
                try:
                    texts = graph.get(request_str)
                    success = True
                except OAuthError:
                    stdout.write('\nCall Limit Exceeded ! Sleeping for 4 min before retrying !!\n')
                    for i in range(250):
                        stdout.write(('\rSleeing.......%d' % i))
                        stdout.flush()
                        time.sleep(1)
                    stdout.write('Woke Up! Retrying !!\n')
        else:
            texts['data'] = []