Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f32b4d76 authored by JONGLEZ Baptiste's avatar JONGLEZ Baptiste
Browse files

cli: allow to run even if config file is missing

parent 0539aed2
No related branches found
No related tags found
1 merge request!7Improve SSL user experience on Grid'5000
...@@ -20,23 +20,29 @@ MOTD = r""" ...@@ -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 * Start exploring the API through the gk variable
# Example: Get all available sites # Example: Get all available sites
$) gk.sites.list() $) gk.sites.list()
""" """
def main(): def main():
path = pathlib.Path(CONF_PATH) path = pathlib.Path(CONF_PATH)
if not path.exists(): motd = MOTD
print("Configuration file %s is missing" % CONF_PATH) if path.exists():
return gk = Grid5000.from_yaml(CONF_PATH)
gk = Grid5000.from_yaml(CONF_PATH) motd += "* Configuration loaded from %s\n" % CONF_PATH
motd = MOTD % (CONF_PATH, gk.username) 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) IPython.embed(header=motd)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment