<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question ExecuteScript python 2.7 not working as expected on server in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/ExecuteScript-python-2-7-not-working-as-expected-on-server/m-p/346941#M235026</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use case is to read email and extract body and other meta data and save it in mongo.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;msg.get_payload()&lt;/PRE&gt;&lt;P&gt;when I execute above line m getting, "2022=\n 15:23" in response. Quotable printable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;msg.get_payload(&lt;SPAN&gt;decode&lt;/SPAN&gt;=&lt;SPAN&gt;True&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;when I execute above line m getting, "2022 15:23" in response. Quotable printable is removed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is as expected and works locally, when I pass eml file. I am using the later one, "decode=True" on server but it is not decoding quotable printable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;quopri.decodestring(body)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Then I tried above, but still it is not decoding as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is entire the script m using in local, running on Jython 2.7.2&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;email&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;quopri&lt;BR /&gt;msg = email.message_from_file(&lt;SPAN&gt;open&lt;/SPAN&gt;(&lt;SPAN&gt;"some_eml.eml"&lt;/SPAN&gt;))&lt;BR /&gt;body = &lt;SPAN&gt;""&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;msg.is_multipart():&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;part &lt;SPAN&gt;in &lt;/SPAN&gt;msg.walk():&lt;BR /&gt;        ctype = part.get_content_type()&lt;BR /&gt;        cdispo = &lt;SPAN&gt;str&lt;/SPAN&gt;(part.get(&lt;SPAN&gt;'Content-Disposition'&lt;/SPAN&gt;))&lt;BR /&gt;        &lt;SPAN&gt;if &lt;/SPAN&gt;(ctype == &lt;SPAN&gt;'text/plain' &lt;/SPAN&gt;&lt;SPAN&gt;or &lt;/SPAN&gt;ctype == &lt;SPAN&gt;'text/html'&lt;/SPAN&gt;) &lt;SPAN&gt;and &lt;/SPAN&gt;&lt;SPAN&gt;'attachment' &lt;/SPAN&gt;&lt;SPAN&gt;not in &lt;/SPAN&gt;cdispo:&lt;BR /&gt;            body = part.get_content()  &lt;SPAN&gt;# decode&lt;BR /&gt;&lt;/SPAN&gt;            &lt;SPAN&gt;print&lt;/SPAN&gt;(body)&lt;BR /&gt;            &lt;SPAN&gt;break&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;:&lt;BR /&gt;    body_byte = msg.get_payload()&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;repr&lt;/SPAN&gt;(body_byte))&lt;BR /&gt;    body = body_byte.decode(&lt;SPAN&gt;"utf-8"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'ignore'&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;repr&lt;/SPAN&gt;(body))&lt;BR /&gt;    utf = quopri.decodestring(body)&lt;BR /&gt;    text = utf.decode(&lt;SPAN&gt;'utf-8'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;errors&lt;/SPAN&gt;=&lt;SPAN&gt;'replace'&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;repr&lt;/SPAN&gt;(text))&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(text)&lt;/PRE&gt;&lt;P&gt;on server it is same m using without print and necessary boiler plate required for Nifi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jul 2022 11:00:09 GMT</pubDate>
    <dc:creator>bunty</dc:creator>
    <dc:date>2022-07-06T11:00:09Z</dc:date>
  </channel>
</rss>

