diff --git a/grid5000/cli.py b/grid5000/cli.py index 1f5a9966ab54fdf5fbe458dd9910564120a2d736..454983f71c2e33c44617555f3660c6b7b7680d3e 100644 --- a/grid5000/cli.py +++ b/grid5000/cli.py @@ -20,23 +20,29 @@ MOTD = r""" \____/_/ /_/\__,_/ /_____/\____/\____/\____/ -* Configuration loaded from %s -* A new client (variable gk) has been created for the user %s +""" + +MOTD_END = """\ * Start exploring the API through the gk variable # Example: Get all available sites $) gk.sites.list() """ - def main(): - path = pathlib.Path(CONF_PATH) - if not path.exists(): - print("Configuration file %s is missing" % CONF_PATH) - return - gk = Grid5000.from_yaml(CONF_PATH) - motd = MOTD % (CONF_PATH, gk.username) + motd = MOTD + if path.exists(): + gk = Grid5000.from_yaml(CONF_PATH) + motd += "* Configuration loaded from %s\n" % CONF_PATH + else: + gk = Grid5000() + motd += "* Warning: configuration file %s is missing, authentication might not work\n" % CONF_PATH + if gk.username: + motd += "* A new client (variable gk) has been created for the user %s\n" % gk.username + else: + motd += "* A new client (variable gk) has been created\n" + motd += MOTD_END IPython.embed(header=motd)