From eabe587408c46aa52e35f9a6db356323511ac440 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Sun, 3 May 2015 20:08:32 +0000 Subject: [PATCH] Added tasks app --- README.md | 17 +++++++++++++---- TODO.md | 11 +++++++---- orchestra/bin/orchestra-admin | 18 ++++-------------- .../project_template/project_name/settings.py | 1 + orchestra/contrib/tasks/__init__.py | 1 + 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 1e290623..e7c80d1d 100644 --- a/README.md +++ b/README.md @@ -34,11 +34,20 @@ Fast Deployment Setup To only run the Python interface follow these steps: ```bash -python3 -menv env-django-orchestra +# Create a new virtualenv +python3 -mvenv env-django-orchestra source env-django-orchestra/bin/activate -echo $HOME/django-orchestra/ | sudo tee env-django-orchestra/lib/python3*/site-packages/orchestra.pth -pip3 install -r $HOME/django-orchestra/requirements.txt -django-admin.py startproject panel --template="$HOME/django-orchestra/orchestra/conf/project_template" +pip3 install django-orchestra==dev \ + --allow-external django-orchestra \ + --allow-unverified django-orchestra + +# Install dependencies +sudo apt-get install python3.4-dev libxml2-dev libxslt1-dev libcrack2-dev +pip3 install -r \ + https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/requirements.txt + +# Create an orchestra instance +orchestra-admin startproject panel python3 panel/manage.py migrate accounts python3 panel/manage.py migrate python3 panel/manage.py runserver diff --git a/TODO.md b/TODO.md index c50a5db3..84fcc4db 100644 --- a/TODO.md +++ b/TODO.md @@ -311,14 +311,16 @@ Replace celery by a custom solution? *priority: custom Thread backend *bulk: wrapper arround django-mailer to avoid loading django system +# Create a new virtualenv python3 -mvenv env-django-orchestra source env-django-orchestra/bin/activate pip3 install django-orchestra==dev --allow-external django-orchestra --allow-unverified django-orchestra + +# Install dependencies +sudo apt-get install python3.4-dev libxml2-dev libxslt1-dev libcrack2-dev pip3 install -r https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/requirements.txt -# TODO make them optional -sudo apt-get install python3.4-dev libxml2-dev libxslt1-dev libcrack2-dev -wget -O - https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/requirements.txt | xargs pip3 install +# Create an orchestra instance orchestra-admin startproject panel python3 panel/manage.py migrate accounts python3 panel/manage.py migrate @@ -352,9 +354,10 @@ Collecting lxml==3.3.5 (from -r re (line 22)) # deprecate install_dependnecies in favour of only requirements.txt # import module and sed # if setting.value == default. remove -# cron backend: os.cron or uwsgi.cron +# TASKS_ENABLE_UWSGI_CRON # reload generic admin view ?redirect=http... # inspecting django db connection for asserting db readines? # wake up django mailer on send_mail # project settings modified copy of django's default project settings + diff --git a/orchestra/bin/orchestra-admin b/orchestra/bin/orchestra-admin index 6c0ebfc2..2db723bb 100755 --- a/orchestra/bin/orchestra-admin +++ b/orchestra/bin/orchestra-admin @@ -131,8 +131,6 @@ function install_requirements () { python3-pip \ python3-psycopg2 \ python3-lxml \ - postgresql \ - rabbitmq-server \ python3-dev \ bind9utils \ python3-cracklib \ @@ -143,7 +141,7 @@ function install_requirements () { gettext" # TODO remove celery deps, django 1.8.1, glic3rinu fork, celery email - PIP="django==1.8 \ + PIP="django==1.8.1 \ django-celery-email==1.0.4 \ https://github.com/glic3rinu/django-fluent-dashboard/archive/master.zip \ https://bitbucket.org/izi/django-admin-tools/get/a0abfffd76a0.zip \ @@ -208,20 +206,12 @@ function install_requirements () { run pip3 install $PIP - # TODO remove - # Some versions of rabbitmq-server will not start automatically by default unless ... - sed -i "s/# Default-Start:.*/# Default-Start: 2 3 4 5/" /etc/init.d/rabbitmq-server - sed -i "s/# Default-Stop:.*/# Default-Stop: 0 1 6/" /etc/init.d/rabbitmq-server - run update-rc.d rabbitmq-server defaults - # Patch passlib - # TODO discover locaion by importing it IMPORT="from django.contrib.auth.hashers import mask_hash, _" COLLECTIONS="from collections import OrderedDict" - ls /usr/local/lib/python*/dist-packages/passlib/ext/django/utils.py \ - | xargs sed -i "s/${IMPORT}, SortedDict/${IMPORT}\n ${COLLECTIONS}/" - ls /usr/local/lib/python*/dist-packages/passlib/ext/django/utils.py \ - | xargs sed -i "s/SortedDict/OrderedDict/g" + PASSLIB_PATH=$(python3 -c "from passlib.ext.django import utils; print(utils.__file__)") + sed -i "s/${IMPORT}, SortedDict/${IMPORT}\n ${COLLECTIONS}/" $PASSLIB_PATH + sed -i "s/SortedDict/OrderedDict/g" $PASSLIB_PATH } export -f install_requirements diff --git a/orchestra/conf/project_template/project_name/settings.py b/orchestra/conf/project_template/project_name/settings.py index 1a54465c..dd85ed9d 100644 --- a/orchestra/conf/project_template/project_name/settings.py +++ b/orchestra/conf/project_template/project_name/settings.py @@ -273,3 +273,4 @@ FLUENT_DASHBOARD_APP_ICONS = { # Django-celery import djcelery djcelery.setup_loader() +CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler' diff --git a/orchestra/contrib/tasks/__init__.py b/orchestra/contrib/tasks/__init__.py index dd2c46b0..af70fc11 100644 --- a/orchestra/contrib/tasks/__init__.py +++ b/orchestra/contrib/tasks/__init__.py @@ -78,6 +78,7 @@ def apply_async_override(fn, name): def task(fn=None, **kwargs): + # TODO override this if 'celerybeat' in sys.argv ? from . import settings # register task if fn is None: