changeset 7:dfbb21128332

merge commit
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 25 Nov 2010 13:09:23 -0800
parents 3cb8ad35fe62 (diff) da132a64926e (current diff)
children 76b8f41da4cf
files bitsytweet/__init__.py
diffstat 1 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bitsytweet/__init__.py	Thu Nov 25 12:08:05 2010 -0800
+++ b/bitsytweet/__init__.py	Thu Nov 25 13:09:23 2010 -0800
@@ -22,3 +22,38 @@
       except Exception, e:
         print >> sys.stderr, "Couldn't tweet %s (%s)" % (url, e)
       print '</tweet>'
+
+def main(args=sys.argv[1:]):
+  """debugging front-end for BitstTweet"""
+  
+  usage = "%prog [options] tweet"
+  from optparse import OptionParser
+  parser = OptionParser(usage=usage)
+  parser.add_option('-u', '--username',
+                    help='username')
+  parser.add_option('-p', '--password',
+                    help='password')
+  options, args = parser.parse_args(args)
+  if not options.username:
+    parser.error('please provide a username')
+  if not options.password:
+    parser.error('please provide a password')
+  if not args:
+    parser.error('please provide a post')
+
+  # get the tweeter
+  bitsytweet = BitsyTweet(None, options.username, options.password)
+
+  # make a dummy class
+  class Dummy(object):
+    def __init__(self, tweet):
+      self.tweet = tweet
+    def snippet(self):
+      return self.tweet
+  blog_entry = Dummy(' '.join(args))
+
+  # tweet it
+  bitsytweet(blog_entry, 'http://k0s.org/blog')
+
+if __name__ == '__main__':
+  main()