summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-07-29 14:30:56 +0300
committerLars Wirzenius <liw@liw.fi>2018-07-29 14:30:56 +0300
commitb3b17aceb134c8bd6c88efa13f667e975c9f0460 (patch)
tree2ffb32c3cdcac3f6d363a522cd211a9ef86df1a9
parent15afd4c27dce6c31fa362ef3b259fee2370ffcd1 (diff)
downloadick2-b3b17aceb134c8bd6c88efa13f667e975c9f0460.tar.gz
Add: OUT and ERR and OUTERR functions to Python actions
-rw-r--r--ick2/actions.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ick2/actions.py b/ick2/actions.py
index 932c1e0..daab0e5 100644
--- a/ick2/actions.py
+++ b/ick2/actions.py
@@ -228,6 +228,17 @@ class PythonAction(Action):
' if "check" not in kwargs:\n'
' kwargs["check"] = True\n'
' return subprocess.run(args, **kwargs)\n'
+ 'def OUT(*args, **kwargs):\n'
+ ' x = RUN(*args, stdout=subprocess.PIPE, **kwargs)\n'
+ ' return x.stdout.decode("UTF-8")\n'
+ 'def ERR(*args, **kwargs):\n'
+ ' x = RUN(*args, stderr=subprocess.PIPE, check=False, **kwargs)\n'
+ ' return x.stderr.decode("UTF-8")\n'
+ 'def OUTERR(*args, **kwargs):\n'
+ ' x = RUN(*args, stdout=subprocess.PIPE, \n'
+ ' sterr=subproces.STDOUT, check=False, **kwargs)\n'
+ ' return s.stdout.decode("UTF-8"), x.stderr.decode("UTF-8")\n'
+
).format(encoded)
return prefix