sedrubal / brother_printer_fwupd

Script to update the firmware of some Brother printers
https://pypi.org/project/brother_printer_fwupd/
GNU General Public License v3.0
30 stars 5 forks source link

[!] poll error: Traceback (pyasn: TypeError: decodeMessageVersion.<locals>.<lambda>() takes 3 positional arguments but 4 were given) #16

Closed eliasp closed 1 year ago

eliasp commented 1 year ago

Executing brother_printer_fwupd --printer=10.13.1.212 results in:

[i] Querying printer info via SNMP.
[!] poll error: Traceback (most recent call last):
;  File "/nix/store/83ig1ly53ywsdzrl786mlfbbl5yvwkkg-python3.10-pysnmp-4.4.12/lib/python3.10/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 45, in runDispatcher
    loop(timeout or self.getTimerResolution(),
;  File "/nix/store/vagb0sjv83ybi435i6iiv10hjrdghph9-python3-3.10.12/lib/python3.10/asyncore.py", line 214, in loop
    poll_fun(timeout, map)
;  File "/nix/store/vagb0sjv83ybi435i6iiv10hjrdghph9-python3-3.10.12/lib/python3.10/asyncore.py", line 195, in poll2
    readwrite(obj, flags)
;  File "/nix/store/vagb0sjv83ybi435i6iiv10hjrdghph9-python3-3.10.12/lib/python3.10/asyncore.py", line 130, in readwrite
    obj.handle_error()
;  File "/nix/store/vagb0sjv83ybi435i6iiv10hjrdghph9-python3-3.10.12/lib/python3.10/asyncore.py", line 115, in readwrite
    obj.handle_read_event()
;  File "/nix/store/vagb0sjv83ybi435i6iiv10hjrdghph9-python3-3.10.12/lib/python3.10/asyncore.py", line 427, in handle_read_event
    self.handle_read()
;  File "/nix/store/83ig1ly53ywsdzrl786mlfbbl5yvwkkg-python3.10-pysnmp-4.4.12/lib/python3.10/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 170, in handle_read
    self._cbFun(self, transportAddress, incomingMessage)
;  File "/nix/store/83ig1ly53ywsdzrl786mlfbbl5yvwkkg-python3.10-pysnmp-4.4.12/lib/python3.10/site-packages/pysnmp/carrier/base.py", line 84, in _cbFun
    self.__recvCallables[recvId](
;  File "/nix/store/83ig1ly53ywsdzrl786mlfbbl5yvwkkg-python3.10-pysnmp-4.4.12/lib/python3.10/site-packages/pysnmp/entity/engine.py", line 151, in __receiveMessageCbFun
    self.msgAndPduDsp.receiveMessage(
;  File "/nix/store/83ig1ly53ywsdzrl786mlfbbl5yvwkkg-python3.10-pysnmp-4.4.12/lib/python3.10/site-packages/pysnmp/proto/rfc3412.py", line 291, in receiveMessage
    msgVersion = verdec.decodeMessageVersion(wholeMsg)
;  File "/nix/store/83ig1ly53ywsdzrl786mlfbbl5yvwkkg-python3.10-pysnmp-4.4.12/lib/python3.10/site-packages/pysnmp/proto/api/verdec.py", line 15, in decodeMessageVersion
    seq, wholeMsg = decoder.decode(
;  File "/nix/store/26w8jlhl89mfv901wpz9ry6ff0yljik0-python3.10-pyasn1-0.5.0/lib/python3.10/site-packages/pyasn1/codec/ber/decoder.py", line 2003, in __call__
    for asn1Object in streamingDecoder:
;  File "/nix/store/26w8jlhl89mfv901wpz9ry6ff0yljik0-python3.10-pyasn1-0.5.0/lib/python3.10/site-packages/pyasn1/codec/ber/decoder.py", line 1918, in __iter__
    for asn1Object in self._singleItemDecoder(
;  File "/nix/store/26w8jlhl89mfv901wpz9ry6ff0yljik0-python3.10-pyasn1-0.5.0/lib/python3.10/site-packages/pyasn1/codec/ber/decoder.py", line 1778, in __call__
    for value in concreteDecoder.valueDecoder(
;  File "/nix/store/26w8jlhl89mfv901wpz9ry6ff0yljik0-python3.10-pyasn1-0.5.0/lib/python3.10/site-packages/pyasn1/codec/ber/decoder.py", line 654, in valueDecoder
    for chunk in substrateFun(asn1Object, substrate, length, options):
;TypeError: decodeMessageVersion.<locals>.<lambda>() takes 3 positional arguments but 4 were given
caused by <class 'TypeError'>: decodeMessageVersion.<locals>.<lambda>() takes 3 positional arguments but 4 were given
[!] This might be a bug.

Running on NixOS, with:

eliasp commented 1 year ago

This was caused by the fact, that NixOS uses the wrong (original upstream) pyasn1, instead of the fork pysnmp-pyasn1 as required by pysnmp's pyproject.toml.

sedrubal commented 9 months ago

Thanks for your report. This is the same issue as #17. I released version 0.5.3 which might fix this issue. However @Dragunovam added pyasn1 as a dependency in #18 instead of pysnmp-pyasn1. Unfortunately, I can't test the release as I don't have access to a brother printer or any other SNMP device.

Dragunovam commented 9 months ago

Hi @eliasp my fork runs on my end with multiple brother devices, testing on a few Linux machines works so far. I checked the nixos packages and it seems like you might need some different accommodations that are specific to nixos's needs and handling of packages. One of the main issues addressed by the newer pyasn1 0.5.1 is the breaking change in release 0.5.0 discussed here Use correct argument type for valueDecoder method #30.

You could try to make the small changes to pysnmp-pyasn1 on your own fork and report back your findings?

sedrubal commented 9 months ago

Thanks for your answer!