diff --git a/ESSArch_Core/fixity/models.py b/ESSArch_Core/fixity/models.py index 19cf87bbd..ab604561d 100644 --- a/ESSArch_Core/fixity/models.py +++ b/ESSArch_Core/fixity/models.py @@ -84,7 +84,12 @@ def prepare_cmd(self, filepath, options): 'input_ext': ''.join(PurePath(filepath).suffixes)[1:], # 'jpg' } kwargs.update(options) - return self.cmd.format(**kwargs) + if isinstance(self.cmd, str): + return self.cmd.format(**kwargs) + elif isinstance(self.cmd, dict): + return {k: v.format(**kwargs) for k, v in self.cmd.items()} + else: + raise TypeError(f"Invalid self.cmd type: {type(self.cmd)}") def _run_application(self, filepath, rootdir, options, t=None, ip=None): from ESSArch_Core.util import normalize_path @@ -122,28 +127,28 @@ def _run_python(self, filepath, rootdir, options, t=None, ip=None, context=None) filepath = normalize_path(filepath) if not context and '_context' in options.keys(): context = options.pop('_context') - cmd = eval(self.prepare_cmd(filepath, options)) + cmd = self.prepare_cmd(filepath, options) if isinstance(cmd, str): - cmd = (cmd,) + cmd = shlex.split(cmd) try: [module, task] = self.path.rsplit('.', 1) p = getattr(importlib.import_module(module), task)(task=t, ip=ip, context=context) if self.type == ExternalTool.Type.CONVERSION_TOOL and isinstance(cmd, dict): p.convert(**cmd) - elif self.type == ExternalTool.Type.CONVERSION_TOOL and isinstance(cmd, tuple): + elif self.type == ExternalTool.Type.CONVERSION_TOOL and isinstance(cmd, list): p.convert(*cmd) elif self.type == ExternalTool.Type.COLLECTION_TOOL and isinstance(cmd, dict): p.collect(**cmd) - elif self.type == ExternalTool.Type.COLLECTION_TOOL and isinstance(cmd, tuple): + elif self.type == ExternalTool.Type.COLLECTION_TOOL and isinstance(cmd, list): p.collect(*cmd) elif self.type == ExternalTool.Type.TRANSFORMATION_TOOL and isinstance(cmd, dict): p.transform(**cmd) - elif self.type == ExternalTool.Type.TRANSFORMATION_TOOL and isinstance(cmd, tuple): + elif self.type == ExternalTool.Type.TRANSFORMATION_TOOL and isinstance(cmd, list): p.transform(*cmd) elif self.type == ExternalTool.Type.VALIDATION_TOOL and isinstance(cmd, dict): p.validate(**cmd) - elif self.type == ExternalTool.Type.VALIDATION_TOOL and isinstance(cmd, tuple): + elif self.type == ExternalTool.Type.VALIDATION_TOOL and isinstance(cmd, list): p.validate(*cmd) else: raise ValueError(cmd) diff --git a/ESSArch_Core/install/install_default_config.py b/ESSArch_Core/install/install_default_config.py index 69e2b8578..f5e92e31e 100644 --- a/ESSArch_Core/install/install_default_config.py +++ b/ESSArch_Core/install/install_default_config.py @@ -171,7 +171,7 @@ def sync_event_types(event_definitions, dry_run=False, remove_extra=False): data = desired_by_code[code] click.secho( f" [+] {'Would create' if dry_run else 'Created'}: " - f"{code} – {data['eventDetail']}", + f"{code} - {data['eventDetail']}", fg="green", ) @@ -213,7 +213,7 @@ def sync_event_types(event_definitions, dry_run=False, remove_extra=False): updated += 1 else: - click.echo(f" [=] OK: {code} – {obj.eventDetail}") + click.echo(f" [=] OK: {code} - {obj.eventDetail}") unchanged += 1 # -------------------------------- @@ -221,7 +221,7 @@ def sync_event_types(event_definitions, dry_run=False, remove_extra=False): # -------------------------------- for code in extra: obj = existing_by_code[code] - msg = f" [!] Extra: {code} – {obj.eventDetail}" + msg = f" [!] Extra: {code} - {obj.eventDetail}" if remove_extra: click.secho(