Download (all) Scripts from Maximo / ICD to your Eclipse Project
In one of my last blogs I showed a very nice way how to upload Jython scripts from Eclipse to your Maximo / ICD environment. Now what about the situation that you already have a Maximo / ICD environment with tons of scripts in it? In this blog I will show you a simple way how you can include all these scripts to your Eclipse project within 15 minutes. This will also include the first comment lines needed for the later upload.
To achieve our goal the following steps are needed:
- Setup an application export in the Autoscript application
- Download a XML File including all scripts
- Run a Jython script to extract all the unique scripts
Setup an application export in the Autoscript application
The application export will be configured using the “Object Structures” application. Launch:
Go To > Integration > Object Structures
In the Object Structures application search for the “MXSCRIPT” Object Structure and open it.
After opening select an action:
Select Action > Add/Modify Application Export Support
In the dialog box create a new row in the table using the values shown here:
Press OK. The export support now has been created. Next step is to grant the security rights to the user group which should use the tool. In my example I will grant the rights to the maxadmin group. Goto the following Menu:
Go To > Security > Security Groups
Now perform the following steps:
- Search and open the security group you want to grant the rights to.
- Change to the “Applications” Tab.
- Filter for the Application “Automation Scripts” and select the record.
- In the Options for Automation Scripts section enable the option “Application Export”.
- Save the Security Group.
- Logoff and Logon again to Maximo / ICD. Be sure that all your user sessions are successfully logged of – otherwise the settings will not be activated.
Download a XML File including all scripts
To download a XML File which includes all scripts in your system you have to go to the Automation Scripts application.
Go To > System Configuration > Plattform Configuration > Automation Scripts
If the previous step worked correctly you should now see a new Icon in the iconbar for the application export. Before you press this button you have to search for the scripts to export. If all scripts should be exported just press enter in the search field. Now press the icon.
In the “Application Export” Dialog you just can take all settings and press “OK”.
The XML File now will be downloaded to the download directory of your browser on your local PC.
Run a Jython script to extract all the unique scripts
First of all you have to have a project setup in Eclipse where you would like to store your downloaded scripts. This chapter requires a complete project-setup using Eclipse, Jython and PyDev like described in this blog. Copy the downloaded XML file to this directory and name it scripts.xml.
Now create a Jython script with the following code:
#AUTOSCRIPT:EXPORTSCRIPTS #DESCRIPTION:Script to export all Jython Scripts on a Server #LOGLEVEL:ERROR from java.io import File from org.jdom.input import SAXBuilder xmlFile = File("scripts.xml") builder = SAXBuilder() document = builder.build(xmlFile) wrap = document.getRootElement() ns = wrap.getNamespace() rootNode = wrap.getChild("MXSCRIPTSet", ns) liste = rootNode.getChildren("AUTOSCRIPT",ns) for i in range(0,liste.size()): node = liste.get(i) scriptName = node.getChildText("AUTOSCRIPT",ns) scriptDesc = node.getChildText("DESCRIPTION",ns) scriptVersion = node.getChildText("VERSION",ns) scriptDebug = node.getChildText("LOGLEVEL",ns) scriptCode = node.getChildText("SOURCE",ns).encode('utf-8') scriptFile = open(scriptName + ".py","w") scriptFile.write("#AUTOSCRIPT: " + scriptName + "\n") scriptFile.write("#DESCRIPTION:" + scriptDesc + "\n") scriptFile.write("#VERSION: " + scriptVersion + "\n") scriptFile.write("#LOGLEVEL: " + scriptDebug + "\n") scriptFile.write(scriptCode) scriptFile.close()
This scripts requires the Java JDOM Class. Please ensure that the jdom.jar file is included in your PYTHONPATH. You can check this by right-click on your Eclipse project and select the “Properties” Menu. Check under “PyDev – PYTHONPATH” if jdom.jar is existent. If not use the “Add zip/jar/egg” Button to add it.
Remark: If you don’t have a local version of jdom.jar you can find one on your Maximo / ICD Server in the following directory: %WEBSPHERE _DIR%\AppServer\profiles\ctgAppSrv01\installedApps\ctgCell01\MAXIMO.ear\lib
Hopefully after a refresh of your project/folder (F5) you will see a bunch of new scripts! Congratulations!