scrapy sending mail got an ERROR: Unable to send mail. object of type 'module' has no len() - email

I wanna send email when spider closed, code is like this:
def close(spider, reason):
# mailer = MailSender.from_settings(self.settings)
from scrapy.mail import MailSender
mailer = MailSender(
smtphost="smtp.163.com",
mailfrom="rhys***#163.com",
smtpuser="rhys***g#163.com",
smtppass="***",
smtpport=25
)
body = u"""
content
"""
subject = u'title'
mailer.send(to=["rhys***#qq.com"],
subject=subject.encode("utf-8"),
body=body.encode("utf-8"),
cc=['12202012**#qq.com'])
But I got an error like this:
[twisted] CRITICAL: Unhandled Error
Traceback (most recent call last):
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/python/log.py", line 103, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/python/log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
why = selectable.doRead()
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/internet/tcp.py", line 208, in doRead
return self._dataReceived(data)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/internet/tcp.py", line 214, in _dataReceived
packages/twisted/internet/tcp.py", line 214, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/protocols/tls.py", line 330, in dataReceived
self._flushReceiveBIO()
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/protocols/tls.py", line 295, in _flushReceiveBIO
ProtocolWrapper.dataReceived(self, bytes)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/protocols/policies.py", line 120, in dataReceived
self.wrappedProtocol.dataReceived(data)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/protocols/basic.py", line 571, in dataReceived
why = self.lineReceived(line)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/mail/smtp.py", line 995, in lineReceived
why = self._okresponse(self.code, b'\n'.join(self.resp))
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/mail/smtp.py", line 1044, in smtpState_to
return self.smtpState_toOrData(0, b'')
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/mail/smtp.py", line 1062, in smtpState_toOrData
self.sendLine(b'RCPT TO:' + quoteaddr(self.lastAddress))
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/mail/smtp.py", line 179, in quoteaddr
res = email.utils.parseaddr(addr)
File "/home/rhys/.pyenv/versions/2.7.5/lib/python2.7/email/utils.py", li
ne 215, in parseaddr
addrs = _AddressList(addr).addresslist
File "/home/rhys/.pyenv/versions/2.7.5/lib/python2.7/email/_parseaddr.py
", line 457, in __init__
self.addresslist = self.getaddrlist()
File "/home/rhys/.pyenv/versions/2.7.5/lib/python2.7/email/_parseaddr.py
", line 217, in getaddrlist
while self.pos < len(self.field):
exceptions.TypeError: object of type 'module' has no len()
anybody can explain why?
I use python2.7 and scapy1.4. if I comment the code mentioned above everything is just ok
thanks

I bumped to twisted 17.9 and the problem went away.

Related

Error when using find/find_one pymongo methods when on an apache2 server (mongodb atlas)

when using find/find_one pymongo methods when on an apache2 server i get the following error :
No <class 'cryptography.x509.extensions.TLSFeature'> extension was found
when using pymongo on an apache2 server to connect and insert or delete in my mongodb collections it works just fine, but when i try to pull something out of the database (using find or find_one methods) i get an error, please note that this error only occurs while running the apache2 server, because when i connected and used find methods in a locally run python script it gave me the information without any errors.
if it is of any relevance, the web framework i am using is flask.
Edit : As for what is producing the error i dont know for sure, so here are the logs.
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/var/www/html/srv21/SRVApp.py", line 17, in downloadpage
ThreadID = ThreadID.next()
File "/usr/local/lib/python3.10/dist-packages/pymongo/cursor.py", line 1248, in next
if len(self.__data) or self._refresh():
File "/usr/local/lib/python3.10/dist-packages/pymongo/cursor.py", line 1165, in _refresh
self.__send_message(q)
File "/usr/local/lib/python3.10/dist-packages/pymongo/cursor.py", line 1052, in __send_message
response = client._run_operation(
File "/usr/local/lib/python3.10/dist-packages/pymongo/_csot.py", line 105, in csot_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1330, in _run_operation
return self._retryable_read(
File "/usr/local/lib/python3.10/dist-packages/pymongo/_csot.py", line 105, in csot_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1442, in _retryable_read
with self._socket_from_server(read_pref, server, session) as (sock_info, read_pref):
File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1282, in _socket_from_server
with self._get_socket(server, session) as sock_info:
File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1217, in _get_socket
with server.get_socket(handler=err_handler) as sock_info:
File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.10/dist-packages/pymongo/pool.py", line 1407, in get_socket
sock_info = self._get_socket(handler=handler)
File "/usr/local/lib/python3.10/dist-packages/pymongo/pool.py", line 1520, in _get_socket
sock_info = self.connect(handler=handler)
File "/usr/local/lib/python3.10/dist-packages/pymongo/pool.py", line 1358, in connect
sock = _configured_socket(self.address, self.opts)
File "/usr/local/lib/python3.10/dist-packages/pymongo/pool.py", line 1061, in _configured_socket
sock = ssl_context.wrap_socket(sock, server_hostname=host)
File "/usr/local/lib/python3.10/dist-packages/pymongo/pyopenssl_context.py", line 369, in wrap_socket
ssl_conn.do_handshake()
File "/usr/local/lib/python3.10/dist-packages/pymongo/pyopenssl_context.py", line 125, in do_handshake
return self._call(super(_sslConn, self).do_handshake, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/pymongo/pyopenssl_context.py", line 108, in _call
return call(*args, **kwargs)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1894, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1603, in _raise_ssl_error
self._context._ocsp_helper.raise_if_problem()
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 319, in raise_if_problem
raise self._problems.pop(0)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 539, in wrapper
valid = callback(conn, ocsp_data, data)
File "/usr/local/lib/python3.10/dist-packages/pymongo/ocsp_support.py", line 298, in _ocsp_callback
ext = _get_extension(cert, _TLSFeature)
File "/usr/local/lib/python3.10/dist-packages/pymongo/ocsp_support.py", line 114, in _get_extension
return cert.extensions.get_extension_for_class(klass)
File "/usr/local/lib/python3.10/dist-packages/cryptography/x509/extensions.py", line 135, in get_extension_for_class
raise ExtensionNotFound(
cryptography.x509.extensions.ExtensionNotFound: No <class 'cryptography.x509.extensions.TLSFeature'> extension was found

Reloading error while sending email in survey to list of emails in odoo12

I created new database in odoo12 and install survey module. And when i try to share survey to multiple user(more than 50) by putting list of email ids in 'list of email' field. It send survey email to some users but after that it stop by throwing 'reloading error'. So, anybody can help for this odoo issue.
Error message on terminal is below:
2020-09-01 09:48:00,618 2920 WARNING ? odoo.service.server: Thread <Thread(odoo.service.http.request.140297178703616, started 140297178703616)> virtual real time limit (136/120s) reached.
2020-09-01 09:48:00,618 2920 INFO ? odoo.service.server: Dumping stacktrace of limit exceeding threads before reloading
2020-09-01 09:48:00,785 2920 INFO ? odoo.tools.misc:
# Thread: <Thread(odoo.service.http.request.140297178703616, started 140297178703616)> (db:new_db) (uid:2) (url:http://localhost:8012/web/dataset/call_button)
File: "/usr/lib/python3.6/threading.py", line 884, in _bootstrap
self._bootstrap_inner()
File: "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File: "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File: "/usr/lib/python3.6/socketserver.py", line 654, in process_request_thread
self.finish_request(request, client_address)
File: "/usr/lib/python3.6/socketserver.py", line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File: "/usr/lib/python3.6/socketserver.py", line 724, in __init__
self.handle()
File: "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 228, in handle
rv = BaseHTTPRequestHandler.handle(self)
File: "/usr/lib/python3.6/http/server.py", line 418, in handle
self.handle_one_request()
File: "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 263, in handle_one_request
return self.run_wsgi()
File: "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 205, in run_wsgi
execute(self.server.app)
File: "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 193, in execute
application_iter = app(environ, start_response)
File: "/opt/odoo12/odoo/odoo/service/server.py", line 434, in app
return self.app(e, s)
File: "/opt/odoo12/odoo/odoo/service/wsgi_server.py", line 142, in application
return application_unproxied(environ, start_response)
File: "/opt/odoo12/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
result = odoo.http.root(environ, start_response)
File: "/opt/odoo12/odoo/odoo/http.py", line 1320, in __call__
return self.dispatch(environ, start_response)
File: "/opt/odoo12/odoo/odoo/http.py", line 1293, in __call__
return self.app(environ, start_wrapped)
File: "/usr/local/lib/python3.6/dist-packages/werkzeug/wsgi.py", line 599, in __call__
return self.app(environ, start_response)
File: "/opt/odoo12/odoo/odoo/http.py", line 1488, in dispatch
result = ir_http._dispatch()
File: "/opt/odoo12/odoo/addons/website_sale/models/ir_http.py", line 15, in _dispatch
return super(IrHttp, cls)._dispatch()
File: "/opt/odoo12/odoo/addons/auth_signup/models/ir_http.py", line 19, in _dispatch
return super(Http, cls)._dispatch()
File: "/opt/odoo12/odoo/addons/web_editor/models/ir_http.py", line 22, in _dispatch
return super(IrHttp, cls)._dispatch()
File: "/opt/odoo12/odoo/addons/http_routing/models/ir_http.py", line 403, in _dispatch
result = super(IrHttp, cls)._dispatch()
File: "/opt/odoo12/odoo/addons/utm/models/ir_http.py", line 26, in _dispatch
response = super(IrHttp, cls)._dispatch()
File: "/opt/odoo12/odoo/odoo/addons/base/models/ir_http.py", line 208, in _dispatch
result = request.dispatch()
File: "/opt/odoo12/odoo/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params)
File: "/opt/odoo12/odoo/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File: "/opt/odoo12/odoo/odoo/service/model.py", line 98, in wrapper
return f(dbname, *args, **kwargs)
File: "/opt/odoo12/odoo/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File: "/opt/odoo12/odoo/odoo/http.py", line 941, in __call__
return self.method(*args, **kw)
File: "/opt/odoo12/odoo/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw)
File: "/opt/odoo12/odoo/addons/web/controllers/main.py", line 966, in call_button
action = self._call_kw(model, method, args, {})
File: "/opt/odoo12/odoo/addons/web/controllers/main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File: "/opt/odoo12/odoo/odoo/api.py", line 759, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File: "/opt/odoo12/odoo/odoo/api.py", line 746, in _call_kw_multi
result = method(recs, *args, **kwargs)
File: "/opt/odoo12/odoo-custom-addons/surveymanagement/survey_management/wizard/survey_email_compose_message.py", line 113, in send_mail_action
return self.send_mail()
File: "/opt/odoo12/odoo-custom-addons/surveymanagement/survey_management/wizard/survey_email_compose_message.py", line 324, in send_mail
create_response_and_send_mail(wizard, token, partner.id, email)
File: "/opt/odoo12/odoo-custom-addons/surveymanagement/survey_management/wizard/survey_email_compose_message.py", line 220, in create_response_and_send_mail
Mail.create(values).send()
File: "/opt/odoo12/odoo/addons/mail/models/mail_mail.py", line 265, in send
smtp_session=smtp_session)
File: "/opt/odoo12/odoo/addons/mail/models/mail_mail.py", line 370, in _send
msg, mail_server_id=mail.mail_server_id.id, smtp_session=smtp_session)
File: "/opt/odoo12/odoo/odoo/addons/base/models/ir_mail_server.py", line 501, in send_email
smtp.sendmail(smtp_from, smtp_to_list, message.as_string())
File: "/usr/lib/python3.6/smtplib.py", line 882, in sendmail
(code, resp) = self.data(msg)
File: "/usr/lib/python3.6/smtplib.py", line 569, in data
(code, msg) = self.getreply()
File: "/usr/lib/python3.6/smtplib.py", line 387, in getreply
line = self.file.readline(_MAXLINE + 1)
File: "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File: "/usr/lib/python3.6/ssl.py", line 1012, in recv_into
return self.read(nbytes, buffer)
File: "/usr/lib/python3.6/ssl.py", line 874, in read
return self._sslobj.read(len, buffer)
File: "/usr/lib/python3.6/ssl.py", line 631, in read
v = self._sslobj.read(len, buffer)
2020-09-01 09:48:00,786 2920 INFO ? odoo.service.server: Initiating server reload
Thanks in advance.

Using PostgreSQL with App Engine Standard

I trying to use postgres on app engine standard with python2.7 environment.
I use sqlalchemy + pg8000 for connection, connection string looks like:
postgresql+pg8000://user:password#/dbname?unix_sock=/cloudsql/project:us-central1:db
It works on local machine, but when I deploy it, I receive an error:
AttributeError: 'Connection' object has no attribute '_usock'
How to configure the connection to the database?
Full traceback:
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/e416f9a06334486a/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/e416f9a06334486a/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/e416f9a06334486a/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/main.py", line 15, in <module>
db.engine.execute('select ')
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/engine/base.py", line 2074, in execute
connection = self.contextual_connect(close_with_result=True)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/engine/base.py", line 2123, in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/engine/base.py", line 2158, in _wrap_pool_connect
return fn()
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/pool.py", line 400, in connect
return _ConnectionFairy._checkout(self)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/pool.py", line 788, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/pool.py", line 529, in checkout
rec = pool._do_get()
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/pool.py", line 1193, in _do_get
self._dec_overflow()
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/util/langhelpers.py", line 66, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/pool.py", line 1190, in _do_get
return self._create_connection()
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/pool.py", line 347, in _create_connection
return _ConnectionRecord(self)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/pool.py", line 474, in __init__
self.__connect(first_connect_check=True)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/pool.py", line 671, in __connect
connection = pool._invoke_creator(self)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/engine/strategies.py", line 106, in connect
return dialect.connect(*cargs, **cparams)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/sqlalchemy/engine/default.py", line 412, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/pg8000/__init__.py", line 112, in connect
application_name, max_prepared_statements)
File "/base/data/home/apps/s~valid-song-196413/web-analytics-parser:20180926t131114.412842106933365078/lib/pg8000/core.py", line 1183, in __init__
self._usock.close()
AttributeError: 'Connection' object has no attribute '_usock'

Odoo - outgoing email KeyError: 'body'

In Odoo 9 community outgoing email used to work (smtp configured, etc.), but now I get the following error when trying to send any email (invoice, internal note, etc.) from any account, for any template.
Things I changed since it worked that might (or might not) be linked to this issue:
I installed and uninstalled the SMTP Server Per User plugin
I changed the "from: " email address in the email templates
Any clue why this occurs? Or any clue what this "body" key is and where it is supposed to be defined? Thanks!
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 605, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 642, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 316, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 309, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 893, in __call__
return self.method(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 471, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 998, in call_button
action = self._call_kw(model, method, args, {})
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 986, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 238, in wrapper
return old_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 369, in old_api
result = method(recs, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/wizard/mail_compose_message.py", line 191, in send_mail_action
return self.send_mail()
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
return new_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/account/models/account_invoice.py", line 1306, in send_mail
return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
return new_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/wizard/mail_compose_message.py", line 248, in send_mail
ActiveModel.browse(res_id).message_post(message_type='comment', subtype=subtype, **mail_values)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
return new_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/mail_thread.py", line 1712, in message_post
new_message = MailMessage.create(values)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
return new_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/mail_message.py", line 864, in create
user_signature=self.env.context.get('mail_notify_user_signature', True))
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
return new_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/mail_message.py", line 926, in _notify
partners._notify(self, force_send=force_send, user_signature=user_signature)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
return new_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/res_partner.py", line 127, in _notify
('notify_email', '!=', 'none')])._notify_by_email(message, force_send=force_send, user_signature=user_signature)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
return new_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/res_partner.py", line 178, in _notify_by_email
new_emails, new_recipients_nbr = self._notify_send(not_values['body'], not_values['subject'], recipient_template_values['not_followers'], **base_mail_values)
KeyError: 'body'
#v11 odoo community
Solved Error : Odoo - outgoing email KeyError: 'body'
When Other User sends message on contacts page it gives outgoing email KeyError: 'body'.
This Error is occur from Mail Template : [mail module /data/ mail_data.xml]
so change Your Template Body code Or You Can Also inherit Mail Template:
Remove extra content in this mail_data.xml file.
% if ctx.get('website_url'):
% endif
Only This code Work Properly :
<p style="color: #555555;">
Sent by
% if ctx.get('website_url'):
<a href="${ctx['website_url']}" style="text-decoration:none; color: #875A7B;">
% endif
${ctx.get('company_name')}
</a>
using
<a target="_blank" href="https://www.odoo.com" style="text-decoration:none; color: #875A7B;">Odoo</a>.
</p>
Also Reference : https://i.stack.imgur.com/h8yMK.png
I did not solve the issue myself, but the person who did told me it came from a translation file and an "<" sign that was interpreted as a smaller than in the python code. So he changed the translation file to remove the smaller than.

Watch long term process in Ipython notebook

For now, after reconnect ipython notebook is not able to print any output from running kernel. I tried following work-around:
import sys, time
with open('foo.log','w') as sys.stdout:
for i in range(5):
print i
time.sleep(1)
everything is nice, I can see the process with tail -f foo.log, but at the end whole thing crashes and I get following error:
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 407, in _run_callback
callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 260, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 218, in dispatch_shell
sys.stdout.flush()
ValueError: I/O operation on closed file
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 433, in _handle_events
self._handle_recv()
File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 465, in _handle_recv
self._run_callback(callback, msg)
File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 407, in _run_callback
callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 260, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 218, in dispatch_shell
sys.stdout.flush()
ValueError: I/O operation on closed file
ERROR:tornado.application:Exception in callback None
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 883, in start
handler_func(fd_obj, events)
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 433, in _handle_events
self._handle_recv()
File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 465, in _handle_recv
self._run_callback(callback, msg)
File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 407, in _run_callback
callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 260, in dispatcher
return self.dispatch_shell(stream, msg)
File "/usr/local/lib/python2.7/dist-packages/ipykernel/kernelbase.py", line 218, in dispatch_shell
sys.stdout.flush()
ValueError: I/O operation on closed file
I have finally managed to log messages from jupyter into file and flush memory immediately:
class InstantLogger():
def __init__(self, f):
self.f = open(f,'w')
def __getattr__(self,name):
return object.__getattribute__(self.f, name)
def write(self, x):
self.f.write(x)
self.f.flush()
def flush(self):
self.f.flush()
def close(self):
self.f.close()
than I can use it as:
old_stdout = sys.stdout
sys.stdout = InstantLogger('file.log')
print ....
sys.stdout.close()
sys.stdout = old_stdout