<commit_before>#!/usr/bin/env python

import argparse
import twitter
import random
import time
import json

parser = argparse.ArgumentParser()
parser.add_argument('buildfile', help='built line file location')
args = parser.parse_args()

with open(args.buildfile) as buildfile:
    builtObject = json.load(buildfile)

print "Lines loaded"

api = twitter.Api(consumer_key = builtObject['key'], consumer_secret = builtObject['secret'],
    access_token_key = builtObject['oauthtoken'], access_token_secret = builtObject['oauthsecret'])

print "Connected to twitter"

def tweetLine():
    randLine = random.choice(builtObject['lines'])
    api.PostUpdate(status=randLine)
    print "Tweeted '" + randLine.strip('\n') + "'"
    time.sleep(int(builtObject['interval']))

print "Tweeting lines from", builtObject['title'], "every", builtObject['interval'], "seconds"

while True:
    tweetLine()<commit_msg>Add duplicate error handling<commit_after>#!/usr/bin/env python

import argparse
import twitter
import random
import time
import json

parser = argparse.ArgumentParser()
parser.add_argument('buildfile', help='built line file location')
args = parser.parse_args()

with open(args.buildfile) as buildfile:
    builtObject = json.load(buildfile)

print "Lines loaded"

api = twitter.Api(consumer_key = builtObject['key'], consumer_secret = builtObject['secret'],
    access_token_key = builtObject['oauthtoken'], access_token_secret = builtObject['oauthsecret'])

print "Connected to twitter"

def tweetLine():
    randLine = random.choice(builtObject['lines'])
    try:
        api.PostUpdate(status=randLine)
        print "Tweeted '" + randLine.strip('\n') + "'"
        time.sleep(int(builtObject['interval']))
    except TwitterError as e:
        # 99% of the time, this is a duplicate tweet
        print "Skipping duplicate"
    

print "Tweeting lines from", builtObject['title'], "every", builtObject['interval'], "seconds"

while True:
    tweetLine()
{'fraction_non_alphanumeric': 0.12914752424706483, 'fraction_numerical': 0.0010209290454313426, 'mean_word_length': 5.222222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3412522', 'n_tokens_mistral': 589, 'n_tokens_neox': 576, 'n_words': 145}