Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 44 lines (38 sloc) 1.34 KB
import csv
import datetime
import tweepy
# cron settings
# * * 12 03 * python /home/shared-drives/litclock/
# paths have to be explicit for cron
path = '/home/shared-drives/litclock/'
# separate the credits out to keep out of github
def creds():
with open(path + 'creds.csv', 'r') as csvfile:
creds = csv.DictReader(csvfile, delimiter=",")
row =
return row['token'], row['secret'], row['akey'], row['asecret']
def text():
now =
with open(path + 'tweets.csv', 'r') as csvfile:
tweets = csv.DictReader(csvfile, delimiter=",")
for row in tweets:
ft = row['time']
hour = int(ft.split(':')[0])
minute = int(ft.split(':')[1])
if hour == now.hour and minute == now.minute:
return row['text']
def tweet(k, t):
# k stores token, secret, api key, and api secret
auth = tweepy.OAuthHandler(k[2], k[3])
auth.set_access_token(k[0], k[1])
api = tweepy.API(auth)
# dummy write to a file instead of tweeting
# f = open(path + 'log.txt', 'a')
# f.write(t + '\n')
except tweepy.error.TweepError, e:
# implement logging later
# print 'failed because of %s' % e.reason
tweet(creds(), text())