Merge branch 'feature/github_issue_17' into development
This commit is contained in:
@@ -7,6 +7,7 @@ from django.db import transaction
|
||||
from django.core import serializers
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.db import models
|
||||
from django.db.utils import DatabaseError
|
||||
|
||||
from .models import HistoryType, History
|
||||
from .runtime_data import history_types_dict
|
||||
@@ -17,9 +18,13 @@ def register_history_type(history_type_dict):
|
||||
namespace = history_type_dict['namespace']
|
||||
name = history_type_dict['name']
|
||||
|
||||
history_type_obj, created = HistoryType.objects.get_or_create(
|
||||
namespace=namespace, name=name)
|
||||
history_type_obj.save()
|
||||
try:
|
||||
history_type_obj, created = HistoryType.objects.get_or_create(
|
||||
namespace=namespace, name=name)
|
||||
history_type_obj.save()
|
||||
except DatabaseError:
|
||||
# Special case for syncdb
|
||||
pass
|
||||
|
||||
# Runtime
|
||||
history_types_dict.setdefault(namespace, {})
|
||||
|
||||
@@ -1,16 +1,2 @@
|
||||
from celery.decorators import task, periodic_task
|
||||
from celery.task.control import inspect
|
||||
|
||||
from job_processor.conf.settings import BACKEND
|
||||
|
||||
|
||||
@task
|
||||
def celery_task(func, *args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
||||
def process_job(func, *args, **kwargs):
|
||||
if BACKEND == 'celery':
|
||||
return celery_task.delay(func, *args, **kwargs)
|
||||
elif BACKEND is None:
|
||||
return func(*args, **kwargs)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
"""Configuration options for the job_processing app"""
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from smart_settings.api import register_settings
|
||||
|
||||
register_settings(
|
||||
namespace=u'job_processor',
|
||||
module=u'job_processor.conf.settings',
|
||||
settings=[
|
||||
{'name': u'BACKEND', 'global_name': u'JOB_PROCESSING_BACKEND', 'default': None, 'description': _('Specified which job processing library to use, option are: None and celery.')},
|
||||
]
|
||||
)
|
||||
@@ -5,7 +5,7 @@ import logging
|
||||
from django.db import transaction
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext
|
||||
from django.db.models.signals import post_save
|
||||
from django.db.models.signals import post_save, post_syncdb
|
||||
from django.dispatch import receiver
|
||||
|
||||
from navigation.api import register_links, register_multi_item_links
|
||||
@@ -23,6 +23,7 @@ from .permissions import (PERMISSION_OCR_DOCUMENT,
|
||||
PERMISSION_OCR_DOCUMENT_DELETE, PERMISSION_OCR_QUEUE_ENABLE_DISABLE,
|
||||
PERMISSION_OCR_CLEAN_ALL_PAGES)
|
||||
from .exceptions import AlreadyQueued
|
||||
from . import models as ocr_models
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -77,11 +78,10 @@ def document_post_save(sender, instance, **kwargs):
|
||||
logger.debug('instance: %s' % instance)
|
||||
if kwargs.get('created', False):
|
||||
if AUTOMATIC_OCR:
|
||||
try:
|
||||
DocumentQueue.objects.queue_document(instance.document)
|
||||
except AlreadyQueued:
|
||||
pass
|
||||
|
||||
try:
|
||||
DocumentQueue.objects.queue_document(instance.document)
|
||||
except AlreadyQueued:
|
||||
pass
|
||||
|
||||
# Disabled because it appears Django execute signals using the same
|
||||
# process of the signal emiter effectively blocking the view until
|
||||
@@ -92,7 +92,9 @@ def document_post_save(sender, instance, **kwargs):
|
||||
# logger.debug('got call_queue signal: %s' % kwargs)
|
||||
# task_process_document_queues()
|
||||
|
||||
create_default_queue()
|
||||
@receiver(post_syncdb, dispatch_uid='create_default_queue', sender=ocr_models)
|
||||
def create_default_queue_signal_handler(sender, **kwargs):
|
||||
create_default_queue()
|
||||
|
||||
register_interval_job('task_process_document_queues', _(u'Checks the OCR queue for pending documents.'), task_process_document_queues, seconds=QUEUE_PROCESSING_INTERVAL)
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from celery.task.control import inspect
|
||||
from permissions.models import Permission
|
||||
from documents.models import Document
|
||||
from documents.widgets import document_link, document_thumbnail
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
; =======================================
|
||||
; celeryd supervisor example for Django
|
||||
; =======================================
|
||||
|
||||
[program:celery]
|
||||
command=/usr/share/mayan/bin/python /usr/share/mayan/mayan/manage.py celeryd --loglevel=INFO
|
||||
directory=/usr/share/mayan/mayan
|
||||
user=nobody
|
||||
numprocs=1
|
||||
stdout_logfile=/var/log/mayan-celeryd.log
|
||||
stderr_logfile=/var/log/mayan-celeryd.log
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=10
|
||||
|
||||
; Need to wait for currently executing tasks to finish at shutdown.
|
||||
; Increase this if you have very long running tasks.
|
||||
stopwaitsecs = 600
|
||||
|
||||
; if rabbitmq is supervised, set its priority higher
|
||||
; so it starts first
|
||||
priority=998
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
; ==========================================
|
||||
; celerybeat supervisor example for Django
|
||||
; ==========================================
|
||||
|
||||
[program:celerybeat]
|
||||
command=/usr/share/mayan/bin/python /usr/share/mayan/mayan/manage.py celerybeat --schedule=/var/lib/celery/celerybeat-schedule --loglevel=INFO
|
||||
directory=/usr/share/mayan/mayan
|
||||
user=nobody
|
||||
numprocs=1
|
||||
stdout_logfile=/var/log/mayan-celerybeat.log
|
||||
stderr_logfile=/var/log/mayan-celerybeat.log
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=10
|
||||
|
||||
; if rabbitmq is supervised, set its priority higher
|
||||
; so it starts first
|
||||
priority=999
|
||||
|
||||
@@ -75,14 +75,6 @@ Credits
|
||||
* Jens Gulden 2005-2007 - unpaper@jensgulden.de.
|
||||
* http://unpaper.berlios.de/
|
||||
|
||||
* celery - Celery is an open source asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.
|
||||
* Copyright 2009-2011, Ask Solem & contributors
|
||||
* http://ask.github.com/celery/getting-started/introduction.html
|
||||
|
||||
* django-celery - django-celery provides Celery integration for Django
|
||||
* Copyright Ask Solem & contributors
|
||||
* http://github.com/ask/django-celery/
|
||||
|
||||
* favicon
|
||||
* http://www.iconfinder.com/icondetails/21581/24/draw_pyramid_icon
|
||||
* Gnome Project
|
||||
|
||||
@@ -28,12 +28,6 @@ Executables:
|
||||
Optional requirements
|
||||
=====================
|
||||
|
||||
To enable distributed OCR support
|
||||
---------------------------------
|
||||
|
||||
* ``celery`` - asynchronous task queue/job queue based on distributed message passing
|
||||
* ``django-celery`` - celery integration for Django
|
||||
|
||||
To store documents in a GridFS database
|
||||
---------------------------------------
|
||||
|
||||
|
||||
@@ -179,17 +179,6 @@ Storage
|
||||
|
||||
Default: ``document_storage``
|
||||
|
||||
|
||||
Job processor
|
||||
-------------
|
||||
|
||||
.. data:: JOB_PROCESSING_BACKEND
|
||||
|
||||
Default: ``None``
|
||||
|
||||
|
||||
Specifies which job processing library to use, option are: None and celery.
|
||||
|
||||
|
||||
Document indexing
|
||||
-----------------
|
||||
|
||||
@@ -4,9 +4,6 @@ django-extensions==0.7.1
|
||||
django-pagination==1.0.7
|
||||
django-rosetta==0.6.2
|
||||
wsgiref==0.1.2
|
||||
celery==2.2.2
|
||||
django-celery==2.2.2
|
||||
django-sentry==1.6.0
|
||||
django-taggit==0.9.3
|
||||
-e git://github.com/django-mptt/django-mptt.git@0af02a95877041b2fd6d458bd95413dc1666c321#egg=django-mptt
|
||||
-e git://github.com/ahupp/python-magic.git@a75cf0a4a7790eb106155c947af9612f15693b6e#egg=python-magic
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
Django==1.3.1
|
||||
django-pagination==1.0.7
|
||||
wsgiref==0.1.2
|
||||
celery==2.2.2
|
||||
django-celery==2.2.2
|
||||
django-sentry==1.6.0
|
||||
django-taggit==0.9.3
|
||||
-e git://github.com/django-mptt/django-mptt.git@0af02a95877041b2fd6d458bd95413dc1666c321#egg=django-mptt
|
||||
-e git://github.com/ahupp/python-magic.git@a75cf0a4a7790eb106155c947af9612f15693b6e#egg=python-magic
|
||||
|
||||
18
settings.py
18
settings.py
@@ -18,7 +18,6 @@ DEVELOPMENT = False
|
||||
TEMPLATE_DEBUG = False
|
||||
|
||||
ADMINS = ()
|
||||
SENTRY_ADMINS = ('root@localhost',)
|
||||
MANAGERS = ADMINS
|
||||
|
||||
DATABASES = {
|
||||
@@ -141,12 +140,6 @@ INSTALLED_APPS = (
|
||||
'filetransfers',
|
||||
'acls',
|
||||
'converter',
|
||||
'djcelery',
|
||||
'indexer',
|
||||
'paging',
|
||||
'sentry',
|
||||
'sentry.client',
|
||||
'sentry.client.celery',
|
||||
'storage',
|
||||
'folders',
|
||||
'document_comments',
|
||||
@@ -278,18 +271,7 @@ COMPRESS_ENABLED=False
|
||||
#------------ django-sendfile --------------
|
||||
# Change to xsendfile for apache if x-sendfile is enabled
|
||||
SENDFILE_BACKEND = 'sendfile.backends.simple'
|
||||
#----------- django-celery --------------
|
||||
import djcelery
|
||||
djcelery.setup_loader()
|
||||
BROKER_HOST = "localhost"
|
||||
BROKER_PORT = 5672
|
||||
BROKER_USER = "guest"
|
||||
BROKER_PASSWORD = "guest"
|
||||
BROKER_VHOST = "/"
|
||||
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
|
||||
#======== End of user configuration options =======
|
||||
#--------- Celery ------------------
|
||||
CELERY_DISABLE_RATE_LIMITS = True
|
||||
#--------- Web theme ---------------
|
||||
WEB_THEME_ENABLE_SCROLL_JS = False
|
||||
#--------- Django -------------------
|
||||
|
||||
1
urls.py
1
urls.py
@@ -15,7 +15,6 @@ urlpatterns = patterns('',
|
||||
(r'^tags/', include('tags.urls')),
|
||||
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
(r'^sentry/', include('sentry.urls')),
|
||||
(r'^comments/', include('document_comments.urls')),
|
||||
(r'^user_management/', include('user_management.urls')),
|
||||
(r'^settings/', include('smart_settings.urls')),
|
||||
|
||||
Reference in New Issue
Block a user