def install(): adduser('django') dcfg = django.config() status_set('maintenance', 'installing system deps') apt_install(['build-essential', 'binutils-doc', 'autoconf', 'authbind', 'bison', 'libjpeg-dev', 'libfreetype6-dev', 'zlib1g-dev', 'libzmq3-dev', 'libgdbm-dev', 'libncurses5-dev', 'automake', 'libtool', 'libffi-dev', 'curl', 'git', 'gettext', 'flex', 'postgresql-client', 'postgresql-client-common', 'python3', 'python3-pip', 'python-dev', 'python3-dev', 'python-pip', 'libxml2-dev', 'virtualenvwrapper', 'libxslt-dev', 'git-core', 'python-git', 'libpq-dev'] + dcfg.get('apt-packages', [])) subprocess.check_call([django.pip(), 'install', 'circus', 'gunicorn', ]) source_install(dcfg) open_port(config('django-port')) start()
def connect_db(pgsql): dcfg = django.config() apt_install(['python-psycopg2']) ctx = { 'database': pgsql, 'debug': config('django-debug'), 'settings_import': dcfg.get('settings-import', '.settings'), 'media_path': os.path.join(dcfg.get('source-path'), dcfg.get('media-path')), 'static_path': os.path.join(dcfg.get('source-path'), dcfg.get('static-path')), } off = 0 # Offset import_settings = dcfg.get('settings-import', '.settings') if import_settings.startswith('.'): off = 1 cfg_path = os.path.dirname(import_settings[off:].replace('.', '/')) settings_cfg = os.path.join(dcfg.get('source-path'), cfg_path, 'juju.py') status_set('maintenance', 'writing Django settings') render(source='local.py.j2', target=settings_cfg, owner='django', group='django', perms=0o644, context=ctx) dcfg.set('config-path', os.path.join(dcfg.get('source-path'), cfg_path, 'juju.py')) dcfg.set('config-import', '.'.join([cfg_path, 'juju'])) source_install(dcfg) set_state('django.configured')