Skip to main content

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

Project description

CI codecov 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()

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

How to create a dev environment

git clone https://github.com/bieniu/brother.git
cd brother
./scripts/setup-local-env.sh

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-6.1.0.tar.gz (22.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-6.1.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for brother-6.1.0.tar.gz
Algorithm Hash digest
SHA256 9eb144a05afd1936ac8f4c99e0f51cb8724c791b57d9fce23713ccaf2c49e2d2
MD5 48b41302354429c2d8db733c9ca34a97
BLAKE2b-256 5f10d0728b79f7d11f58bee242b4188f3c4898d0c9d2fe7c3659458ecd9580da

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for brother-6.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5011abf82ec1b7573fea50f83c28dcac4307da134c8c20168b9a52efce3c75db
MD5 d29232dea505cfabd42c7b6812614599
BLAKE2b-256 7422e3245150b2e27f8961642b7bb5f8d7bf81d5da6508135df493b8709ead53

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