diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index 5e14082b5..8b0b981b2 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -970,6 +970,43 @@ def tools_reboot(operation_logger, force=False): subprocess.check_call(['systemctl', 'reboot']) +def tools_shell(command=None): + """ + Launch an (i)python shell in the YunoHost context. + + This is entirely aim for development. + """ + + from yunohost.utils.ldap import _get_ldap_interface + ldap = _get_ldap_interface() + + if command: + exec(command) + return + + logger.warn("The \033[1;34mldap\033[0m interface 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() + + +# ############################################ # +# # +# Migrations management # +# # +# ############################################ # + def tools_migrations_list(pending=False, done=False): """ List existing migrations @@ -1155,37 +1192,6 @@ def tools_migrations_state(): return read_json(MIGRATIONS_STATE_PATH) -def tools_shell(command=None): - """ - Launch an (i)python shell in the YunoHost context. - - This is entirely aim for development. - """ - - from yunohost.utils.ldap import _get_ldap_interface - ldap = _get_ldap_interface() - - if command: - exec(command) - return - - logger.warn("The \033[1;34mldap\033[0m interface 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(): migrations = []