Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
32 reddittweeter.py → bin/reddittweeter.py
@@ -17,7 +17,6 @@
debug = False
-dbname = 'reddittweeter.db'
maxtweets = 10 # don't tweet more than this in one session
keepfor = timedelta(days=30) # how long to keep articles in the sqlite
# cache to keep them from being tweeted
@@ -108,7 +107,7 @@ def tweet_item(entry):
def main(sourceurl, twitter_consumer, twitter_secret,
- twitter_access_key, twitter_access_secret):
+ twitter_access_key, twitter_access_secret, dbname):
engine = create_engine('sqlite:///%s' % dbname, echo = debug)
Session = sessionmaker(bind=engine)
session = Session()
@@ -173,17 +172,22 @@ def main(sourceurl, twitter_consumer, twitter_secret,
if __name__ == '__main__':
- if len(sys.argv) != 6:
- print "Usage: reddittweeter SOURCEURL TWITTER_CONSUMER TWITTER_SECRET ACCESS_KEY ACCESS_SECRET"
+ if len(sys.argv) != 3:
+ print "Usage: reddittweeter CONFIG_FILE URL"
sys.exit(1)
- sourceurl = sys.argv[1]
- # these are the tokens you get with your registered app
- twitter_consumer = sys.argv[2]
- twitter_secret = sys.argv[3]
- # these are the credentials for the account doing the tweeting. See
- # http://joshthecoder.github.com/tweepy/docs/auth_tutorial.html
- twitter_access_key = sys.argv[4]
- twitter_access_secret = sys.argv[5]
-
+ config_filename = sys.argv[1]
+ sourceurl = sys.argv[2]
+
+ import ConfigParser
+ parser = ConfigParser.RawConfigParser()
+ with open(config_filename, "r") as f:
+ parser.readfp(f)
+
+ twitter_consumer = parser.get("twitter", "consumer")
+ twitter_secret = parser.get("twitter", "secret")
+ twitter_access_key = parser.get("twitter", "access_key")
+ twitter_access_secret = parser.get("twitter", "access_secret")
+ dbname = parser.get("storage", "db_path")
+
main(sourceurl, twitter_consumer, twitter_secret,
- twitter_access_key, twitter_access_secret)
+ twitter_access_key, twitter_access_secret, dbname)
View
13 etc/reddittweeter.ini.example
@@ -0,0 +1,13 @@
+[twitter]
+# these are the tokens you get with your registered app
+consumer = sldkfjsl
+secret = sldkfjlksjdf
+
+# these are the credentials for the account doing the tweeting. See
+# http://joshthecoder.github.com/tweepy/docs/auth_tutorial.html
+access_key = abc
+access_secret = 123
+
+[storage]
+# the path to the sqlite database for the tweeter
+db_path = /var/opt/reddittweeter/reddittweeter.db
View
6 reddit-tweeter.conf
@@ -0,0 +1,6 @@
+description "tweet the hottest links from a given listing"
+
+task
+instance $ini $url
+
+exec /opt/reddittweeter/bin/reddittweeter.py "$ini" "$url"

No commit comments for this range

Something went wrong with that request. Please try again.