Maximo Open Forum

 View Only
  • 1.  Importing basic python libs into Automation Scripts

    Posted 03-18-2022 08:41
    How does one use the python libs included in the jython.jar file? For instance, if I want to use datetime and timedelta, or decimal, how would I import them. I have verified these do indeed exist in the jython.jar file. In standard python, I'd use the following import statements:

    from datetime import datetime, timedelta
    from decimal import Decimal

    I know (and have) imported the java libs to do similar functions to these, but I want to use the python versions.
    #Customizations
    #EverythingMaximo

    ------------------------------
    Sid Ogden
    GDIT
    ------------------------------


  • 2.  RE: Importing basic python libs into Automation Scripts

    Posted 03-21-2022 09:11
    A few examples: 

    from
    com.ibm.json.java import JSONObject
    from org.python.core.util import StringUtil
    from com.ibm.tivoli.maximo.oslc import OslcUtils
     


    ------------------------------
    Pankaj Bhide
    Berkeley National Laboratory
    ------------------------------



  • 3.  RE: Importing basic python libs into Automation Scripts

    Posted 03-21-2022 09:33
    Sincerely, appreciate the input. The 2nd example above works to import StringUtil, but trying variations of that does not allow me to grab any of the libs in the jython.jar. Still looking for a solution.

    ------------------------------
    Sid Ogden
    GDIT
    ------------------------------



  • 4.  RE: Importing basic python libs into Automation Scripts

    Posted 03-23-2022 08:49
    From IBM:

    The developer said that standard libraries need to be extracted and treated the same as non-standard. 

    Then the Lead developer from IBM said:

    We do not recommend customers go down that approach - 

    1. It is not very stable - some modules work and some modules don't - the modules that work are independent ones and ones with dependencies do not work.
    2. Most of the work can be done using java libraries that we have - including our endpoints - which they can leverage from scripts.
    Soooooo, the bottom line is that although IBM touts the ability to leverage python, they don't really want you to use python, they want you to use the wrapper of python around java and the mbo framework. Very interesting.

    ------------------------------
    Sid Ogden
    GDIT
    ------------------------------



  • 5.  RE: Importing basic python libs into Automation Scripts

    Posted 03-29-2022 22:37
    In comes Maximo scripting to help ease some of these concerns. Maximo scripting is primarily based on the JSR 223 specification which is part of JAVA 6. This JSR allows a JAVA application [in this case Maximo] to host script engines which are compliant to this specification. The engines that are supported in an OOTB Maximo 75 are
    1. Mozilla Rhino (JavaScript) which ships with the IBM/Oracle(Sun) JDK 2. Jython which is included as part of Maximo
    This basically implies that users can use either of these 2 scripting languages to customize Maximo using the Maximo scripting framework. We do understand that there are other popular JSR 223 compliant scripting engines like JRuby/Groovy and it should be fairly simple to add support for these by adding these engines [jars] in Maximo application classpath. The way the scripting framework is written – it should be able to detect those jars from the classpath and show them as available languages in the scripting application. However I would like to mention that at this point Maximo has only been tested with the Rhino-JavaScript and Jython engines and JSR 223 being fairly new, a lot of the “compliant” engines may have potential issues with their implementation which can prevent seamless integration with Maximo.

    *******

    The above is an excerpt from Mr. Anamithra guideline document of Introduction to Jython. It’s available over the internet.

    Hope this helps to re-emphasise the point.

    Regards,

    ---------------------------------
    Thanks & Regards
    Venkat
    ---------------------------------