diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ick2/actions.py | 7 |
2 files changed, 10 insertions, 1 deletions
@@ -41,6 +41,10 @@ Version 0.53.2+git, not yet released uses. This doesn't catch when a parameters is used by a pipeline, but not declared by it. +* The worker-manager now defines a RUN() function for Python actions, + to make it easier to run commands from Python code. It's a small + wrapper around `subporocess.run()`. + Version 0.53.2, released 2018-07-18 ------------------------------------ diff --git a/ick2/actions.py b/ick2/actions.py index a424c95..932c1e0 100644 --- a/ick2/actions.py +++ b/ick2/actions.py @@ -220,9 +220,14 @@ class PythonAction(Action): def encode_parameters(self, params): # pragma: no cover encoded = self.encode64(params) prefix = ( - 'import base64, json\n' + 'import base64, json, subprocess\n' 'params = json.loads(base64.b64decode(\n' ' "{}").decode("utf8"))\n' + 'def RUN(*args, **kwargs):\n' + ' print("Executing:", args, kwargs)\n' + ' if "check" not in kwargs:\n' + ' kwargs["check"] = True\n' + ' return subprocess.run(args, **kwargs)\n' ).format(encoded) return prefix |