IBM Support

Automated Scripting: Accessing a Custom [J|P]ython Module Within Your Script

Technical Blog Post


Abstract

Automated Scripting: Accessing a Custom [J|P]ython Module Within Your Script

Body

In this quick blog we'll discuss how to access a custom module from an automation script. Often in the script application we create long and complicated scripts which are embedded inside a multiline textbox. Maintaining the bulk of your scripts on your file system will allow code modularity as well as allow for maintenance and deployment via an scm system such as RTC or git.

 

On our system we will place a simple file called test.py under C:\myLibrary with the contents:

  #  Answer to the Ultimate Question of Life, the Universe, and Everything  def answer():      return 42  

In the Maximo Autoscripts application, assume that we've created an Object LP script which will update the description upon save with the following code:

  import sys  sys.path.append('''C:\myLibrary''')    import test  desc += " The answer is  %d ! " % test.answer()  

Above we've used sys.path.append() function to make the custom library available to the script environment.  No reboot should be required.

 

After saving our record, we've updated the description with the value from our custom library.

image

 

Thanks for reading!

Pete

 

 

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSLKT6","label":"IBM Maximo Asset Management"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

UID

ibm11130865