PIL import graceful exit

This commit is contained in:
Abyss Watcher
2024-12-22 14:03:26 +01:00
parent f6a54c5c48
commit 7caf8c572a
@@ -4,9 +4,6 @@
import logging
import io
# Image manipulation functions are kept in the plugin,
# to prevent a general exit on missing PIL (pillow) dependency.
from PIL import Image
from dataclasses import dataclass
from typing import Type, List, Dict, Tuple
from volatility3.framework import constants, exceptions, interfaces
@@ -16,6 +13,15 @@ from volatility3.framework.objects import utility
from volatility3.framework.constants import architectures
from volatility3.framework.symbols import linux
# Image manipulation functions are kept in the plugin,
# to prevent a general exit on missing PIL (pillow) dependency.
try:
from PIL import Image
has_pil = True
except ImportError:
has_pil = False
vollog = logging.getLogger(__name__)
@@ -101,7 +107,7 @@ class Fbdev(interfaces.plugins.PluginInterface):
context: interfaces.context.ContextInterface,
kernel_name: str,
fb: Framebuffer,
) -> Image.Image:
):
"""Convert raw framebuffer pixels to an image.
Args:
@@ -238,6 +244,13 @@ You can try using ffmpeg to decode the raw buffer. Example usage:
return fb
def _generator(self):
if not has_pil:
vollog.error(
"PIL (pillow) module is required to use this plugin. Please install it manually or through pyproject.toml."
)
return None
kernel_name = self.config["kernel"]
kernel = self.context.modules[kernel_name]