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.1.tar.gz (22.5 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.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for brother-6.1.1.tar.gz
Algorithm Hash digest
SHA256 29d2a40a2a2d62ab53dc683f61a4bd7cadd6e7405994f837b5f3f6263fd2d1f2
MD5 ccc061c3ce6bf4e1062165ea99d2e8e0
BLAKE2b-256 bf24e0c38e88cde84313dac8ed696a662bd5538389bfe722ab8345c0c78fdb5d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for brother-6.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 202bad8b17de7096cd781378ea7d37588b46db9d69f65570e3d5d46e153a0eee
MD5 099cd457f7b53dc6d5b8d743eb42b9b0
BLAKE2b-256 5f0cc601dd35eff8fccbb132a0ce1a5ae2d5788815e77b6e72d57678f2c1da8f

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