30 января, 2012

WLST jython: smtplib ImportError: no module named locale


$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.6 (Tikanga)

Python 2.4.3 (#1, Apr 14 2011, 20:41:59)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2

import smtplib
from email.MIMEText import MIMEText
..
s.sendmail('email@email.com', ['email@email.com'], msg.as_string())

File "/home/user/scripts/script.py", line 75, in ?
File "$WL_HOME/common/wlst/modules/jython-modules.jar/Lib/email/Message.py", line 127, in as_string
File "$WL_HOME/common/wlst/modules/jython-modules.jar/Lib/email/Generator.py", line 10, in ?
ImportError: no module named locale

I've modified $WL_HOME/common/wlst/modules/jython-modules.jar/Lib/email/Generator.py. Just replaced one line "import locale" with "import java.util.Locale" and now my script works!

Комментариев нет: