~ubuntu-branches/ubuntu/saucy/dput-ng/saucy-proposed

« back to all changes in this revision

Viewing changes to examples/hooks/twitter/code/tweet.py

  • Committer: Package Import Robot
  • Author(s): Paul Tagliamonte, Paul Tagliamonte, Arno Töll
  • Date: 2012-12-26 09:30:06 UTC
  • Revision ID: package-import@ubuntu.com-20121226093006-8oebt2qovy5stc8a
Tags: 1.3
* The "we're so proud of our work, we need to let everyone know" release

[ Paul Tagliamonte ]
* Avoid failing on upload if a pre/post upload hook is missing from the
  Filesystem. Thanks to Moritz Mühlenhoff for the report. (Closes: #696659)
* Adjust Homepage: to point to our spiffy debian.net alias, rather then
  my people.debian.
* Add in experiemental clojure support via clojurepy hackery. It's
  amazingly cool, really. Thanks to Paul Tagliamonte for the extremely
  nice patch. Well done.

[ Arno Töll ]
* Fix "dcut raises FtpUploadException" by correctly initializing the uploader
  classes from dcut (Closes: #696467)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) Paul Tagliamonte, 2012, under the terms of dput-ng.
 
2
# Example: https://twitter.com/paultag/status/257981606139133954
 
3
 
 
4
import twitter
 
5
import json
 
6
import os
 
7
 
 
8
 
 
9
def tweet(changes, profile, interface):
 
10
    tweet = "I've just uploaded %s/%s to %s's %s suite #debian" % (
 
11
        changes['Source'],
 
12
        changes['Version'],
 
13
        profile['name'],
 
14
        changes['Distribution']
 
15
    )
 
16
    if len(tweet) > 140:
 
17
        tweet = tweet[:140]
 
18
 
 
19
    obj = json.load(open(os.path.expanduser("~/.twitter.json"), 'r'))
 
20
    t = twitter.Api(
 
21
        consumer_key=obj['consumer_key'],
 
22
        consumer_secret=obj['consumer_secret'],
 
23
        access_token_key=obj['oath_token'],
 
24
        access_token_secret=obj['oath_secret']
 
25
    )
 
26
 
 
27
    t.PostUpdates(tweet)