def cli_change_kernel(): """Change the kernel of an image :raises UserWarning: When there is no image with kernel """ # Get all images images_list = ImageManager.get_created_images() # Select only images with kernel attribut images_with_kernel = [] for image in images_list: if hasattr(image, 'kernel'): images_with_kernel.append(image.name) # If there is no image with kernel, raise an exception if not images_with_kernel: raise UserWarning('Not any image with a kernel') # Select the image to change kernel image_name = select_from_list(images_with_kernel) image = ImageManager.get_created_image(image_name) print('\nCurrent kernel is: ' + image.kernel + '\n') # Select an available kernel new_kernel = KernelManager.cli_select_kernel() # Set image kernel by using image method KernelManager.change_kernel(image, new_kernel)
def get_images(cls): """Get all images that are of this class type.""" # Get all images images = ImageManager.get_created_images() # Instantiate None class_image array class_images = None # If there is images if images: # Get all class images class_images = [ image for image in images if image.image_class == cls.__name__ ] # Return all class images return class_images