Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cve_bin_tool/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
InsufficientArgs,
InvalidExtensionError,
MirrorError,
PDFOutputUnavailable,
excepthook,
)
from cve_bin_tool.input_engine import InputEngine, TriageData
Expand Down Expand Up @@ -893,11 +894,14 @@ def main(argv=None):

# Check for PDF support
if "pdf" in output_formats and importlib.util.find_spec("reportlab") is None:
LOGGER.info("PDF output not available.")
LOGGER.info(
LOGGER.error("PDF output not available.")
LOGGER.error(
"If you want to produce PDF output, please install reportlab using pip install reportlab"
)
output_formats.remove("pdf")
if len(output_formats) < 1:
# If there's no other formats selected, exit so people actually see the error
return ERROR_CODES[PDFOutputUnavailable]

merged_reports = None
if args["merge"]:
Expand Down
5 changes: 5 additions & 0 deletions cve_bin_tool/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class NetworkConnectionError(Exception):
"""Raised when issue occurred with internet connection"""


class PDFOutputUnavailable(Exception):
"""Raised when reportlab is not installed and PDF output is unavailable"""


class ErrorMode(Enum):
Ignore = 0
NoTrace = 1
Expand Down Expand Up @@ -246,4 +250,5 @@ def __exit__(self, exc_type, exc_val, exc_tb):
InvalidExtensionError: 42,
SigningError: 43,
NetworkConnectionError: 44,
PDFOutputUnavailable: 45,
}
2 changes: 1 addition & 1 deletion test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def test_console_output_depending_reportlab_existence(self, caplog):

assert (
"cve_bin_tool",
logging.INFO,
logging.ERROR,
not_installed_msg,
) in caplog.record_tuples

Expand Down
Loading