Exemplo n.º 1
0
def launchpad(launchpad_file=None, lpad_name="base"):
    """
    Script to set up the configuration of the launchpad for accessing the workflow
    server.

    Args:
        launchpad_file (str): my_launchpad.yaml file from which to load the
            mongoDB database details.
        lpad_name (str): Name to give to the database in the configuration setup.

    Returns:
        None

    """

    if launchpad_file:
        lpad = LaunchPad.from_file(launchpad_file)
    else:
        host = input("Please provide the server host: ")
        port = int(input("Please provide the port number: "))
        name = input("Please provide the server name: ")
        username = input("Please provide your username: "******"Please provide your password: "******"admin")

    # Test the launchpad
    print("\nAttempting connection to mongoDB database...")
    _ = lpad.get_fw_ids()
    print("Connection successful!\n")

    config_lpad_file = os.path.join(os.path.expanduser("~"),
                                    ".workflow_config", "launchpad",
                                    lpad_name + "_launchpad.yaml")
    try:
        os.makedirs(
            os.path.join(os.path.expanduser("~"), ".workflow_config",
                         "launchpad"))
    except FileExistsError:
        pass

    lpad.to_file(config_lpad_file)
    print("Launchpad file written to " + config_lpad_file + "\n")