eyal0 / OctoPrint-PrintTimeGenius

Use a gcode pre-analysis to provide better print time estimation
190 stars 32 forks source link

AttributeError: module 'collections' has no attribute 'Mapping' #311

Closed flaviut closed 1 year ago

flaviut commented 1 year ago

Before reporting, check if your problem is here: https://github.com/eyal0/OctoPrint-PrintTimeGenius/wiki/Common-problems

Describe the bug

My analysis failed due to the following error:

2023-11-05 11:33:21,133 - octoprint.printer.standard - ERROR - Error while pausing the analysis queue
Traceback (most recent call last):
  File "/opt/octoprint/lib/python3.11/site-packages/octoprint/printer/standard.py", line 1482, in on_comm_state_change
    self._analysisQueue.pause()  # only analyse files while idle
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/octoprint/lib/python3.11/site-packages/octoprint/filemanager/analysis.py", line 129, in pause
    q.pause()
  File "/opt/octoprint/lib/python3.11/site-packages/octoprint/filemanager/analysis.py", line 265, in pause
    self._do_abort()
  File "/opt/octoprint/lib/python3.11/site-packages/octoprint_PrintTimeGenius/__init__.py", line 207, in _do_abort
    if _allow_analysis(self._plugin._printer, self._plugin._settings):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/octoprint/lib/python3.11/site-packages/octoprint_PrintTimeGenius/__init__.py", line 186, in _allow_analysis
    if not isinstance(thermostat, collections.Mapping) or not 'actual' in thermostat or not 'target' in thermostat or thermostat['target'] is None:
                                  ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'Mapping'

To Reproduce Steps to reproduce the behavior:

Run this code on Python 3.10+, where the collections.Mapping field was moved to collections.abc.Mapping. collections.abc.Mapping was introduced in Python 3.3, released in 2012

Expected behavior

No error

OctoPrint Version:

Version 1.9.3

PrintTimeGenius Version (if you know):

2.3.1

If relevant, upload the PrintTimeGenius log and any problematic gcode files (you might need to rename the files). This is really important. I probably can't help you without this.

bereldhuin commented 8 months ago

Hi,

Would it be possible to create a new tag with this bug solved ? I think most people installing it on newer Ubuntu version will have the problem with Python 3.10.

eyal0 commented 8 months ago

I don't understand, what am I supposed to do here?

flaviut commented 8 months ago

@eyal0 https://stackoverflow.com/a/18223354/2299084, and create a new 2.3.2 version. It's been a while, so I don't remember, but maybe Octoprint's package manager requires a tagged version to update?

eyal0 commented 8 months ago

Ah, right, that kind of tag, yes! Hah, I had forgotten. I also need to update the version number to match in the code or else the updater will try to download the code over and over again!

eyal0 commented 8 months ago

e9489e63606f65daf6e15455c184a40158cb238e

eyal0 commented 8 months ago

Done, here: https://github.com/eyal0/OctoPrint-PrintTimeGenius/releases/tag/2.3.2

Let me know if I need to do something else, thanks.

bereldhuin commented 8 months ago

Thank you, it works, I just received a notification from Octoprint saying that a new version (2.32) is available :-)