Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions ESSArch_Core/fixity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions ESSArch_Core/install/install_default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand Down Expand Up @@ -213,15 +213,15 @@ 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

# --------------------------------
# Extra events
# --------------------------------
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(
Expand Down
Loading