Daily Bruin's Twitter and Facebook poster
1. Install system packages
These instructions are meant for Ubuntu. If you are using something other than ubuntu, find the packages on your own.
If you want to use Vagrant, clone this repo and
vagrant up will automatically install everything in this section.
Install the required packages:
sudo apt-get update sudo apt-get install python-pip python-setuptools python-dev fabric git postgresql postgresql-server-dev-9.1 sendmail
2. Create a virtual environment (optional)
I prefer virtualenvwrapper since virtualenv depends on symlinks and VirtualBox shared folders don't support symlinks.
Install it like this:
sudo easy_install virtualenv sudo pip install virtualenvwrapper
And add this line to your
Make a virtualenv:
And activate the vitualenv (it does this automatically after creating it):
3. Install python packages
Install psycopg2 (a postgres adapter) outside of your virtualenv
Then within your virtualenv install everything in
requirements.txt within this repo
pip install -r requirements.txt
4. Configure django
Configure your database in django. For development environments, open
/etc/postgresql/9.1/main/pg_hba.conf in a text editor (you may need to install something like
vim) and, around line 84, change the word
trust like so:
# Database administrative login by Unix domain socket local all postgres trust # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust
reload the database:
Create a database (this makes a database with the name "meow"):
createdb -U postgres meow
meow/meow/settings.py configure your database settings. If you followed these instructions, this should work:
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'meow', 'USER': 'postgres', 'PASSWORD': '',
Sync the databases through django and create your own superuser:
python manage.py syncdb python manage.py migrate
5. Configure meow
python manage.py init to configure all settings.
For this part of the set up you will need
twitter consumer key and consumer secret: https://apps.twitter.com/app/new
additionally for twitter, you will need to fill in the Callback URL
facebook app ID and app secret: https://developers.facebook.com/docs/apps/register
bitly access token: https://bitly.com/a/oauth_apps
6. Configure sections
Use the default Django admin (http://[YOUR_URL]/admin) to add a Section object. To find Twitter access keys/tokens, use the instructions at
python manage.py twitter_auth
and to find the Facebook tokens, use these instructions.
Run meow by going into the
meow directory of the repo and typing
This will run meow on 0.0.0.0:8000 (not the default 127.0.0.1:8000) so it can be accessible from other machines. (i.e. accessing meow from a host when meow is running on a VM).
If you want to run it on a different port, the fabric command takes an argument. For instance,
will listen on port 2000.
Tweets are sent through a management command. In
python manage.py sendposts
This will send any posts that are marked as copy-edited and ready for publication but are not yet sent. If you want posts to send automatically, put this on a cron job.
The Daily Bruin's cron job is something like:
#! /bin/bash source meow-venv/bin/activate python meow/manage.py sendposts
sendposts will output the facebook post or tweet when it tries to send to
stdout (in ASCII) so feel free to implement logging. Almost all sending errors, however, are saved within meow's database for easy access.
These are only used for testing and are set as private. When testing is over, these accounts should be deleted and removed from this page.
Meow is released under GNU AGPLv3. See
LICENSE for more details.
Though not required, if you use this software or would like to contribute to its development, please let us know by emailing us at firstname.lastname@example.org. We'd love to know what it's being used for, especially if it's at another college newspaper.