Using python in Cloverleaf

Homepage Clovertech Forums Cloverleaf Using python in Cloverleaf

Tagged: ,

  • Creator
    Topic
  • #121067
    Ramachandran R
    Participant
    We have a requirement to send a message to an external REST API, where it accepts only (Content-Type: multipart/form-data; boundary=—-<unique ID>). I understand that we can use PROTOCOL:java/ws-rawclient, however forming of data is what makes it complex, as it requires the data in multipart/form-data; boundary=—-<unique ID> format.
    So we have decided to build an adopter to send the data to external API using python3, and tried with the below simple code in outbound TPS,
    def process_qlm_multipart(cloverEnv, context, mode, msg, userArgs, dl):
        hciConnName = cloverEnv.getThreadName()
        if mode == “run”:
            messageContent = msg.getContent()
            cloverEnv.log(2, f”messageContent: {messageContent}”)
    import sys
            cloverEnv.log(2, f”{sys.path}”)
            import http.client
            from codecs import encode
            conn = http.client.HTTPSConnection(“URL Comes Here”)
    But getting the below error
    [‘/usr/lib64/python38.zip’, ‘/usr/lib64/python3.8’, ‘/usr/lib64/python3.8/lib-dynload’, ‘/home/hci/.local/lib/python3.8/site-packages’, ‘/usr/lib64/python3.8/site-packages’, ‘/usr/lib/python3.8/site-packages’, ‘/cloverleaf/cis20.1/integrator/python’]
     Tcl error:
         msgId   = message0
         proc    = ‘cljTPS’
         args    = ‘{CLASS ScriptTPS} {LANG jep} {FILE process_qlm_multipart.py} {FUNC process_qlm_multipart}’
         result  = ‘com.quovadx.cloverleaf.upoc.CloverleafException: Failed in running UPoC due to Jep exception’
         errorInfo: ‘
     com.quovadx.cloverleaf.upoc.CloverleafException: Failed in running UPoC due to Jep exception
         at JepUpocEngine.run(JepUpocEngine.java:296)
         at ScriptTPS.process(ScriptTPS.java:58)
         at com.quovadx.cloverleaf.upoc.CloverEnv.processTPS(CloverEnv.java:1418)
     Caused by: jep.JepException: <class ‘ImportError’>: /usr/lib64/python3.8/lib-dynload/binascii.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyExc_ValueError
         at /usr/lib64/python3.8/email/header.<module>(header.py:14)
         at /usr/lib64/python3.8/email/_policybase.<module>(_policybase.py:7)
         at /usr/lib64/python3.8/email/feedparser.<module>(feedparser.py:27)
         at /usr/lib64/python3.8/email/parser.<module>(parser.py:12)
         at /usr/lib64/python3.8/http/client.<module>(client.py:71)
         at /cloverleaf/cis20.1/integrator/sfin3/scripts/process_qlm_multipart.process_qlm_multipart(process_qlm_multipart.py:32)
         at <string>.<module>(<string>:1)
         at jep.Jep.exec(Native Method)
         at jep.Jep.exec(Jep.java:478)
         at JepUpocEngine.run(JepUpocEngine.java:290)
         … 2 more
         invoked from within
     “processTPS “$instanceMap($__userArgs) $context $mode $mh””
         (procedure “cljTPS” line 49)
         invoked from within
     “cljTPS {MSGID message0} {CONTEXT sms_ob_data} {ARGS {{CLASS ScriptTPS} {LANG jep} {FILE process_qlm_multipart.py} {FUNC process_qlm_multipart}}} {MODE…”‘
    We are using Cloverleaf 20.1.2, on RHEL 8.6, and python3.8
    The above error is raised exactly at import http.client. I can see that this package is already available with python3.8.
    Any help/lead in fixing the above issue would be greatly appreciated.
    Thank you.
Viewing 0 reply threads
Viewing 0 reply threads
  • You must be logged in to reply to this topic.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10