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

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.0.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

brother-5.0.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for brother-5.0.0.tar.gz
Algorithm Hash digest
SHA256 899e05835240151bab526ada73e8aed4936c9f39e717f8ec65a24eedd4cd1238
MD5 8e58b1914a3c81e416e48d5cf400abb1
BLAKE2b-256 6bf49af2002446a437a688e9fba880153c7fe61922d8facc3637115d5d7393c7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for brother-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df6d59bfae280be4e8696cb41283b1d094182d926d95fd6c022092bd47255bc3
MD5 36139a071ebd561ecac593c83d2754db
BLAKE2b-256 fdaf4b3cd1950f52b06d4e0f3585259bd8d43b4ba243b81af22604a1372a6a21

See more details on using hashes here.

Supported by

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