summaryrefslogtreecommitdiff
path: root/cmd2/pyscript_bridge.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-04-23 22:35:56 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-04-23 22:35:56 -0400
commitca7f24b238cdfd67adddec0146e7519352589484 (patch)
treee0208beaab3b491f4bc5e073c9085fe365ef63cd /cmd2/pyscript_bridge.py
parent47b531d0ecc41a0ae4182ed72445a1fd811e7d62 (diff)
downloadcmd2-git-ca7f24b238cdfd67adddec0146e7519352589484.tar.gz
Only enabling/disabling stdout storage in the call PyscriptBridge makes to onecmd_plus_hooks.
All nested calls to onecmd_plus_hooks keep capturing stdout to match the behavior of stdout redirection being enabled during nested commands.
Diffstat (limited to 'cmd2/pyscript_bridge.py')
-rw-r--r--cmd2/pyscript_bridge.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/cmd2/pyscript_bridge.py b/cmd2/pyscript_bridge.py
index 47ce29db..1c720cf9 100644
--- a/cmd2/pyscript_bridge.py
+++ b/cmd2/pyscript_bridge.py
@@ -87,20 +87,19 @@ class PyscriptBridge(object):
# This will be used to capture _cmd2_app.stdout and sys.stdout
copy_cmd_stdout = StdSim(self._cmd2_app.stdout, echo)
+ # Pause the storing of stdout until onecmd_plus_hooks enables it
+ copy_cmd_stdout.pause_storage = True
+
# This will be used to capture sys.stderr
copy_stderr = StdSim(sys.stderr, echo)
- # Pause the storing of any output until onecmd_plus_hooks enables it
- copy_cmd_stdout.pause_storage = True
- copy_stderr.pause_storage = True
-
self._cmd2_app._last_result = None
try:
self._cmd2_app.stdout = copy_cmd_stdout
with redirect_stdout(copy_cmd_stdout):
with redirect_stderr(copy_stderr):
- self._cmd2_app.onecmd_plus_hooks(command)
+ self._cmd2_app.onecmd_plus_hooks(command, pyscript_bridge_call=True)
finally:
self._cmd2_app.stdout = copy_cmd_stdout.inner_stream