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.0.1.tar.gz (16.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.0.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for brother-5.0.1.tar.gz
Algorithm Hash digest
SHA256 224ccb3bd0a6da7bb2155b3b850501bfcb89f7718ea874e508b54add35fd587f
MD5 6e50b41dbd790762280732671040a708
BLAKE2b-256 4ba7854ef48680313fb90156e7edded9ff10b213098ca43f03ed026fa2ffbaec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: brother-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 59531c3c2d1c43eebea9eb698b675ac334758c4e8b9b71035ef27896ced36d6b
MD5 69574a0e80f7fecf65d0bbb284dd355d
BLAKE2b-256 8f2a015f6d01309d5626d1d4abaebf36df791a0998725fa7ed1c45c9ef2c98e3

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