Ejemplo n.º 1
0
def get_manifest(workspace_name):
    if workspace_name is None:
        exit_with_error("No workspace found.")
    workspace_path = workspaces.get_workspace_path(workspace_name)
    manifest_path = workspaces.get_manifest_path(workspace_name)
    try:
        return Manifest(manifest_path, workspace_path)
    except Exception as e:
        exit_with_error(e.message)
Ejemplo n.º 2
0
def get_manifest(workspace_name, logfile_path):
    if workspace_name is None:
        workspace_name = workspaces.get_last_workspace_name()
    if workspace_name is None:
        exit_with_error("No workspace found.", logfile_path)
    workspace_path = workspaces.get_workspace_path(workspace_name)
    manifest_path = workspaces.get_manifest_path(workspace_name)
    if not os.path.isfile(manifest_path):
        colorprint.warning(
            "Error: could not find manifest at {}. While it's "
            "not mandatory, it's highly recommended to use one."
            " Read 'README_MANIFEST.md' for more "
            "information.".format(manifest_path), logfile_path)
        return None
    else:
        try:
            return Manifest(manifest_path, workspace_path)
        except Exception as e:
            exit_with_error(e.message, logfile_path)
Ejemplo n.º 3
0
    else:
        for entry in os.scandir(workspace_path):
            if entry.is_dir() and entry.name not in excluded_components and \
                    os.path.isfile('{}/{}/install.sh'.format(workspace_path,
                                                             entry.name)):
                commands.append(os.path.join(entry.name, "install.sh"))
    return commands


if __name__ == "__main__":
    container_name = sys.argv[1]
    if len(sys.argv) > 2:
        workspace_name = sys.argv[2]
    else:
        workspace_name = container_name
    workspace_path = workspaces.get_workspace_path(workspace_name)
    logfile_path = os.path.abspath(
        os.path.join(workspace_path, INSTALL_LOG_FILE_NAME))
    manifest = get_manifest(workspace_name, logfile_path)

    install_commands = get_install_commands(manifest, workspace_path,
                                            logfile_path)

    for install_command in install_commands:
        cmd = 'lxc exec {} -- /bin/bash /home/swift/code/{}'.format(
            container_name, install_command)
        try:
            run_command(cmd, logfile_path=logfile_path)
        except Exception as e:
            colorprint.error(str(e), logfile_path)
            sys.exit(1)
Ejemplo n.º 4
0
                                                   "install.sh")
                    if os.path.isfile(install_sh_path):
                        commands.append(os.path.join(dest_path, "install.sh"))

    else:
        for entry in os.scandir(workspace_path):
            if entry.is_dir() and entry.name not in excluded_components and \
                    os.path.isfile('{}/{}/install.sh'.format(workspace_path,
                                                             entry.name)):
                commands.append(os.path.join(entry.name, "install.sh"))
    return commands


if __name__ == "__main__":
    container_name = sys.argv[1]
    workspace_path = workspaces.get_workspace_path(container_name)
    logfile_path = os.path.abspath(
        os.path.join(workspace_path, INSTALL_LOG_FILE_NAME))
    manifest = get_manifest(container_name, logfile_path)

    install_commands = get_install_commands(manifest, workspace_path,
                                            logfile_path)

    for install_command in install_commands:
        cmd = 'lxc exec {} -- /bin/bash /home/swift/code/{}'.format(
            container_name, install_command)
        try:
            run_command(cmd, logfile_path=logfile_path)
        except Exception as e:
            colorprint.error(str(e), logfile_path)
            sys.exit(1)