-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add command for opening a shell for Thrift services #161
Conversation
baseplate/server/__init__.py
Outdated
|
||
args = parser.parse_args(sys.argv[1:]) | ||
config = read_config(args.config_file, server_name=None, app_name=args.app_name) | ||
configure_logging(config, args.debug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I delete this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want fileConfig taking over, so it might be best to just manually set up a logging.basicConfig(level=logging.INFO)
with a simple formatter or something? Not sure how much logging we'd want to see while trying to interact with the REPL.
setup.py
Outdated
@@ -89,6 +89,7 @@ def run(self): | |||
scripts=[ | |||
"bin/baseplate-serve{:d}".format(sys.version_info.major), | |||
"bin/baseplate-script{:d}".format(sys.version_info.major), | |||
"bin/tshell", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I need a tshell2
and tshell3
similar to the serve and script commands?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that makes most sense for consistency.
Should this be baseplate-
prefixed? It's almost a generic thrift shell but it does tie into baseplate's span stuff (as it should) so it's definitely custom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
baseplate-
prefixed?
Sounds reasonable. It also doesn't have to be called tshell
if you have some other name that you would prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tshell
seems pretty nice to be consistent with pshell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great and will be super useful. Thank you!
I think it might be nice to add some documentation of this (and pshell tbh). That'd mean adding some new .rst files to docs/ (see CONTRIBUTING.md for how to add new stuff and test it out).
baseplate/server/__init__.py
Outdated
@@ -66,12 +67,16 @@ def read_config(config_file, server_name, app_name): | |||
if server_name else None) | |||
app_config = dict(parser.items("app:" + app_name)) | |||
has_logging_config = parser.has_section("loggers") | |||
tshell_config = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None
might be a little more obvious here.
baseplate/server/__init__.py
Outdated
|
||
args = parser.parse_args(sys.argv[1:]) | ||
config = read_config(args.config_file, server_name=None, app_name=args.app_name) | ||
configure_logging(config, args.debug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want fileConfig taking over, so it might be best to just manually set up a logging.basicConfig(level=logging.INFO)
with a simple formatter or something? Not sure how much logging we'd want to see while trying to interact with the REPL.
baseplate/server/__init__.py
Outdated
# try to use IPython if possible | ||
try: | ||
try: | ||
# 1.0 <= ipython |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be OK dropping the old IPython support?
IPython 1.0 was released on August 8, 2013 (http://ipython.org/news.html)
In general we should probably be writing the minimal version of what we need here rather than just copying pylons; they have many more cases (and much longer history) to deal with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. Yeah, this was copied from r2 which was copied from pylons.
baseplate/server/__init__.py
Outdated
shell(local_ns=env, global_ns={}) | ||
except ImportError: | ||
import code | ||
py_prefix = sys.platform.startswith('java') and 'J' or 'P' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha let's drop this too. we're never gonna run in Jython.
setup.py
Outdated
@@ -89,6 +89,7 @@ def run(self): | |||
scripts=[ | |||
"bin/baseplate-serve{:d}".format(sys.version_info.major), | |||
"bin/baseplate-script{:d}".format(sys.version_info.major), | |||
"bin/tshell", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that makes most sense for consistency.
Should this be baseplate-
prefixed? It's almost a generic thrift shell but it does tie into baseplate's span stuff (as it should) so it's definitely custom.
💇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pulled this down and played with it and it's great! This is gonna be super useful and make a lot of people happy, thank you!
One request: can you make it clearer in the argparse banner and the sphinx docs that tshell is just for thrift apps?
|
This adds a
tshell
command which will provide a way for Thrift services to open an interactive shell similar topshell
:Services may expose additional variables to the shell environment by providing a setup function in their
.ini
file.config file:
setup function: