Code that powers the @abovebrum Twitter account.
There are three scripts:
- scrape – runs daily to fetch the flare/ISS times from heavens-above.com
- weather – runs hourly to fetch the latest weather from forecast.io
- twitter – runs every five minutes to see if something is coming up that needs to be sent to Twitter.
Install tweepy (a third party application to talk to the Twitter API):
$ virtualenv venv $ source venv/bin/activate $ pip install tweepy
Clone the repository:
$ git clone https://github.com/dracos/abovebrum $ cd abovebrum $ cp config.py-example config.py
Now open up config.py and change the co-ordinates to wherever you want to run the service (that's for looking up flare times). Put your tokens and secrets in the appropriate places to enable Twitter posting access and forecast.io lookup.
Set up cronjobs (or however you want to do it) that run
weather every hour,
scrape once a day, and
2 2 * * * /home/matthew/bin/abovebrum/venv/bin/python /home/matthew/bin/abovebrum/scrape 57 * * * * /home/matthew/bin/abovebrum/venv/bin/python /home/matthew/bin/abovebrum/weather */5 * * * * /home/matthew/bin/abovebrum/venv/bin/python /home/matthew/bin/abovebrum/twitter
That should be it.