j7126 / OctoPrint-Dashboard

A dashboard for Octoprint
GNU Affero General Public License v3.0
288 stars 39 forks source link

Watched folder / Watchdog causes TypeError when plugin is enabled #321

Closed ido-nl closed 1 year ago

ido-nl commented 2 years ago

Using Dashboard version 1.19.5 on my Raspberry Pi - Octoprint v1.7.2, OctoPi Version 0.17.0, running on Raspberry Pi 3 Model B Rev 1.2

I get this error

2021-12-25 12:45:19,893 - octoprint.server.util.watchdog - ERROR - There was an error while processing the file /home/pi/.octoprint/watched/idotest1.gcode in the watched folder
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/server/util/watchdog.py", line 162, in _upload
    allow_overwrite=True,
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/filemanager/__init__.py", line 743, in add_file
    display=display,
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/filemanager/storage.py", line 909, in add_file
    file_object.save(file_path)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/filemanager/util.py", line 105, in save
    shutil.copyfileobj(source, dest)
  File "/home/pi/oprint/lib/python3.7/shutil.py", line 79, in copyfileobj
    buf = fsrc.read(length)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/filemanager/util.py", line 217, in read
    processed_line = self.process_line(line)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_dashboard/__init__.py", line 68, in process_line
    if re.match(self.layer_move_pattern, line) is not None:
  File "/home/pi/oprint/lib/python3.7/re.py", line 173, in match
    return _compile(pattern, flags).match(string)
TypeError: cannot use a string pattern on a bytes-like object

Hope it can be fixed, gotten used to the nice dashboard.

j7126 commented 2 years ago

There was another issue with network filesystems a little while ago #300 that I was unable to figure out the cause of, not sure if it is the same issue here, but I will have to take a look.

j7126 commented 2 years ago

Hi @ido-nl

It seems that for some reason the gcode was not being decoded correctly when being loaded from the NAS. I have added an extra check to make sure that it is properly decoded, which should fix the issue.

This change will be included in the next release, you can try it out by installing the version from development branch https://github.com/j7126/OctoPrint-Dashboard/archive/development.zip

Please let me know if this solves the problem.