view bitsytweet/__init__.py @ 4:ed3c5f7ba348

print to stderr instead of dying on exceptions
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 26 Jul 2010 07:08:37 -0700
parents 50f77774a20a
children da132a64926e
line wrap: on
line source

"""
BitsyTweet - tweet your bitsyblog entries (horrid, I know)
"""

import sys
import twitter

class BitsyTweet(object):

  def __init__(self, bitsyblog, username, password):
    self.bitsyblog = bitsyblog
    self.username = username
    self.password = password
    self.api = twitter.Api(username=self.username, password=self.password) 

  def __call__(self, blog_entry, url):
    if blog_entry.privacy == 'public': # only tweet public blogs
      tweet = '%s : %s' % (blog_entry.snippet(), url)
      try:
        self.api.PostUpdate(tweet)
      except Exception, e:
        print >> sys.stderr, "Couldn't tweet %s (%s)" % (url, e)