(Migrated) Imbox multiple attachments

(This message has been automatically imported from the retired mailing list)

Hello!

I am trying to use as a convertor of suppliers price-lists to REST service.
Suppliers send us price-lists with xls/xlsx attachments. With a little
magic of xlrd service translates it to Redis collection and then Zato
exposes it as a web service for our ERP.

The problem is that imbox integrated to zato works incorrectly with
multiple attachments. Example:

from zato.server.service import Service
from datetime import datetime
import email
import email
import tempfile
import xlrd
import os

class PriceEleyusUpdate(Service):
def handle(self):
filter = 'xls, xlsx’
conn = self.email.imap.get(‘pr1ce’).conn
for msg_id, msg in conn.get(folder=‘eleyus’):
pass

2015-04-09 13:10:43,839 - WARNING - 620:Dummy-46485 -
zato.server.service:22 - Traceback (most recent call last):
File “/opt/zato/2.0.1/zato-server/src/zato/server/service/init.py”,
line 405, in update_handle
self._invoke(service, channel)
File “/opt/zato/2.0.1/zato-server/src/zato/server/service/init.py”,
line 345, in _invoke
service.handle()
File
"/opt/zato/env/qs-1/server1/work/hot-deploy/current/price-eleyus.py", line
26, in handle
for msg_id, msg in conn.get(folder=‘eleyus’):
File “/opt/zato/2.0.1/zato-server/src/zato/server/connection/email.py”,
line 179, in get
for uid, msg in conn.fetch_list(’
’.join(self.config.get_criteria.splitlines())):
File “/opt/zato/2.0.1/zato-server/src/zato/server/connection/email.py”,
line 66, in fetch_list
yield (uid, self.fetch_by_uid(uid))
File “/opt/zato/2.0.1/zato-server/src/zato/server/connection/email.py”,
line 54, in fetch_by_uid
email_object = parse_email(raw_email)
File “/opt/zato/2.0.1/eggs/imbox-0.5.5-py2.7.egg/imbox/parser.py”, line
99, in parse_email
if ‘create-date’ in name:
File “/opt/zato/2.0.1/eggs/imbox-0.5.5-py2.7.egg/imbox/parser.py”, line
64, in parse_attachment
match = re.search(r’=?((?:\w|-)+)?(Q|B)?(.+)?=’, value)
ValueError: too many values to unpack

2015-04-09 13:10:43,851 - ERROR - 620:Dummy-46485 -
zato.server.connection.http_soap.channel:22 - Caught an exception,
cid:[K05CM4XKYDFT04RH8N00FJ8YNWTB], status_code:[500],
_format_exc:[Traceback (most recent call last):
File
"/opt/zato/2.0.1/zato-server/src/zato/server/connection/http_soap/channel.py",
line 198, in dispatch
payload, worker_store, self.simple_io_config, post_data)
File
"/opt/zato/2.0.1/zato-server/src/zato/server/connection/http_soap/channel.py",
line 351, in handle
params_priority=channel_item.params_pri)
File “/opt/zato/2.0.1/zato-server/src/zato/server/service/init.py”,
line 426, in update_handle
raise e
ValueError: too many values to unpack


The same problem with reading of messages list.
Of course it is possible to use imaplib but use of the native components of
Zato is preferable.

The latest commit of imbox - https://github.com/martinrusev/imbox helps!
I’ve just write it over Zato’s imbox. Please upgrade it in the next Zato
release.

On Thu, Apr 9, 2015 at 6:15 PM, Val Budkin val.budkin@gmail.com wrote:

Hello!

I am trying to use as a convertor of suppliers price-lists to REST
service. Suppliers send us price-lists with xls/xlsx attachments. With a
little magic of xlrd service translates it to Redis collection and then
Zato exposes it as a web service for our ERP.

The problem is that imbox integrated to zato works incorrectly with
multiple attachments. Example:

from zato.server.service import Service
from datetime import datetime
import email
import email
import tempfile
import xlrd
import os

class PriceEleyusUpdate(Service):
def handle(self):
filter =3D ‘xls, xlsx’
conn =3D self.email.imap.get(‘pr1ce’).conn
for msg_id, msg in conn.get(folder=3D’eleyus’):
pass

2015-04-09 13:10:43,839 - WARNING - 620:Dummy-46485 -
zato.server.service:22 - Traceback (most recent call last):
File “/opt/zato/2.0.1/zato-server/src/zato/server/service/init.py”,
line 405, in update_handle
self._invoke(service, channel)
File “/opt/zato/2.0.1/zato-server/src/zato/server/service/init.py”,
line 345, in _invoke
service.handle()
File
"/opt/zato/env/qs-1/server1/work/hot-deploy/current/price-eleyus.py", lin=
e
26, in handle
for msg_id, msg in conn.get(folder=3D’eleyus’):
File “/opt/zato/2.0.1/zato-server/src/zato/server/connection/email.py”,
line 179, in get
for uid, msg in conn.fetch_list(’
’.join(self.config.get_criteria.splitlines())):
File “/opt/zato/2.0.1/zato-server/src/zato/server/connection/email.py”,
line 66, in fetch_list
yield (uid, self.fetch_by_uid(uid))
File “/opt/zato/2.0.1/zato-server/src/zato/server/connection/email.py”,
line 54, in fetch_by_uid
email_object =3D parse_email(raw_email)
File “/opt/zato/2.0.1/eggs/imbox-0.5.5-py2.7.egg/imbox/parser.py”, line
99, in parse_email
if ‘create-date’ in name:
File “/opt/zato/2.0.1/eggs/imbox-0.5.5-py2.7.egg/imbox/parser.py”, line
64, in parse_attachment
match =3D re.search(r’=3D?((?:\w|-)+)?(Q|B)?(.+)?=3D’, value)
ValueError: too many values to unpack

2015-04-09 13:10:43,851 - ERROR - 620:Dummy-46485 -
zato.server.connection.http_soap.channel:22 - Caught an exception,
cid:[K05CM4XKYDFT04RH8N00FJ8YNWTB], status_code:[500],
_format_exc:[Traceback (most recent call last):
File
"/opt/zato/2.0.1/zato-server/src/zato/server/connection/http_soap/channel=
.py",
line 198, in dispatch
payload, worker_store, self.simple_io_config, post_data)
File
"/opt/zato/2.0.1/zato-server/src/zato/server/connection/http_soap/channel=
.py",
line 351, in handle
params_priority=3Dchannel_item.params_pri)
File “/opt/zato/2.0.1/zato-server/src/zato/server/service/init.py”,
line 426, in update_handle
raise e
ValueError: too many values to unpack


The same problem with reading of messages list.
Of course it is possible to use imaplib but use of the native components
of Zato is preferable.


Val Budkin
email/jabber: val.budkin@gmail.com
skype: val.budkin
twitter: @valbudkin
site:www.avtomat.biz

–=20


=D0=92=D0=B0=D0=BB=D0=B5=D0=BD=D1=82=D0=B8=D0=BD =D0=91=D1=83=D0=B4=D0=BA=
=D0=B8=D0=BD
email/jabber: val.budkin@gmail.com
skype: val.budkin
twitter: @valbudkin
site:http://adminote.blogspot.com

On 09/04/15 18:17, Val Budkin wrote:

The latest commit of imbox - https://github.com/martinrusev/imbox helps!

Thanks Val - will definitely have a look at it.