Skip to content

Status and Exceptions Reference

Exceptions Hierarchy

All library-specific exceptions derive from purrint.exceptions.PurrintError.

purrint.exceptions.PurrintError

Bases: Exception

Base class for all purrint errors.

Source code in src/purrint/exceptions.py
class PurrintError(Exception):
    """Base class for all purrint errors."""

purrint.exceptions.PrinterNotFoundError

Bases: PurrintError

No matching printer was found while scanning.

Source code in src/purrint/exceptions.py
class PrinterNotFoundError(PurrintError):
    """No matching printer was found while scanning."""

purrint.exceptions.OutOfPaperError

Bases: PrinterStateError

The printer reported it has no paper (or the cover is open).

Source code in src/purrint/exceptions.py
class OutOfPaperError(PrinterStateError):
    """The printer reported it has no paper (or the cover is open)."""

purrint.exceptions.OverheatError

Bases: PrinterStateError

The print head reported it is too hot.

Source code in src/purrint/exceptions.py
class OverheatError(PrinterStateError):
    """The print head reported it is too hot."""

purrint.exceptions.ConnectionFailedError

Bases: PurrintError

Bluetooth connection or GATT discovery failed.

Source code in src/purrint/exceptions.py
class ConnectionFailedError(PurrintError):
    """Bluetooth connection or GATT discovery failed."""

purrint.exceptions.NotConnectedError

Bases: PurrintError

An operation needs a connected printer.

Source code in src/purrint/exceptions.py
class NotConnectedError(PurrintError):
    """An operation needs a connected printer."""

Status and Telemetry Data

purrint.status.PrinterStatus dataclass

Snapshot of what the printer last told us. None means "not reported by this model".

Source code in src/purrint/status.py
@dataclass(frozen=True)
class PrinterStatus:
    """Snapshot of what the printer last told us. ``None`` means "not reported by this model"."""

    state: PrinterState = PrinterState.UNKNOWN
    out_of_paper: bool = False
    overheated: bool = False
    low_battery: bool = False
    cover_open: bool = False
    battery_percent: Optional[int] = None
    temperature_c: Optional[int] = None
    raw: bytes = field(default=b"", repr=False)

    @property
    def ok(self) -> bool:
        """True when nothing prevents printing."""
        return not (self.out_of_paper or self.overheated or self.low_battery or self.cover_open)

    @property
    def problems(self) -> list:
        out = []
        if self.out_of_paper:
            out.append("out of paper")
        if self.cover_open:
            out.append("cover open")
        if self.overheated:
            out.append("print head overheated")
        if self.low_battery:
            out.append("battery low")
        return out

    def merged(self, **changes: object) -> "PrinterStatus":
        return replace(self, **changes)  # type: ignore[arg-type]

ok property

True when nothing prevents printing.

purrint.status.DeviceInfo dataclass

Identity data that can be queried from the printer.

Source code in src/purrint/status.py
@dataclass(frozen=True)
class DeviceInfo:
    """Identity data that can be queried from the printer."""

    firmware: Optional[str] = None
    serial: Optional[str] = None
    head_type: Optional[str] = None
    """V5X only: ``"high_voltage"``, ``"low_voltage"`` or ``"unknown"``."""

head_type = None class-attribute instance-attribute

V5X only: "high_voltage", "low_voltage" or "unknown".