Wednesday, November 16, 2011

Another strange Django error

If you stumble across the error in Django 1.3:

  File "/Users/brad/work/django-formwizard/.env/lib/python2.7/site-packages/django/core/", line 368, in reverse
    app_list = resolver.app_dict[ns]
  File "/Users/brad/work/django-formwizard/.env/lib/python2.7/site-packages/django/core/", line 241, in _get_app_dict
  File "/Users/brad/work/django-formwizard/.env/lib/python2.7/site-packages/django/core/", line 198, in _populate
    p_pattern = pattern.regex.pattern
AttributeError: 'str' object has no attribute 'regex'

Or in Django 1.4:


  File "/brew/Cellar/python/2.7.1/lib/python2.7/site-packages/django/core/handlers/", line 101, in get_response
  File "/brew/Cellar/python/2.7.1/lib/python2.7/site-packages/django/core/", line 300, in resolve
    sub_match = pattern.resolve(new_path)
AttributeError: 'str' object has no attribute 'resolve'

You have probably accidentally left a trailing comma in the URLCONF_ROOT setting, i.e.:

ROOT_URLCONF = 'project.urls',

Sunday, November 13, 2011

Strange UTF-8 decoding error with Jenkins + Python

I've come across a strange problem while setting up Jenkins to build Python projects. For some reason I get the following error:

Traceback (most recent call last):
  File "", line 32, in <module>
    'Topic :: Software Development :: Libraries :: Python Modules',
  File "/usr/local/lib/python2.7/distutils/", line 152, in setup

  File "/home/jenkins/.jenkins/jobs/django-console/workspace/django_attest-0.1.1-py2.7.egg/django_attest/", line 0
SyntaxError: 'NoneType' object has no attribute 'utf_8_decode'

In any case it's fixed by adding the following as an environment variable (I added it to the Properties Content section):

Thursday, November 10, 2011

Upstart + Jenkins

I've been playing with Jenkins for CI of Python projects. I run Jenkins on, and then use Apache2 to proxy a domain to it. Here's a simple virtual host configuration I found somewhere:

<VirtualHost *:80>
    ServerName jenkins
    ProxyPass         /  http://localhost:8081/
    ProxyPassReverse  /  http://localhost:8081/
    ProxyRequests     Off
    # Local reverse proxy authorization override
    # Most unix distribution deny proxy by default (ie
    # /etc/apache2/mods-enabled/proxy.conf in Ubuntu)
    <Proxy http://localhost:8081*>
      Order deny,allow
      Allow from all

Lastly I wrote an Upstart job in /etc/init/jenkins.conf to keep it running across restarts:

description "Jenkins"

start on started network-services
stop on stopping network-services

cd /home/jenkins
sudo -Hu jenkins java -jar jenkins.war -Djava.awt.headless=true --httpPort=8081 --httpListenAddress=
end script