Update apps interface for the new LocalScheduler class

This commit is contained in:
Roberto Rosario
2012-08-01 01:43:00 -04:00
parent 859109c378
commit 344e738c48
8 changed files with 37 additions and 24 deletions
+5 -3
View File
@@ -6,7 +6,7 @@ from navigation.api import (bind_links,
register_model_list_columns)
from common.utils import encapsulate
from project_setup.api import register_setup
from scheduler.api import register_interval_job
from scheduler.api import LocalScheduler
from documents.models import Document
from .staging import StagingFile
@@ -62,8 +62,10 @@ register_model_list_columns(StagingFile, [
register_setup(setup_sources)
register_interval_job('task_fetch_pop3_emails', _(u'Connects to the POP3 email sources and fetches the attached documents.'), task_fetch_pop3_emails, seconds=EMAIL_PROCESSING_INTERVAL)
register_interval_job('task_fetch_imap_emails', _(u'Connects to the IMAP email sources and fetches the attached documents.'), task_fetch_imap_emails, seconds=EMAIL_PROCESSING_INTERVAL)
sources_scheduler = LocalScheduler('sources', _(u'Document sources'))
sources_scheduler.add_interval_job('task_fetch_pop3_emails', _(u'Connects to the POP3 email sources and fetches the attached documents.'), task_fetch_pop3_emails, seconds=EMAIL_PROCESSING_INTERVAL)
sources_scheduler.add_interval_job('task_fetch_imap_emails', _(u'Connects to the IMAP email sources and fetches the attached documents.'), task_fetch_imap_emails, seconds=EMAIL_PROCESSING_INTERVAL)
sources_scheduler.start()
bind_links(['document_list_recent', 'document_list', 'document_create', 'document_create_multiple', 'upload_interactive', 'staging_file_delete'], [document_create_multiple], menu_name='secondary_menu')
bind_links([Document], [document_create_multiple], menu_name='secondary_menu')
+9 -8
View File
@@ -27,7 +27,6 @@ from converter.literals import DIMENSION_SEPARATOR
from documents.models import Document, DocumentType
from documents.events import history_document_created
from metadata.api import save_metadata_list
from scheduler.api import register_interval_job, remove_job
from acls.utils import apply_default_acls
from .managers import SourceTransformationManager, SourceLogManager
@@ -43,6 +42,7 @@ from .literals import (SOURCE_CHOICES, SOURCE_CHOICES_PLURAL,
IMAP_DEFAULT_MAILBOX)
from .compressed_file import CompressedFile, NotACompressedFile
from .conf.settings import POP3_TIMEOUT
#from . import sources_scheduler
logger = logging.getLogger(__name__)
@@ -441,17 +441,18 @@ class WatchFolder(BaseModel):
interval = models.PositiveIntegerField(verbose_name=_(u'interval'), help_text=_(u'Inverval in seconds where the watch folder path is checked for new documents.'))
def save(self, *args, **kwargs):
if self.pk:
remove_job(self.internal_name())
#if self.pk:
# remove_job(self.internal_name())
super(WatchFolder, self).save(*args, **kwargs)
self.schedule()
def schedule(self):
if self.enabled:
register_interval_job(self.internal_name(),
title=self.fullname(), func=self.execute,
kwargs={'source_id': self.pk}, seconds=self.interval
)
pass
#if self.enabled:
# sources_scheduler.add_interval_job(self.internal_name(),
# title=self.fullname(), function=self.execute,
# seconds=self.interval, kwargs={'source_id': self.pk}
# )
def execute(self, source_id):
source = WatchFolder.objects.get(pk=source_id)