[enh] can do a 'yunohost tools shell -c command' à la python -c

This commit is contained in:
Laurent Peuch 2017-08-15 17:24:26 +02:00
parent 52c7a37a78
commit 4e1a839557
2 changed files with 9 additions and 1 deletions

View file

@ -1483,6 +1483,10 @@ tools:
configuration: configuration:
authenticate: all authenticate: all
action_help: Launch a development shell action_help: Launch a development shell
arguments:
-c:
help: python command to execute
full: --command
### tools_shutdown() ### tools_shutdown()
shutdown: shutdown:

View file

@ -814,13 +814,17 @@ def tools_migrations_state():
return read_json(MIGRATIONS_STATE_PATH) return read_json(MIGRATIONS_STATE_PATH)
def tools_shell(auth): def tools_shell(auth, command=None):
""" """
Launch an (i)python shell in the YunoHost context. Launch an (i)python shell in the YunoHost context.
This is entirely aim for development. This is entirely aim for development.
""" """
if command:
exec(command)
return
logger.warn("The \033[1;34mauth\033[0m is available in this context") logger.warn("The \033[1;34mauth\033[0m is available in this context")
try: try:
from IPython import embed from IPython import embed