mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #351 from YunoHost/dev_shell
Integrate a command to launch a dev shell from within moulinette context
This commit is contained in:
commit
4f1cf058c2
2 changed files with 38 additions and 0 deletions
|
@ -1467,6 +1467,16 @@ tools:
|
||||||
extra:
|
extra:
|
||||||
pattern: *pattern_port
|
pattern: *pattern_port
|
||||||
|
|
||||||
|
### tools_shell()
|
||||||
|
shell:
|
||||||
|
configuration:
|
||||||
|
authenticate: all
|
||||||
|
action_help: Launch a development shell
|
||||||
|
arguments:
|
||||||
|
-c:
|
||||||
|
help: python command to execute
|
||||||
|
full: --command
|
||||||
|
|
||||||
### tools_shutdown()
|
### tools_shutdown()
|
||||||
shutdown:
|
shutdown:
|
||||||
action_help: Shutdown the server
|
action_help: Shutdown the server
|
||||||
|
|
|
@ -817,6 +817,34 @@ def tools_migrations_state():
|
||||||
return read_json(MIGRATIONS_STATE_PATH)
|
return read_json(MIGRATIONS_STATE_PATH)
|
||||||
|
|
||||||
|
|
||||||
|
def tools_shell(auth, command=None):
|
||||||
|
"""
|
||||||
|
Launch an (i)python shell in the YunoHost context.
|
||||||
|
|
||||||
|
This is entirely aim for development.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if command:
|
||||||
|
exec(command)
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.warn("The \033[1;34mauth\033[0m is available in this context")
|
||||||
|
try:
|
||||||
|
from IPython import embed
|
||||||
|
embed()
|
||||||
|
except ImportError:
|
||||||
|
logger.warn("You don't have IPython installed, consider installing it as it is way better than the standard shell.")
|
||||||
|
logger.warn("Falling back on the standard shell.")
|
||||||
|
|
||||||
|
import readline # will allow Up/Down/History in the console
|
||||||
|
readline # to please pyflakes
|
||||||
|
import code
|
||||||
|
vars = globals().copy()
|
||||||
|
vars.update(locals())
|
||||||
|
shell = code.InteractiveConsole(vars)
|
||||||
|
shell.interact()
|
||||||
|
|
||||||
|
|
||||||
def _get_migrations_list():
|
def _get_migrations_list():
|
||||||
migrations = []
|
migrations = []
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue