Maximo EAM

 View Only
  • 1.  Questions about developing Automation scripts - best practices

    Posted Tue April 19, 2022 10:06 AM
    I struggle with testing / developing my automation scripts.
    Our system is hosted and getting access to logs is difficult.
    The "test" function of a automation script never seems to work for me.

    I primarily develop in jython and sometimes I just want to test what libraries are available.
    Sometimes I need to print variables at break points to validate.

    Can anyone point me to best practices, hints or tips for developing and testing scripts.

    ------------------------------
    Chris Schulz
    ------------------------------


  • 2.  RE: Questions about developing Automation scripts - best practices

    Posted Tue April 19, 2022 11:02 AM
    Edited by Tim Ferrill Tue April 19, 2022 11:04 AM
    Chris,

    Good questions. IBM could do a lot to improve the script development process.

    Some tricks that I've learned over the years, particularly for hosted environments:
    • Use Error messages in the UI to troubleshoot values or script logic. This can help you quickly diagnose where the problem code resides in a large script.
    • Run Scripts manually for test/development purposes. I find this more straightforward than the Test functionality personally, but that could be due to my own limitations with the test capabilities. (You'll need to add the EXECUTE sigopt in Application Designer and then grant the permission in Security Groups).
    • Have a utility script to read log files via Script. Something like this will let you read log files from the remote server directly in the Autoscript window.

    Sample Log File script:
    from psdi.server import MXServer
    from java.io import File
    from java.io import FileReader
    from java.io import BufferedReader
    
    logFile = 'logs\\MXServer_maximo.log'
     
    server = MXServer.getMXServer()
    
    logFolder = server.getProperty("mxe.logging.rootfolder")
    filePath = logFolder.replace("\\","\\\\").rstrip("\\") + "\\\\.."
    
    if logFile is not None:
      filePath = filePath + "\\" + logFile
      input = FileReader(filePath);
      buffer = BufferedReader(input);
    
      try:
        line = buffer.readLine()
        while line is not None:
          print(line)
          line = buffer.readLine()
      finally:
        buffer.close();​


    ------------------------------
    Tim Ferrill
    Solutions Consultant
    Intelligent Technology Solutions
    tferrill@webuildits.com
    www.webuildits.com
    @tferrill/@webuildits
    ------------------------------



  • 3.  RE: Questions about developing Automation scripts - best practices

    Posted Tue April 19, 2022 04:59 PM
    this is interesting, I look forward to trying it. thanks.

    ------------------------------
    Chris Schulz
    ------------------------------