Error when calling preprocessor hook

Hi,

I'm working on the Telegram plugin and I have a problem when I upload a file.

I do this to upload the file and it's working to add the file

stream = octoprint.filemanager.util.StreamWrapper(file_name, bytes_reader_class(data))
self.main._file_manager.add_file(octoprint.filemanager.FileDestinations.LOCAL, target_filename, stream, allow_overwrite=True)

it has working for sometimes but I just see that I have those error on the log file

2021-01-08 08:37:09,287 - octoprint.filemanager - ERROR - Error when calling preprocessor hook for plugin cancelobject, ignoring
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/filemanager/__init__.py", line 718, in add_file
    allow_overwrite=allow_overwrite,
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/util/__init__.py", line 1890, in wrapper
    return f(*args, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_cancelobject/__init__.py", line 228, in modify_file
    self.reptag))
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_cancelobject/__init__.py", line 21, in __init__
    super(ModifyComments, self).__init__(fileBufferedReader)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/filemanager/util.py", line 191, in __init__
    self.input_stream = io.BufferedReader(input_stream)
AttributeError: StringIO instance has no attribute 'readable'
2021-01-08 08:37:09,289 - octoprint.plugins.DisplayLayerProgress - INFO - FilePreProcessor. Checking LayerExpressions.
2021-01-08 08:37:09,290 - octoprint.plugins.DisplayLayerProgress - INFO - FilePreProcessor. LayerExpression valid. Start processing...
2021-01-08 08:37:09,291 - octoprint.filemanager - ERROR - Error when calling preprocessor hook for plugin DisplayLayerProgress, ignoring
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/filemanager/__init__.py", line 718, in add_file
    allow_overwrite=allow_overwrite,
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_DisplayLayerProgress/__init__.py", line 401, in createFilePreProcessor
    self._layerDetectorFileProcessor = LayerDetectorFileProcessor(fileStream, self._allLayerExpressions, self._logger)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_DisplayLayerProgress/__init__.py", line 143, in __init__
    super(LayerDetectorFileProcessor, self).__init__(fileBufferedReader)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/filemanager/util.py", line 191, in __init__
    self.input_stream = io.BufferedReader(input_stream)
AttributeError: StringIO instance has no attribute 'readable'

Does anybody has an idea what I'm doing wrong or how I could fix the problem?

thanks a lot

never mind I found that if I write the file and use
octoprint.filemanager.util.DiskFileWrapper(target_filename, path)
it's working fine so I will go that path from now on.

thanks

2 Likes