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.0.tar.gz (20.7 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.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for brother-5.1.0.tar.gz
Algorithm Hash digest
SHA256 c228c2f59a0e4b26b23114ed5eec3765d52f7dd43bc1f27ddfc4d0c582a3e861
MD5 0fb95d068033f3c0809b09ba8f7da156
BLAKE2b-256 81130ebffe69c384a3c7e86018399703b65e677c80bfc6d577f49c99bb64ac0a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for brother-5.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73bac224e3214191065beca9e98def881d3bd3224b47f1ecdf61edd3b4c0b137
MD5 3f56943f31965f82d20993f5ad6e09ac
BLAKE2b-256 fbea8bb4ea52f8781c633df850e7689246d55f8fcaa33b6f123754c836f4e9e6

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