Skip to content

NotEnoughFreeSpaceError discards its byte counts, forcing callers to parse the message #426

Description

@bernalvinicius

Environment

  • pyntc version: 3.2.3a1 (develop)

Observed Behavior

NotEnoughFreeSpaceError accepts required, available and file_system, uses them to build the message string, and then calls super().__init__(message) without storing any of them (errors.py L209-L226). The values are only recoverable by parsing message.

The message also prints the raw integers with no thousands separators, so a nine-digit byte count is hard to read and the shortfall has to be worked out by hand:

host1: bootflash: has 13456789 bytes free; 313456789 bytes required for transfer

Expected Behavior

The byte counts kept as attributes, so a caller can render its own message or compute the shortfall without a regex. The default message readable at a glance, including how much more space is needed.

Steps to Reproduce

>>> from pyntc.errors import NotEnoughFreeSpaceError
>>> err = NotEnoughFreeSpaceError(hostname="host1", required=313456789, available=13456789, file_system="bootflash:")
>>> err.required
AttributeError: 'NotEnoughFreeSpaceError' object has no attribute 'required'

Found while improving disk-space log messages in a downstream app, which currently has to regex the values back out of message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions