Example #1
0
def _handle_save_packages(packages, dst, base_url, no_images):
    downloaded_images = []

    for name, pkg in packages.items():
        if not no_images:
            image_specs = pkg.images()
            for image_spec in image_specs:
                if not image_spec["Name"]:
                    print("Invalid image.lst file for {0} package. "
                          "'Name' section is absent.".format(name))
                    continue
                if image_spec["Name"] not in downloaded_images:
                    print("Package {0} depends on image {1}. "
                          "Downloading...".format(name, image_spec["Name"]))
                    try:
                        utils.save_image_local(image_spec, base_url, dst)
                        downloaded_images.append(image_spec["Name"])
                    except Exception as e:
                        print("Error {0} occurred while saving image {1}".
                              format(e, image_spec["Name"]))

        try:
            pkg.save(dst)
            print("Package {0} has been successfully saved".format(name))
        except Exception as e:
            print("Error {0} occurred while saving package {1}".format(
                e, name))
Example #2
0
def _handle_save_packages(packages, dst, base_url, no_images):
    downloaded_images = []

    for name, pkg in six.iteritems(packages):
        if not no_images:
            image_specs = pkg.images()
            for image_spec in image_specs:
                if not image_spec["Name"]:
                    print(
                        "Invalid image.lst file for {0} package. "
                        "'Name' section is absent.".format(name))
                    continue
                if image_spec["Name"] not in downloaded_images:
                    print(
                        "Package {0} depends on image {1}. "
                        "Downloading...".format(name, image_spec["Name"]))
                    try:
                        utils.save_image_local(image_spec, base_url, dst)
                        downloaded_images.append(image_spec["Name"])
                    except Exception as e:
                        print(
                            "Error {0} occurred while saving image {1}".format(
                                e, image_spec["Name"]))

        try:
            pkg.save(dst)
            print("Package {0} has been successfully saved".format(name))
        except Exception as e:
            print("Error {0} occurred while saving package {1}".format(
                e, name))