I’m getting back into Fedora stuff again (working on front-end dev & design for Hyperkitty). I originally submitted something for consideration back in October, but since it’s been awhile, I thought I’d try to see how easy it would be to integrate my submission into the main repo via a pull request.

Turns out it wasn’t as easy as I had hoped. It was recommended that I do a rebase, but that ended up leading to lots of conflicts. Most likely because there had been other front-end commits before mine, which meant that we had conflicting version of some of the same files. I also ended up reading up online what rebasing is like; one thing lead to another, and I ended up having all the concepts swirl in my head and after several rebase/merge/resets my local git was just a mess.

Luckily all the important checkins are posted to Github, so I figured why don’t I just start from a clean slate? It had been a few weeks since I last got my hands dirty anyways, so it would be a good refresher for me, and this way I’d also be starting with a clean slate.

So I went back to the handy Hyperkitty Development Guide and follow the steps there. Just for record keeping, I’m recording my steps here:

# assumes you have already have the essentials. if not, install these:
# sudo yum install bzr python-setuptools python-devel python-virtualenv
# sudo yum groupinstall 'Development Tools'
# sudo yum groupinstall 'Development Libraries' 
 
# grab all the source code
cd ~/Repos
bzr launchpad-login <launchpad-username>
bzr branch lp:mailman
bzr branch lp:mailman.client
bzr branch lp:postorius
bzr branch lp:~mailman-coders/postorius/postorius_standalone
git clone https://github.com/hyperkitty/kittystore.git
git clone https://github.com/hyperkitty/hyperkitty.git
git clone https://github.com/hyperkitty/hyperkitty_standalone.git
 
# create isolated Python environment where you can add Hyperkitty 
# and its dependencies without messing up your system Python install
virtualenv venv_hk
source venv_hk/bin/activate
 
# install dependencies for Hyperkitty/Mailman 
pip install django
pip install django-social-auth
 
# setup Mailman 3
cd mailman
python setup.py install
venv_hk/bin/mailman start
cd ..
 
# setup mailman.client (Python bindings for Mailman's REST API) and Postorius
cd mailman.client
python setup.py develop
cd ..
cd postorius
python setup.py develop
cd ..
 
# start Postorius development server
cd postorius_standalone
python manage.py syncdb # see note below if you encounter an error
python manage.py runserver &
cd ..
# Now go to http://localhost:8000 to see the web UI for Mailman
 
# set up Hyperkitty
cd kittystore
python setup.py develop
cd ..
cd hyperkitty
python setup.py develop
cd ..
 
# configure Hyperkitty settings
cd hyperkitty_standalone
cp settings.py settings_local.py
nano settings_local.py
# refer to development guide for what variables to change 
# (DEBUG, USE_SSL, DATABASES, KITTYSTORE_URL, KITTYSTORE_SEARCH_INDEX)
 
# setup Hyperkitty database
cd ~/Repos/hyperkitty_standalone
mkdir srv
cd srv
mkdir hyperkitty
cd ../..
python manage.py syncdb  # see note below, if you encounter an error
python manage.py migrate hyperkitty
cd ..
 
# setup Kittystore database
cd hyperkitty_standalone
kittystore-updatedb -p ~/Repos/hyperkitty_standalone -s settings
kittystore-download21 -u http://lists.fedoraproject.org -l cloud
kittystore-import --settings settings --pythonpath . -l cloud@lists.fedoraproject.org *.txt
 
# start Hyperkitty development server
cd hyperkitty_standalone
python manage.py syncdb # see note below if you encounter an error
python manage.py runserver 8002 &
cd ..
# Now go to http://localhost:8002 to see the web UI for Hyperkitty

Note 1: You might run into problems running python manage.py syncdb for Postorius and see this error message:

Traceback (most recent call last):
  File "manage.py", line 20, in 
    from django.core.management import execute_manager
ImportError: cannot import name execute_manager

Turns out execute_manager is deprecated in Django 1.4+. And since my version of Django is 1.6, I got this error. To fix this, I had to edit manage.py. I based my version on similar examples found here and here.

#! /usr/bin/env python
import os
import sys
import django

try:
    import settings # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
    sys.exit(1)

if __name__ == "__main__":
    if django.VERSION[0:2] >= (1, 4):
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") #path to the settings py file
        from django.core.management import execute_from_command_line
        execute_from_command_line(sys.argv)
    else:
        from django.core.management import execute_manager
        execute_manager(settings)

Note 2: You might run into a similar problem running python manage.py syncdb for Hyperkitty and encounter the same error message about execute_manager. Make the same kinds of edit you did for Postorius in Hyperkitty’s manage.py and the problem should be solved.

Note 3: You might see this error message when running python manage.py syncdb for Hyperkitty:

django.db.utils.OperationalError: unable to open database file

 

This might be because you forgot to first create the path you specified in settings_local.py. For me, this meant making sure that the path ~/Repos/hyperkitty_standalone/srv/hyperkitty exists. There is also a chance that python prefers absolute paths, in which case you should use, for example, /home/<user>/Repos/hyperkitty_standalone/srv/hyperkitty/hyperkitty-db.db in settings_local.py, instead of ~/Repos/hyperkitty_standalone/srv/hyperkitty/hyperkitty-db.db.

Note 4: I tried to use django-admin since that’s what the latest version of the Hyperkitty docs say to use, but no matter what I did I just couldn’t get things to work. I always ended up with this error:

ImportError: Could not import settings 'settings' (Is it on sys.path? 
Is there an import error in the settings file?): No module named settings

I could import the file when using the interactive python shell, but I couldn’t seem to get things to work when running from the commandline (using: django-admin.py syncdb --pythonpath hyperkitty_standalone --settings settings).

Since the Django docs seem to suggest that manage.py and django-admin.py> serve similar purposes, I decided to just use manage.py since that seemed to work for me.

Leave a Comment

Your email address will not be published. Required fields are marked *