Ejemplo n.º 1
0
 def test_conf_brain_celery(self, m__conf_celery):
     app = MagicMock()
     module.conf_brain_celery(app)
     lifetime = module.brain_config.celery_options.probelist_cache_lifetime
     app.conf.update.assert_called_with(CELERYBEAT_SCHEDULE={
         'probe_list_refresh': {
             'task': 'scan_tasks.probe_list_refresh',
             'schedule': module.timedelta(seconds=lifetime),
             'args': (),
         },
     },
                                        CELERY_TIMEZONE='UTC')
     m__conf_celery.asert_called()
Ejemplo n.º 2
0
 def test_conf_brain_celery(self, m__conf_celery):
     app = MagicMock()
     module.conf_brain_celery(app)
     lifetime = module.brain_config.celery_options.probelist_cache_lifetime
     app.conf.update.assert_called_with(
         CELERYBEAT_SCHEDULE={
             'probe_list_refresh': {
                 'task': 'scan_tasks.probe_list_refresh',
                 'schedule': module.timedelta(seconds=lifetime),
                 'args': (),
             },
         },
         CELERY_TIMEZONE='UTC'
     )
     m__conf_celery.asert_called()
Ejemplo n.º 3
0
from fasteners import interprocess_locked
from brain.models.sqlobjects import User, Job, Scan
import brain.controllers.ftpctrl as ftp_ctrl
import brain.controllers.scanctrl as scan_ctrl
import brain.controllers.probectrl as probe_ctrl
import brain.controllers.frontendtasks as celery_frontend
from brain.helpers.sql import session_transaction
from irma.common.base.utils import IrmaTaskReturn, IrmaScanRequest

RETRY_MAX_DELAY = 30

# Get celery's logger
log = get_task_logger(__name__)

scan_app = celery.Celery('scan_tasks')
config.conf_brain_celery(scan_app)
config.configure_syslog(scan_app)

interprocess_lock_path = config.get_lock_path()

# IRMA specific debug messages are enables through
# config file Section: log / Key: debug
if config.debug_enabled():
    def after_setup_logger_handler(sender=None, logger=None, loglevel=None,
                                   logfile=None, format=None,
                                   colorize=None, **kwds):
        config.setup_debug_logger(logging.getLogger(__name__))
        log.debug("debug is enabled")
    celery.signals.after_setup_logger.connect(after_setup_logger_handler)
    celery.signals.after_setup_task_logger.connect(after_setup_logger_handler)
Ejemplo n.º 4
0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License in the top-level directory
# of this distribution and at:
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# No part of the project, including this file, may be copied,
# modified, propagated, or distributed except according to the
# terms contained in the LICENSE file.

import celery
import config.parser as config
from probe.helpers.celerytasks import async_call

# declare a new Remote Brain application
brain_app = celery.Celery('braintasks')
config.conf_brain_celery(brain_app)
config.configure_syslog(brain_app)


# ============
#  Task calls
# ============

def register_probe(name, category, mimetype_regexp):
    """ send a task to the brain to register local probes"""
    task = async_call(brain_app, "brain.tasks", "register_probe",
                      args=[name, category, mimetype_regexp])
    return task
Ejemplo n.º 5
0
from fasteners import interprocess_locked
from brain.models.sqlobjects import User, Job, Scan
import brain.controllers.scanctrl as scan_ctrl
import brain.controllers.probectrl as probe_ctrl
import brain.controllers.probetasks as celery_probe
import brain.controllers.frontendtasks as celery_frontend
from brain.helpers.sql import session_transaction
from lib.irma.common.utils import IrmaTaskReturn, IrmaScanStatus, \
    IrmaScanRequest


# Get celery's logger
log = get_task_logger(__name__)

scan_app = celery.Celery('scantasks')
config.conf_brain_celery(scan_app)
config.configure_syslog(scan_app)

interprocess_lock_path = config.get_lock_path()

# IRMA specific debug messages are enables through
# config file Section: log / Key: debug
if config.debug_enabled():
    def after_setup_logger_handler(sender=None, logger=None, loglevel=None,
                                   logfile=None, format=None,
                                   colorize=None, **kwds):
        config.setup_debug_logger(logging.getLogger(__name__))
        log.debug("debug is enabled")
    celery.signals.after_setup_logger.connect(after_setup_logger_handler)
    celery.signals.after_setup_task_logger.connect(after_setup_logger_handler)
Ejemplo n.º 6
0
# You may obtain a copy of the License in the top-level directory
# of this distribution and at:
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# No part of the project, including this file, may be copied,
# modified, propagated, or distributed except according to the
# terms contained in the LICENSE file.

import celery
import config.parser as config
from probe.helpers.celerytasks import async_call

# declare a new Remote Brain application
brain_app = celery.Celery('braintasks')
config.conf_brain_celery(brain_app)
config.configure_syslog(brain_app)

# ============
#  Task calls
# ============


def register_probe(name, display_name, category, mimetype_regexp):
    """ send a task to the brain to register local probes"""
    task = async_call(brain_app,
                      "brain.scan_tasks",
                      "register_probe",
                      args=[name, display_name, category, mimetype_regexp])
    return task