Skip to content
Open
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
10 changes: 7 additions & 3 deletions src/escpos/printer/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import functools
import logging
import os
from typing import Dict, Literal, Optional, Type, Union

from ..escpos import Escpos
Expand Down Expand Up @@ -155,7 +156,11 @@ def _check_driver(self) -> None:
and detach_kernel_driver().
This helps enable this library to work on Windows.
"""
if self.device and self.device.backend.__module__.endswith("libusb1"):
if (
self.device
and self.device.backend.__module__.endswith("libusb1")
and os.name == "win32"
):
check_driver: Optional[bool] = None

try:
Expand All @@ -170,15 +175,14 @@ def _check_driver(self) -> None:
pass
except usb.core.USBError as e:
if check_driver is not None:
logging.error("Could not detatch kernel driver: %s", str(e))
logging.error("Could not detach kernel driver: %s", str(e))

def _configure_usb(self) -> None:
"""Configure USB."""
if not self.device:
return
try:
self.device.set_configuration()
self.device.reset()
except usb.core.USBError as e:
logging.error("Could not set configuration: %s", str(e))

Expand Down