Skip to content

Conversation

@anselor
Copy link
Contributor

@anselor anselor commented May 17, 2018

Applied the data isolation added to the py command to the ipy command.
Added stdout/stderr suppression by default when executing application commands from a python script. Setting app.cmd_echo = True enables output.

anselor added 3 commits May 4, 2018 18:05
…t. Added pyscript bridge to ipy command. Saving progress.
…ation command from pyscript.

Added support for tab completing application commands in ipython shell
Updated unit tests scripts to set cmd_echo to True to validate command output.
@anselor anselor requested a review from tleonhardt as a code owner May 17, 2018 22:19
@codecov
Copy link

codecov bot commented May 17, 2018

Codecov Report

Merging #405 into master will decrease coverage by 0.38%.
The diff coverage is 71.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #405      +/-   ##
==========================================
- Coverage   90.15%   89.76%   -0.39%     
==========================================
  Files           8        8              
  Lines        2528     2560      +32     
==========================================
+ Hits         2279     2298      +19     
- Misses        249      262      +13
Impacted Files Coverage Δ
cmd2/cmd2.py 90.97% <0%> (-0.59%) ⬇️
cmd2/pyscript_bridge.py 96.55% <93.18%> (-1.48%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8125d45...4699451. Read the comment docs.

tleonhardt
tleonhardt previously approved these changes May 18, 2018
Copy link
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider my comments, particularly regarding a default value for echo

banner = 'Entering an embedded IPython shell type quit() or <Ctrl>-d to exit ...'
exit_msg = 'Leaving IPython, back to {}'.format(sys.argv[0])
embed(banner1=banner, exit_msg=exit_msg)
from .pyscript_bridge import PyscriptBridge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the features added by pyscript_bridge available consistently using either the py or ipy commands.

class CopyStream(object):
"""Copies all data written to a stream"""
def __init__(self, inner_stream):
def __init__(self, inner_stream, echo):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It kinds of feels to me like echo should have a default value and maybe it should be False. I think that would make the behavior as close as possible to being backwards compatible.

What are your thoughts?

NOTE: This comment applies to other functions in this file that also now accept the echo argument.

class CopyStream(object):
"""Copies all data written to a stream"""
def __init__(self, inner_stream):
def __init__(self, inner_stream, echo):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend adding optional type hinting for new arguments unless you are planning to backport to the python2 branch.



def test_pyscript_custom_name(ps_echo, capsys):
@pytest.mark.parametrize('expected, pyscript_file', [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding some unit tests

Copy link
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider my one additional comment (this time in the correct place)



def _exec_cmd(cmd2_app, func):
def _exec_cmd(cmd2_app, func: Callable, echo: bool):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this echo also default to False?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is intended to be an internal function I think I'd prefer the caller to be explicit about it.

@anselor anselor merged commit a38e3f2 into master May 19, 2018
@tleonhardt tleonhardt deleted the pyscript branch May 19, 2018 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants