diff options
author | CoprDistGit <copr-devel@lists.fedorahosted.org> | 2023-03-08 07:03:33 +0000 |
---|---|---|
committer | CoprDistGit <copr-devel@lists.fedorahosted.org> | 2023-03-08 07:03:33 +0000 |
commit | 79f34596aabf9c85a553aefe941323061a2ab6cc (patch) | |
tree | daae8dd206fdfcd4b7001d8ccdbd2b81a2647241 | |
parent | 3586ae91f8831003be560f53060e99a108cfa13f (diff) |
automatic import of python-brother
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-brother.spec | 299 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 301 insertions, 0 deletions
@@ -0,0 +1 @@ +/brother-2.3.0.tar.gz diff --git a/python-brother.spec b/python-brother.spec new file mode 100644 index 0000000..782963f --- /dev/null +++ b/python-brother.spec @@ -0,0 +1,299 @@ +%global _empty_manifest_terminate_build 0 +Name: python-brother +Version: 2.3.0 +Release: 1 +Summary: Python wrapper for getting data from Brother laser and inkjet printers via SNMP. +License: Apache-2.0 License +URL: https://github.com/bieniu/brother +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/c0/c2/67922bcbd0479f6e35b2b387eda4afbd53db2312f068dd79763bf363fa36/brother-2.3.0.tar.gz +BuildArch: noarch + +Requires: python3-dacite +Requires: python3-pysnmplib + +%description +[![GitHub Release][releases-shield]][releases] +[![PyPI][pypi-releases-shield]][pypi-releases] +[![PyPI - Downloads][pypi-downloads]][pypi-statistics] +[![Buy me a coffee][buy-me-a-coffee-shield]][buy-me-a-coffee] +[![PayPal_Me][paypal-me-shield]][paypal-me] + +# brother + +Python wrapper for getting data from Brother laser and inkjet printers via snmp + +## How to use package + +```py +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() +``` + +[releases]: https://github.com/bieniu/brother/releases +[releases-shield]: https://img.shields.io/github/release/bieniu/brother.svg?style=popout +[pypi-releases]: https://pypi.org/project/brother/ +[pypi-statistics]: https://pepy.tech/project/brother +[pypi-releases-shield]: https://img.shields.io/pypi/v/brother +[pypi-downloads]: https://pepy.tech/badge/brother/month +[buy-me-a-coffee-shield]: https://img.shields.io/static/v1.svg?label=%20&message=Buy%20me%20a%20coffee&color=6f4e37&logo=buy%20me%20a%20coffee&logoColor=white +[buy-me-a-coffee]: https://www.buymeacoffee.com/QnLdxeaqO +[paypal-me-shield]: https://img.shields.io/static/v1.svg?label=%20&message=PayPal.Me&logo=paypal +[paypal-me]: https://www.paypal.me/bieniu79 + + +%package -n python3-brother +Summary: Python wrapper for getting data from Brother laser and inkjet printers via SNMP. +Provides: python-brother +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-brother +[![GitHub Release][releases-shield]][releases] +[![PyPI][pypi-releases-shield]][pypi-releases] +[![PyPI - Downloads][pypi-downloads]][pypi-statistics] +[![Buy me a coffee][buy-me-a-coffee-shield]][buy-me-a-coffee] +[![PayPal_Me][paypal-me-shield]][paypal-me] + +# brother + +Python wrapper for getting data from Brother laser and inkjet printers via snmp + +## How to use package + +```py +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() +``` + +[releases]: https://github.com/bieniu/brother/releases +[releases-shield]: https://img.shields.io/github/release/bieniu/brother.svg?style=popout +[pypi-releases]: https://pypi.org/project/brother/ +[pypi-statistics]: https://pepy.tech/project/brother +[pypi-releases-shield]: https://img.shields.io/pypi/v/brother +[pypi-downloads]: https://pepy.tech/badge/brother/month +[buy-me-a-coffee-shield]: https://img.shields.io/static/v1.svg?label=%20&message=Buy%20me%20a%20coffee&color=6f4e37&logo=buy%20me%20a%20coffee&logoColor=white +[buy-me-a-coffee]: https://www.buymeacoffee.com/QnLdxeaqO +[paypal-me-shield]: https://img.shields.io/static/v1.svg?label=%20&message=PayPal.Me&logo=paypal +[paypal-me]: https://www.paypal.me/bieniu79 + + +%package help +Summary: Development documents and examples for brother +Provides: python3-brother-doc +%description help +[![GitHub Release][releases-shield]][releases] +[![PyPI][pypi-releases-shield]][pypi-releases] +[![PyPI - Downloads][pypi-downloads]][pypi-statistics] +[![Buy me a coffee][buy-me-a-coffee-shield]][buy-me-a-coffee] +[![PayPal_Me][paypal-me-shield]][paypal-me] + +# brother + +Python wrapper for getting data from Brother laser and inkjet printers via snmp + +## How to use package + +```py +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() +``` + +[releases]: https://github.com/bieniu/brother/releases +[releases-shield]: https://img.shields.io/github/release/bieniu/brother.svg?style=popout +[pypi-releases]: https://pypi.org/project/brother/ +[pypi-statistics]: https://pepy.tech/project/brother +[pypi-releases-shield]: https://img.shields.io/pypi/v/brother +[pypi-downloads]: https://pepy.tech/badge/brother/month +[buy-me-a-coffee-shield]: https://img.shields.io/static/v1.svg?label=%20&message=Buy%20me%20a%20coffee&color=6f4e37&logo=buy%20me%20a%20coffee&logoColor=white +[buy-me-a-coffee]: https://www.buymeacoffee.com/QnLdxeaqO +[paypal-me-shield]: https://img.shields.io/static/v1.svg?label=%20&message=PayPal.Me&logo=paypal +[paypal-me]: https://www.paypal.me/bieniu79 + + +%prep +%autosetup -n brother-2.3.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-brother -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed Mar 08 2023 Python_Bot <Python_Bot@openeuler.org> - 2.3.0-1 +- Package Spec generated @@ -0,0 +1 @@ +f69a25eb093eaf940faa0a6317c57513 brother-2.3.0.tar.gz |