StackStorm-Exchange / stackstorm-email

E-Mail Actions/Sensors for StackStorm
https://exchange.stackstorm.org/
Apache License 2.0
9 stars 45 forks source link

IMAPSensor doesn't work on python3 #36

Closed pgsousa closed 3 years ago

pgsousa commented 4 years ago

Hi,

I can confirm that it works on ubuntu16 with python2. This is the error I see on sensorcontainer logs when running in ubuntu18 python 3:

2020-08-24 11:59:37,348 140096106679792 WARNING (unknown file) [-] Sensor "IMAPSensor" run method raised an exception: can't concat int to bytes.
Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py", line 229, in run
    self._sensor_instance.run()
  File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/sensor/base.py", line 121, in run
    self.poll()
  File "/opt/stackstorm/packs/email/sensors/imap_sensor.py", line 58, in poll
    mailbox_metadata=mailbox_metadata)
  File "/opt/stackstorm/packs/email/sensors/imap_sensor.py", line 129, in _poll_for_unread_messages
    mailbox_metadata=mailbox_metadata)
  File "/opt/stackstorm/packs/email/sensors/imap_sensor.py", line 133, in _process_message
    message = mailbox.mail(uid, include_raw=True)
  File "/opt/stackstorm/virtualenvs/email/lib/python3.6/site-packages/easyimap/easyimap.py", line 198, in mail
    typ, content = self._mailer.uid('fetch', uid, self._fetch_message_parts)
  File "/usr/lib/python3.6/imaplib.py", line 879, in uid
    typ, dat = self._simple_command(name, command, *args)
  File "/usr/lib/python3.6/imaplib.py", line 1196, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python3.6/imaplib.py", line 961, in _command
    data = data + b' ' + arg
TypeError: can't concat int to bytes

Thanks

arm4b commented 4 years ago

Thanks for the bug report!

arm4b commented 4 years ago

Some context from Forum: https://forum.stackstorm.com/t/cannot-use-email-imap-plugin-on-kubernetes/1375/

This is a good first issue. If someone willing to contribute the PR fix to add support for python 3 in this pack, - help wanted!