diff --git a/ESSArch_Core/WorkflowEngine/signals.py b/ESSArch_Core/WorkflowEngine/signals.py index 5ecf0ad9d..b50eb0884 100644 --- a/ESSArch_Core/WorkflowEngine/signals.py +++ b/ESSArch_Core/WorkflowEngine/signals.py @@ -4,6 +4,7 @@ from django.db.models.signals import post_save, pre_save from django.dispatch import receiver +from ESSArch_Core.db.utils import check_db_connection from ESSArch_Core.WorkflowEngine.models import ProcessStep, ProcessTask @@ -31,6 +32,7 @@ def step_post_save(sender, instance, created, **kwargs): @task_received.connect def task_received_handler(request=None, **kwargs): + check_db_connection() logger = logging.getLogger('essarch') try: t = ProcessTask.objects.get(celery_id=request.task_id) @@ -39,7 +41,6 @@ def task_received_handler(request=None, **kwargs): t.revoke() except ProcessTask.DoesNotExist: logger.debug('{} signal task_received without ProcessTask'.format(request.task_id)) - pass @task_revoked.connect diff --git a/ESSArch_Core/fixity/conversion/backends/base.py b/ESSArch_Core/fixity/conversion/backends/base.py index 87f45b93e..cf5ccb90f 100644 --- a/ESSArch_Core/fixity/conversion/backends/base.py +++ b/ESSArch_Core/fixity/conversion/backends/base.py @@ -6,10 +6,24 @@ class BaseConverter: input_formats = [] output_formats = [] + file_converter = True # Does the validator operate on single files or entire directories? - def __init__(self, ip=None, user=None): + def __init__(self, context=None, include=None, exclude=None, options=None, + data=None, required=True, task=None, ip=None, responsible=None, + stylesheet=None): + """ + Initializes for convert of one or more files + """ + self.context = context + self.include = include or [] + self.exclude = exclude or [] + self.options = options or {} + self.data = data or {} + self.required = required + self.task = task self.ip = ip - self.user = user + self.responsible = responsible + self.stylesheet = stylesheet @classmethod def validate_input_format(cls, fmt): diff --git a/ESSArch_Core/fixity/models.py b/ESSArch_Core/fixity/models.py index c6ae17723..2d20b7083 100644 --- a/ESSArch_Core/fixity/models.py +++ b/ESSArch_Core/fixity/models.py @@ -121,6 +121,9 @@ def _run_python(self, filepath, rootdir, options, t=None, ip=None, context=None) os.chdir(rootdir) filepath = normalize_path(filepath) cmd = eval(self.prepare_cmd(filepath, options)) + if isinstance(cmd, str): + cmd = (cmd,) + try: [module, task] = self.path.rsplit('.', 1) p = getattr(importlib.import_module(module), task)(task=t, ip=ip, context=context) diff --git a/ESSArch_Core/fixity/transformation/backends/base.py b/ESSArch_Core/fixity/transformation/backends/base.py index ba39ffeba..5c9523560 100644 --- a/ESSArch_Core/fixity/transformation/backends/base.py +++ b/ESSArch_Core/fixity/transformation/backends/base.py @@ -2,9 +2,24 @@ class BaseTransformer: - def __init__(self, ip=None, user=None): + file_transformer = True # Does the validator operate on single files or entire directories? + + def __init__(self, context=None, include=None, exclude=None, options=None, + data=None, required=True, task=None, ip=None, responsible=None, + stylesheet=None): + """ + Initializes for transform of one or more files + """ + self.context = context + self.include = include or [] + self.exclude = exclude or [] + self.options = options or {} + self.data = data or {} + self.required = required + self.task = task self.ip = ip - self.user = user + self.responsible = responsible + self.stylesheet = stylesheet @classmethod def transform(cls, path):