Member since
07-06-2022
2
Posts
0
Kudos Received
0
Solutions
07-13-2022
07:40 PM
https://community.cloudera.com/t5/Support-Questions/ExecuteScript-python-2-7-not-working-as-expected-on-server/td-p/346941 in continuation with that question, Also m using docker, https://github.com/apache/nifi/blob/main/nifi-docker/dockermaven/Dockerfile No matter what I do, tried sys.setdefaultencoding() also this # -*- coding: utf-8 -*- .Jython is not changing unicode to byte. Every string is u'some string' and not b'some string', due to this other functions are getting hampered. Similar issue https://stackoverflow.com/questions/12158747/jython-unknown-enocoding-ms932-on-japanese-system , so wanted to try passing argument. Stuck in this since 5 days. Any help guys!
... View more
Labels:
- Labels:
-
Apache NiFi
07-06-2022
04:00 AM
Hi all, Use case is to read email and extract body and other meta data and save it in mongo. msg.get_payload() when I execute above line m getting, "2022=\n 15:23" in response. Quotable printable. msg.get_payload(decode=True) when I execute above line m getting, "2022 15:23" in response. Quotable printable is removed. 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. quopri.decodestring(body) Then I tried above, but still it is not decoding as expected. Here is entire the script m using in local, running on Jython 2.7.2 import email import quopri msg = email.message_from_file(open("some_eml.eml")) body = "" if msg.is_multipart(): for part in msg.walk(): ctype = part.get_content_type() cdispo = str(part.get('Content-Disposition')) if (ctype == 'text/plain' or ctype == 'text/html') and 'attachment' not in cdispo: body = part.get_content() # decode print(body) break else: body_byte = msg.get_payload() print(repr(body_byte)) body = body_byte.decode("utf-8", 'ignore') print(repr(body)) utf = quopri.decodestring(body) text = utf.decode('utf-8', errors='replace') print(repr(text)) print(text) on server it is same m using without print and necessary boiler plate required for Nifi. Any help appreciated.
... View more
Labels:
- Labels:
-
Apache NiFi