In this post I would like to introduce a cool feature to upload your Jython scripts developed in Eclipse directly to Maximo/ICD without the need to jump to the scripting application and doing some copy/paste actions. To Archive this objective we will utilize the Integration Framework and will write a small Jython script to be called from Eclipse and utilizing this interface. I will show you step by step the different configuration steps.
This is a quit complex configuration to do and there are a lot of places to introduce errors so that the complete system will not work. Please post me your experiences with the configuration as a comment so I can improve this article over time.
Prerequisites
What are the prerequisites for our project:
- An Eclipse Installation with PyDev integrated where you develop your Jython Scripts
- A local Jython 2.x installation (which should normally already be in place). Please consider that we need a full installation and it is not enough to just have a copy of the jython.jar file since we need some standard Jython libraries for our project.
- Access to a Maximo/ICD System
The solution currently only has been tested with local authorization. The Upload script might need slight modifications for LDAP authorization (comments welcome :-).
The solution currently only supports http protocol. If you are using https the upload script might need some modifications.
Preparations Integration Framework in Maximo/ICD
Create a new Object Structure
We need to create an own Object Structure based on the existing MXScript Structure.
- Go to menu Integration → Object Structure and search the MXScript Object Structure.
- Duplicate the Object Structure (Select Action → Duplicate Object Structure)

- The new Object Structure should be called JYSCRIPT unless you want to edit the upload script later on.
- Remove the Source Object „AUTOSCRIPT/VARSThe configuration for the duplicated Object Structure should now look like this:

- Select Action → Exclude/Include Fields
Exclude all fields except the following ones:
- AUTOSCRIPT
- DESCRIPTION
- LOGLEVEL
- SCRIPTLANGUAGE
- SOURCE
- VERSION
Create an Enterprise Service
A new Enterprise Service must be created.
- Go to menu Integration → Enterprise Services
- Create a new Record and fill in the following fields only:

- Save the Enterprise Services
Create an External System
A new External System must be created by the following steps:
- Go to menu Integration → External Systems
- Create a new Record and fill in the System Tab with the following values:

- Be sure all fields are filled in as shown
- Select the tab “Enterprise Services” and create a connection to the previously created Enterprise service. For this select the “New Row” button. Fill in the new line as follows:

- Be sure that the enabled box is checked.
- Save the External System. The configuration on the Maximo/ICD side is now finished.
Configuration of the Eclipse Side
The configuration of Eclipse consist of two steps:
- Prepare Upload Script
- Create a “Run entry” in the Run configuration.
Prepare Upload Script
Take the following script and store it in a place of a Eclipse project. The project should have a valid Jython Runtime configured. Please have a look to this article for proper Eclipse setup if you are unsure.
#-------------------------------------------------------------
# AUTOSCRIPT: UPLOADSCRIPT
# DESCRIPTION: Script to upload Jython Scripts from
# Eclipse to Maximo / ICD
# AUTHOR: Matthias Stroske
# Created 25.11.15
# VERSION: 1.0
# COPYRIGHT: (c) Matthias Stroske
# MAXIMO/ICD Version: 7.5 and higher
#-------------------------------------------------------------
# History of Changes
#
# Ver Date Name Description
# 1.0 01.10.15 Matthias Stroske Initial Version
# 1.1 25.11.15 Matthias Stroske Improved Parameter Handling
#
#-------------------------------------------------------------
import sys
import httplib
import base64
import string
import re
from xml.sax.saxutils import escape
def main():
if len(sys.argv) < 5:
print "USAGE: UploadScript.py <inDatei> <host> <user> <password>"
sys.exit()
inDatei = sys.argv[1]
host = sys.argv[2]
user = sys.argv[3]
password = sys.argv[4]
# Set Defaults as far as possible
scriptName = None
scriptDescription = None
logLevel = "ERROR"
version = "1.0"
httpUrl = "http://" + host + "/meaweb/es/JYSCRIPT/JYSCRIPT"
try:
f = open(inDatei)
fileContent = f.read()
except Exception,ex:
print ("Error reading the input file!")
print ("Exception:" + str(ex))
else:
f.close
firstLines = fileContent.split("\n", 15)
for line in firstLines:
matchObj = re.match(r'^#\s*DESCRIPTION:(.*)',line, re.I)
if matchObj:
scriptDescription = matchObj.group(1)
matchObj = re.match(r'^#\s*AUTOSCRIPT:(.*)', line, re.I)
if matchObj:
scriptName = matchObj.group(1)
matchObj = re.match(r'^#\s*LOGLEVEL:(.*)', line, re.I)
if matchObj:
logLevel = matchObj.group(1)
# Simple Style
matchObj = re.match(r'^#\s*VERSION:(.*)', line, re.I)
if matchObj:
version = matchObj.group(1)
# CVS Style
matchObj = re.match(r'^#\s*Revision:(.*)', line, re.I)
if matchObj:
version = matchObj.group(1)
if scriptName is None or scriptDescription is None:
print "ScriptName and ScriptDescription have to be specified in first Script Lines!"
sys.exit()
print "Script Name = " + scriptName.strip()
print "DESCRIPTION = " + scriptDescription.strip()
print "LOGLEVEL = " + logLevel.strip()
print "VERSION = " + version.strip()
message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
message += "<SyncJYSCRIPT xmlns=\"http://www.ibm.com/maximo\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"
message += "<JYSCRIPTSet>\n"
message += "<AUTOSCRIPT>\n"
message += "<AUTOSCRIPT>" + scriptName.strip() + "</AUTOSCRIPT>\n"
message += "<DESCRIPTION>" + scriptDescription.strip() + "</DESCRIPTION>\n"
message += "<LOGLEVEL>" + logLevel.strip() + "</LOGLEVEL>\n"
message += "<SCRIPTLANGUAGE>jython</SCRIPTLANGUAGE>\n"
message += "<VERSION>" + version.strip() + "</VERSION>\n"
message += "<SOURCE>\n"
message += escape(fileContent)
#message += "pass\n"
message += "</SOURCE>\n"
message += "</AUTOSCRIPT>\n"
message += "</JYSCRIPTSet>\n"
message += "</SyncJYSCRIPT>\n"
message += "\n"
contentType = "application/soap+xml;charset=UTF-8;action=\"urn:processDocument\""
auth = 'Basic ' + string.strip(base64.encodestring( user + ':' + password))
webservice = httplib.HTTPConnection(host)
#webservice.set_debuglevel(5)
headers = {"Content-type": contentType, "Content-Length": len(message), "Authorization": auth}
webservice.request("POST", httpUrl, message, headers)
# get the response
res = webservice.getresponse()
if res.status == 200:
print "Script upload successful!"
else:
print "Script upload completed with RC = " + str(res.status)
webservice.close()
return
if __name__ == "__main__":
main()
Eclipse External Tools configuration
To run the script in context of Eclipse you need to do an additional configuration step in Eclipse.
Find the following Icon in the Eclipse iconbar: 
Select the little arrow beside the icon to expand the menu and select “External Tools Configurations…”

In the following Window fill in the Head section with the Name of the configuration.
Continue to fill in the Main tab with the following values:
- Location: The location of your locally installed Jython interpreter.
- Working Directory: should be ${workspace_loc:/<ProjectName}
- Arguments: 5 Arguments for the Jython interpreter to run.
- Name of Jython Upload Script: e.G. ${workspace_log:/Blog/UloadScript.py}
- Name of the Script to be uploaded: Best we can specify here is always: ${workspace_loc}${selected_resource_path}
- Maximo / ICD Host: IP Adress or Hostname of the Maximo Server
- Username in Maximo / ICD
- Password in Maximo / ICD *** yes I know it is not good to store the PW in clear-text. With little modifications you could store it base64 encoded here if you modify the Jython script slightly.

Preparing your script and using the new tool
Preparing your script
To use the new tool your script must follow a little convention. The first 15 lines must include relevant information which are required to synchronize the script with Maximo/ICD.
#AUTOSCRIPT: UPLOADSCRIPT
#DESCRIPTION: PYTHON UPLOAD SCRIPT 2
#LOGLEVEL: ERROR
#VERSION: 1.0
This are fields which map to the appropriate fields in Maximo/ICD. The AUTOSCRIPT field is the Name of the Autoscript in Maximo/ICD. With the upload you can create new automation scripts, but you can not create or modify any launchpoints. When you change the DESCRIPTION,VERSION or LOGLEVEL field later on these fields are modified in Maximo/ICD.
I have created a base template for your code, which can be found in this blog.
Using the new Tool
To use the tool we assume, that you are now editing your custom Maximo/ICD Jython script with the information lines included and some Jython Code. From this place you just need to run the Upload Script by Clicking the Run external Symbol in the iconbar again.
A script with the name you have chosen during configuration should appear in the drop down list.
After some second you will hopefully get a response “Script upload successful” in the Console View of Eclipse. Otherwise you’ll get an error with the http Return Code.

I hope the solution will work in your environment!