comparison 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
comparison
equal deleted inserted replaced
3:50f77774a20a 4:ed3c5f7ba348
1 """ 1 """
2 BitsyTweet 2 BitsyTweet - tweet your bitsyblog entries (horrid, I know)
3 """ 3 """
4 4
5 import sys
5 import twitter 6 import twitter
6 7
7 class BitsyTweet(object): 8 class BitsyTweet(object):
8 9
9 def __init__(self, bitsyblog, username, password): 10 def __init__(self, bitsyblog, username, password):
13 self.api = twitter.Api(username=self.username, password=self.password) 14 self.api = twitter.Api(username=self.username, password=self.password)
14 15
15 def __call__(self, blog_entry, url): 16 def __call__(self, blog_entry, url):
16 if blog_entry.privacy == 'public': # only tweet public blogs 17 if blog_entry.privacy == 'public': # only tweet public blogs
17 tweet = '%s : %s' % (blog_entry.snippet(), url) 18 tweet = '%s : %s' % (blog_entry.snippet(), url)
18 self.api.PostUpdate(tweet) 19 try:
20 self.api.PostUpdate(tweet)
21 except Exception, e:
22 print >> sys.stderr, "Couldn't tweet %s (%s)" % (url, e)