<commit_before>from auth import secrets

import requests
import urlparse
from tumblpy import Tumblpy
import cv

environ = secrets()
cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
camera_index = 0

def take_photo():
  capture = cv.CaptureFromCAM(camera_index)
  frame = cv.QueryFrame(capture)
  cv.SaveImage("pic.jpg", frame)

def post_to_tumblr():
  # Initialize
  t = Tumblpy(environ['tumblr_oauth'], environ['tumblr_secret'])

  # Ask for tokens
  auth_props = t.get_authentication_tokens(callback_url='http://meyow.herokuapp.com')
  auth_url = auth_props['auth_url']

  # Parse the OAuth token from the response
  url = auth_url
  parsed = urlparse.urlparse(url)
  token = urlparse.parse_qs(parsed.query)['oauth_token'][0]

  # Collect them all
  CONSUMER_KEY = environ['tumblr_oauth']
  CONSUMER_SECRET = environ['tumblr_secret']
  OAUTH_TOKEN = token
  OAUTH_TOKEN_SECRET = auth_props['oauth_token_secret']

  print CONSUMER_KEY
  print CONSUMER_SECRET
  print OAUTH_TOKEN
  print OAUTH_TOKEN_SECRET

  # Authenticate dat
  t = Tumblpy(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

  # Get the blog URL we're looking for
  blog_url = t.post('user/info')
  # blog_url = blog_url['user']['blogs'][0]['url']

  # blog_url = 'http://meyow-me.tumblr.com';

  # Load the photo and post to Tumblr
  photo = open('pic.jpg', 'rb')
  post = t.post('post', blog_url=blog_url, params={'type':'photo', 'caption': 'Test Caption', 'data': photo})

if __name__ == "__main__":
  post_to_tumblr()<commit_msg>Fix Tumblr posting<commit_after>from auth import secrets

import requests
import urlparse
from tumblpy import Tumblpy
import cv

environ = secrets()
cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
camera_index = 0

def take_photo():
  capture = cv.CaptureFromCAM(camera_index)
  frame = cv.QueryFrame(capture)
  cv.SaveImage("pic.jpg", frame)

def post_to_tumblr():
  # Collect them all
  CONSUMER_KEY = environ['tumblr_consumer_key']
  CONSUMER_SECRET = environ['tumblr_consumer_secret']
  OAUTH_TOKEN = environ['tumblr_auth_token']
  OAUTH_TOKEN_SECRET = environ['tumblr_auth_token_secret']

  # Authenticate dat
  t = Tumblpy(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

  # Load the photo and post to Tumblr
  photo = open('pic.jpg', 'rb')
  post = t.post('post', blog_url='http://meyow-me.tumblr.com', params={'type':'photo', 'caption': 'Test Caption', 'data': photo})


def send_tumblr():
  take_photo()
  post_to_tumblr()
  
if __name__ == "__main__":
  send_tumblr()
{'fraction_non_alphanumeric': 0.12355057976809276, 'fraction_numerical': 0.0023990403838464614, 'mean_word_length': 5.398976982097187, 'pattern_counts': {'":': 2, '<': 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': '2793774', 'n_tokens_mistral': 970, 'n_tokens_neox': 927, 'n_words': 192}