Skip to main content

Python wrapper for getting data from Brother laser and inkjet printers via SNMP.

Project description

GitHub Release PyPI PyPI - Downloads Buy me a coffee PayPal_Me Revolut.Me

brother

Python wrapper for getting data from Brother laser and inkjet printers via snmp

How to use package

import asyncio
import logging
from sys import argv

import pysnmp.hlapi.asyncio as hlapi

from brother import Brother, SnmpError, UnsupportedModelError

# printer IP address/hostname
HOST = "brother"
logging.basicConfig(level=logging.DEBUG)


async def main():
    host = argv[1] if len(argv) > 1 else HOST
    printer_type = argv[2] if len(argv) > 2 else "laser"
    # argument printer_type: laser - for laser printer
    #                        ink   - for inkjet printer

    external_snmp = False
    if len(argv) > 3 and argv[3] == "use_external_snmp":
        external_snmp = True

    if external_snmp:
        print("Using external SNMP engine")
        snmp_engine = hlapi.SnmpEngine()
    else:
        snmp_engine = None
    try:
        brother = await Brother.create(
            host, printer_type=printer_type, snmp_engine=snmp_engine
        )
        data = await brother.async_update()
    except (ConnectionError, SnmpError, UnsupportedModelError) as error:
        print(f"{error}")
        return

    brother.shutdown()

    print(f"Model: {brother.model}")
    print(f"Firmware: {brother.firmware}")
    if data:
        print(f"Status: {data.status}")
        print(f"Serial no: {data.serial}")
        print(f"Sensors data: {data}")


loop = asyncio.new_event_loop()
loop.run_until_complete(main())
loop.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brother-5.1.1.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brother-5.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file brother-5.1.1.tar.gz.

File metadata

  • Download URL: brother-5.1.1.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for brother-5.1.1.tar.gz
Algorithm Hash digest
SHA256 6c6aa5c04ec75255d03ca69e30f3f697a32a9042787b018f2a11bc29e1aa06db
MD5 65abbd4ea40cca45d4ba4358914dd3af
BLAKE2b-256 9497e4522f02c65d834ae0971bc916c49ea3c7003a7931cd04fa80f053c76d41

See more details on using hashes here.

File details

Details for the file brother-5.1.1-py3-none-any.whl.

File metadata

  • Download URL: brother-5.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for brother-5.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e2880e40b237498783e6fed8e51ff37305e41101f3d99bbf5d52f69a95ea9ce
MD5 35f748fc6cbfd28b3f1d0d858b201177
BLAKE2b-256 9278f71a7c65c18962b1eb09853ee481a6cb377046598ed0a7c66392e428c90d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page