예제 #1
0
        # first prepare a job record
        job = models.BackgroundJob()
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        generate_sitemap.schedule(args=(background_job.id,), delay=10)

@main_queue.periodic_task(schedule("sitemap"))
@write_required(script=True)
def scheduled_sitemap():
    user = app.config.get("SYSTEM_USERNAME")
    job = SitemapBackgroundTask.prepare(user)
    SitemapBackgroundTask.submit(job)

@main_queue.task()
@write_required(script=True)
def generate_sitemap(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = SitemapBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #2
0
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        check_latest_es_backup.schedule(args=(background_job.id,), delay=10)


@main_queue.periodic_task(schedule("check_latest_es_backup"))
@write_required(script=True)
def scheduled_check_latest_es_backup():
    user = app.config.get("SYSTEM_USERNAME")
    job = CheckLatestESBackupBackgroundTask.prepare(user)
    CheckLatestESBackupBackgroundTask.submit(job)


@main_queue.task()
@write_required(script=True)
def check_latest_es_backup(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = CheckLatestESBackupBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #3
0
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        prune_es_backups.schedule(args=(background_job.id,), delay=10)


@long_running.periodic_task(schedule("prune_es_backups"))
@write_required(script=True)
def scheduled_prune_es_backups():
    user = app.config.get("SYSTEM_USERNAME")
    job = PruneESBackupsBackgroundTask.prepare(user)
    PruneESBackupsBackgroundTask.submit(job)


@long_running.task()
@write_required(script=True)
def prune_es_backups(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = PruneESBackupsBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #4
0
        # first prepare a job record
        job = models.BackgroundJob()
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue
        :param background_job: the BackgroundJob instance
        """
        background_job.save()
        async_workflow_notifications.schedule(args=(background_job.id, ),
                                              delay=10)


@main_queue.periodic_task(schedule("async_workflow_notifications"))
def scheduled_async_workflow_notifications():
    user = app.config.get("SYSTEM_USERNAME")
    job = AsyncWorkflowBackgroundTask.prepare(user)
    AsyncWorkflowBackgroundTask.submit(job)


@main_queue.task()
def async_workflow_notifications(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = AsyncWorkflowBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #5
0
파일: reporting.py 프로젝트: DOAJ/doaj
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        run_reports.schedule(args=(background_job.id,), delay=10)


@main_queue.periodic_task(schedule("reporting"))
@write_required(script=True)
def scheduled_reports():
    user = app.config.get("SYSTEM_USERNAME")
    mail = bool(app.config.get("REPORTS_EMAIL_TO", False))                          # Send email if recipient configured
    outdir = app.config.get("REPORTS_BASE_DIR")
    outdir = os.path.join(outdir, dates.today())
    job = ReportingBackgroundTask.prepare(user, outdir=outdir, email=mail)
    ReportingBackgroundTask.submit(job)


@main_queue.task()
@write_required(script=True)
def run_reports(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = ReportingBackgroundTask(job)
예제 #6
0
        job.params = params
        if prepall:
            job.add_audit_message("'prepall' arg set. 'unchanged' articles will also have their indexes refreshed.")
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        article_cleanup_sync.schedule(args=(background_job.id,), delay=10)


@long_running.periodic_task(schedule("article_cleanup_sync"))
@write_required(script=True)
def scheduled_article_cleanup_sync():
    user = app.config.get("SYSTEM_USERNAME")
    job = ArticleCleanupSyncBackgroundTask.prepare(user)
    ArticleCleanupSyncBackgroundTask.submit(job)

@long_running.task()
@write_required(script=True)
def article_cleanup_sync(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = ArticleCleanupSyncBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #7
0
        job.action = cls.__action__
        job.params = params
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        public_data_dump.schedule(args=(background_job.id,), delay=10)


@long_running.periodic_task(schedule("public_data_dump"))
@write_required(script=True)
def scheduled_public_data_dump():
    user = app.config.get("SYSTEM_USERNAME")
    job = PublicDataDumpBackgroundTask.prepare(user, clean=True, prune=True, types="all")
    PublicDataDumpBackgroundTask.submit(job)


@long_running.task()
@write_required(script=True)
def public_data_dump(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = PublicDataDumpBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #8
0
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        check_latest_es_backup.schedule(args=(background_job.id, ), delay=10)


@main_queue.periodic_task(schedule("check_latest_es_backup"))
@write_required(script=True)
def scheduled_check_latest_es_backup():
    user = app.config.get("SYSTEM_USERNAME")
    job = CheckLatestESBackupBackgroundTask.prepare(user)
    CheckLatestESBackupBackgroundTask.submit(job)


@main_queue.task()
@write_required(script=True)
def check_latest_es_backup(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = CheckLatestESBackupBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #9
0
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        request_es_backup.schedule(args=(background_job.id,), delay=10)


@main_queue.periodic_task(schedule("request_es_backup"))
@write_required(script=True)
def scheduled_request_es_backup():
    user = app.config.get("SYSTEM_USERNAME")
    job = RequestESBackupBackgroundTask.prepare(user)
    RequestESBackupBackgroundTask.submit(job)


@main_queue.task()
@write_required(script=True)
def request_es_backup(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = RequestESBackupBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #10
0
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        run_reports.schedule(args=(background_job.id, ), delay=10)


@main_queue.periodic_task(schedule("reporting"))
@write_required(script=True)
def scheduled_reports():
    user = app.config.get("SYSTEM_USERNAME")
    mail = bool(app.config.get("REPORTS_EMAIL_TO",
                               False))  # Send email if recipient configured
    outdir = app.config.get("REPORTS_BASE_DIR")
    outdir = os.path.join(outdir, dates.today())
    job = ReportingBackgroundTask.prepare(user, outdir=outdir, email=mail)
    ReportingBackgroundTask.submit(job)


@main_queue.task()
@write_required(script=True)
def run_reports(job_id):
    job = models.BackgroundJob.pull(job_id)
예제 #11
0
            raise BackgroundException("Email has been disabled in config. Set ENABLE_EMAIL to True to run this task.")

        # first prepare a job record
        job = models.BackgroundJob()
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue
        :param background_job: the BackgroundJob instance
        """
        background_job.save()
        async_workflow_notifications.schedule(args=(background_job.id,), delay=10)


@main_queue.periodic_task(schedule("async_workflow_notifications"))
def scheduled_async_workflow_notifications():
    user = app.config.get("SYSTEM_USERNAME")
    job = AsyncWorkflowBackgroundTask.prepare(user)
    AsyncWorkflowBackgroundTask.submit(job)


@main_queue.task()
def async_workflow_notifications(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = AsyncWorkflowBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #12
0
                "'prepall' arg set. 'unchanged' articles will also have their indexes refreshed."
            )
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        article_cleanup_sync.schedule(args=(background_job.id, ), delay=10)


@long_running.periodic_task(schedule("article_cleanup_sync"))
@write_required(script=True)
def scheduled_article_cleanup_sync():
    user = app.config.get("SYSTEM_USERNAME")
    job = ArticleCleanupSyncBackgroundTask.prepare(user)
    ArticleCleanupSyncBackgroundTask.submit(job)


@long_running.task()
@write_required(script=True)
def article_cleanup_sync(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = ArticleCleanupSyncBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #13
0
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        prune_es_backups.schedule(args=(background_job.id, ), delay=10)


@long_running.periodic_task(schedule("prune_es_backups"))
@write_required(script=True)
def scheduled_prune_es_backups():
    user = app.config.get("SYSTEM_USERNAME")
    job = PruneESBackupsBackgroundTask.prepare(user)
    PruneESBackupsBackgroundTask.submit(job)


@long_running.task()
@write_required(script=True)
def prune_es_backups(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = PruneESBackupsBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #14
0
파일: read_news.py 프로젝트: DOAJ/doaj
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        read_news.schedule(args=(background_job.id,), delay=10)
        # fixme: schedule() could raise a huey.exceptions.QueueWriteException and not reach redis- would that be logged?


@main_queue.periodic_task(schedule("read_news"))
@write_required(script=True)
def scheduled_read_news():
    user = app.config.get("SYSTEM_USERNAME")
    job = ReadNewsBackgroundTask.prepare(user)
    ReadNewsBackgroundTask.submit(job)

@main_queue.task()
@write_required(script=True)
def read_news(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = ReadNewsBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #15
0
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        journal_csv.schedule(args=(background_job.id, ), delay=10)


@main_queue.periodic_task(schedule("journal_csv"))
@write_required(script=True)
def scheduled_journal_csv():
    user = app.config.get("SYSTEM_USERNAME")
    job = JournalCSVBackgroundTask.prepare(user)
    JournalCSVBackgroundTask.submit(job)


@main_queue.task()
@write_required(script=True)
def journal_csv(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = JournalCSVBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #16
0
        job.params = params
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        public_data_dump.schedule(args=(background_job.id, ), delay=10)


@long_running.periodic_task(schedule("public_data_dump"))
@write_required(script=True)
def scheduled_public_data_dump():
    user = app.config.get("SYSTEM_USERNAME")
    job = PublicDataDumpBackgroundTask.prepare(user,
                                               clean=False,
                                               prune=True,
                                               types="all")
    PublicDataDumpBackgroundTask.submit(job)


@long_running.task()
@write_required(script=True)
def public_data_dump(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = PublicDataDumpBackgroundTask(job)
예제 #17
0
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        read_news.schedule(args=(background_job.id, ), delay=10)
        # fixme: schedule() could raise a huey.exceptions.QueueWriteException and not reach redis- would that be logged?


@main_queue.periodic_task(schedule("read_news"))
@write_required(script=True)
def scheduled_read_news():
    user = app.config.get("SYSTEM_USERNAME")
    job = ReadNewsBackgroundTask.prepare(user)
    ReadNewsBackgroundTask.submit(job)


@main_queue.task()
@write_required(script=True)
def read_news(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = ReadNewsBackgroundTask(job)
    BackgroundApi.execute(task)
예제 #18
0
파일: journal_csv.py 프로젝트: DOAJ/doaj
        job.user = username
        job.action = cls.__action__
        return job

    @classmethod
    def submit(cls, background_job):
        """
        Submit the specified BackgroundJob to the background queue

        :param background_job: the BackgroundJob instance
        :return:
        """
        background_job.save()
        journal_csv.schedule(args=(background_job.id,), delay=10)


@main_queue.periodic_task(schedule("journal_csv"))
@write_required(script=True)
def scheduled_journal_csv():
    user = app.config.get("SYSTEM_USERNAME")
    job = JournalCSVBackgroundTask.prepare(user)
    JournalCSVBackgroundTask.submit(job)


@main_queue.task()
@write_required(script=True)
def journal_csv(job_id):
    job = models.BackgroundJob.pull(job_id)
    task = JournalCSVBackgroundTask(job)
    BackgroundApi.execute(task)