Skip to content

Commit

Permalink
revert default backend to linux_kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
vulpes2 committed Aug 3, 2024
1 parent de284d1 commit 60c869c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
14 changes: 7 additions & 7 deletions brother_ql/backends/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

logger = logging.getLogger(__name__)

def discover(backend_identifier="pyusb"):
def discover(backend_identifier="linux_kernel"):
if backend_identifier is None:
logger.info("Backend for discovery not specified, defaulting to pyusb")
backend_identifier = "pyusb"
logger.info("Backend for discovery not specified, defaulting to linux_kernel.")
backend_identifier = "linux_kernel"
be = backend_factory(backend_identifier)
list_available_devices = be['list_available_devices']
BrotherQLBackend = be['backend_class']
Expand Down Expand Up @@ -48,8 +48,8 @@ def send(instructions, printer_identifier=None, backend_identifier=None, blockin
try:
selected_backend = guess_backend(printer_identifier)
except:
logger.info("No backend stated. Selecting the default pyusb backend.")
selected_backend = "pyusb"
logger.info("No backend stated. Selecting the default linux_kernel backend.")
selected_backend = "linux_kernel"

be = backend_factory(selected_backend)
list_available_devices = be['list_available_devices']
Expand Down Expand Up @@ -122,8 +122,8 @@ def status(
try:
selected_backend = guess_backend(printer_identifier)
except ValueError:
logger.info("No backend stated. Selecting the default pyusb backend.")
selected_backend = "pyusb"
logger.info("No backend stated. Selecting the default linux_kernel backend.")
selected_backend = "linux_kernel"
if selected_backend == "network":
# Not implemented due to lack of an available test device
raise NotImplementedError
Expand Down
2 changes: 1 addition & 1 deletion brother_ql/brother_ql_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BrotherQL_USBdebug(object):

def __init__(self, dev, instructions_data, backend="pyusb"):
def __init__(self, dev, instructions_data, backend='linux_kernel'):

be_cls = backend_factory(backend)['backend_class']
self.be = be_cls(dev)
Expand Down
6 changes: 2 additions & 4 deletions brother_ql/brother_ql_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ def main():
try:
selected_backend = guess_backend(args.printer)
except:
logger.info(
"No backend stated. Selecting the default pyusb backend."
)
selected_backend = "pyusb"
logger.info("No backend stated. Selecting the default linux_kernel backend.")
selected_backend = 'linux_kernel'

# List any printers found, if explicitly asked to do so or if no identifier has been provided.
if args.list_printers or not args.printer:
Expand Down
10 changes: 5 additions & 5 deletions brother_ql/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def cli(ctx, *args, **kwargs):
@click.pass_context
def discover(ctx):
"""find connected label printers"""
backend = ctx.meta.get("BACKEND", "pyusb")
backend = ctx.meta.get("BACKEND", "linux_kernel")
if backend is None:
logger.info("Defaulting to pyusb as backend for discovery")
backend = "pyusb"
logger.info("Defaulting to linux_kernel as backend for discovery.")
backend = "linux_kernel"
from brother_ql.backends.helpers import discover, status

available_devices = discover(backend_identifier=backend)
Expand All @@ -65,7 +65,7 @@ def discover(ctx):
url = urlparse(device["identifier"])
if not os.access(url.path, os.W_OK):
logger.info(
f"Cannot access device {device["identifier"]} due to insufficient permissions"
f"Cannot access device {device["identifier"]} due to insufficient permissions. You need to be a part of the lp group to access printers with this backend."
)
continue

Expand Down Expand Up @@ -176,7 +176,7 @@ def env(ctx, *args, **kwargs):
@click.pass_context
def print_cmd(ctx, *args, **kwargs):
""" Print a label of the provided IMAGE. """
backend = ctx.meta.get('BACKEND', 'pyusb')
backend = ctx.meta.get('BACKEND', 'linux_kernel')
model = ctx.meta.get('MODEL')
printer = ctx.meta.get('PRINTER')
from brother_ql.conversion import convert
Expand Down

0 comments on commit 60c869c

Please sign in to comment.