Brodan / patter

Pipe to Mattermost
MIT License
41 stars 6 forks source link

Formats allowed to be sent #5

Open uhlhosting opened 6 years ago

uhlhosting commented 6 years ago

tried to send an archive, what formats are supported only .txt?

Revenger:~ cosmicsound$ patter -c town-square -f Archive.zip 
Traceback (most recent call last):
  File "/usr/local/bin/patter", line 60, in <module>
    patter.send_message()
  File "/usr/local/lib/python3.7/site-packages/patter/patter.py", line 83, in send_message
    attached_file_id = self._attach_file(self.filename, channel_id)
  File "/usr/local/lib/python3.7/site-packages/patter/patter.py", line 193, in _attach_file
    files={"files": (filename, open(filename))}
  File "/usr/local/lib/python3.7/site-packages/mattermostdriver/endpoints/files.py", line 11, in upload_file
    files=files
  File "/usr/local/lib/python3.7/site-packages/mattermostdriver/client.py", line 169, in post
    return self.make_request('post', endpoint, options=options, params=params, data=data, files=files).json()
  File "/usr/local/lib/python3.7/site-packages/mattermostdriver/client.py", line 137, in make_request
    files=files
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 498, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 441, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 312, in prepare
    self.prepare_body(data, files, json)
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 500, in prepare_body
    (body, content_type) = self._encode_files(files, data)
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 159, in _encode_files
    fdata = fp.read()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 11: invalid start byte
Revenger:~ cosmicsound$ patter -c town-square -f ~/.ssh/config 
Revenger:~ cosmicsound$ 
Brodan commented 6 years ago

Hey @uhlhosting, not sure why that isn't working. The ability to attach files is pretty new and I guess I only test it with .txt files. I'll start looking into ASAP.