<commit_before>from tweepy import API
from tweepy import OAuthHandler
import requests
import os

ckey = '<KEY>'
csecret = '<KEY>'
atoken = '<KEY>'
asecret = '<KEY>'



def twitter_api():
    auth = OAuthHandler(ckey, csecret)
    auth.set_access_token(atoken, asecret)
    api = API(auth)
    return api

def capture_and_tweet():
    view_description = "This Description"
    filepath = 'car.png';
    tweet_image(url, view_description, filepath)
    print("Sick tweet")

def tweet_image(url, message, filepath):
    api = twitter_api()
    filename = filepath
    request = requests.get(url, stream=True)
    if request.status_code == 200:
        with open(filename, 'wb') as image:
            for chunk in request:
                image.write(chunk)
                api.update_with_media(filename, status=message)
                os.remove(filename)
            else:
                print("Unable to download image")

url ="http://pngimg.com/uploads/mercedes/mercedes_PNG1898.png"
capture_and_tweet()
<commit_msg>Posting Images with messages to Twitter<commit_after>from tweepy import API
from tweepy import OAuthHandler
import requests
import os
import urlparse, urllib

ckey = '<KEY>'
csecret = '<KEY>'
atoken = '<KEY>'
asecret = '<KEY>'

def twitter_api():
    auth = OAuthHandler(ckey, csecret)
    auth.set_access_token(atoken, asecret)
    api = API(auth)
    return api

def capture_and_tweet():
    view_description = "Boom"
    filepath = '/Users/PCcik/Desktop/image.jpg';
    tweet_image(view_description, filepath)
    print("Sick tweet")

def tweet_image(message, filepath):
    api = twitter_api()
    media = api.media_upload(filepath)
    api.update_status(status=message, media_ids=[media.media_id])


capture_and_tweet()

{'fraction_non_alphanumeric': 0.11072862880091795, 'fraction_numerical': 0.004016064257028112, 'mean_word_length': 3.5416666666666665, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4393141', 'n_tokens_mistral': 584, 'n_tokens_neox': 561, 'n_words': 137}