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

July 21, 2016 PeteHalbeisen

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

 

 

Previous Article
Internet Explorer does not correctly open .XLSX or .DOCX extension files in Maximo
Internet Explorer does not correctly open .XLSX or .DOCX extension files in Maximo

You may get unreadable and bad characters when downloading attached XLSX or DOCX files in Internet Explorer...

Next Article
STARTTLS: Authenticate First

with Patrick Nolan , Belinda Fuller , and Marcio Pereira Correa.   Email connectivity difficulties 99.9% of...

×

Want our latest news? Subscribe to our blog!

Last Name
First Name
Thank you!
Error - something went wrong!