First python script to list server in websphere

Hi All,

This is my frist python script working on... I would like to list the servers or cluster from websphere. The script contents are below...
run by cmd - wsadmin.bat -lang jython -F
Error -
WASX7209I: Connected to process "dmgr" on node dmgrNode using SOAP connector;  The type of process is: DeploymentManager
WASX7017E: Exception received while running file ""; exception information: exception from Jython:
Traceback (most recent call last):
  File "<string>", line 13, in <module>
ValueError: call stack is not deep enough

Content of the script - this example got from - C:\IBM\WebSphere\AppServer\scriptLibraries\servers\V70

# Set global constants
import sys
import java
import AdminUtilities

# Setting up Global Variable within this script
bundleName = ""
resourceBundle = AdminUtilities.getResourceBundle(bundleName)

# Retrieve scripting objects from local name space
AdminConfig = sys._getframe(1).f_locals['AdminConfig']
AdminApp = sys._getframe(1).f_locals['AdminApp']
AdminControl = sys._getframe(1).f_locals['AdminControl']
AdminTask = sys._getframe(1).f_locals['AdminTask']
Help = sys._getframe(1).f_locals['Help']    

## Example 1 List available servers with given server type and node ##
def listServers(serverType="", nodeName="", failonerror=AdminUtilities._BLANK_):
    if (failonerror==AdminUtilities._BLANK_):
    msgPrefix = "listServers("+`serverType`+", "+`nodeName`+", "+`failonerror`+"): "

        # List servers
        print "---------------------------------------------------------------"
        print " AdminServerManagement:  List servers"
        print " Optional parameters: "
        print "         Server type:    "+serverType
        print "         Node name:      "+nodeName
        print " Usage: AdminServerManagement.listServers(\""+serverType+"\", \""+nodeName+"\") "
        print " Return: List of the servers in the cell. The list is filtered based on the server type and node name parameters if they are provided."
        print "---------------------------------------------------------------"
        print " "
        print " "
        # Construct optional parameters
        optionalParamList = []

        if (len(serverType) > 0):
            optionalParamList = ['-serverType', serverType]

        if (len(nodeName) > 0):
            # check if node exists
            node = AdminConfig.getid("/Node:appNode1" +nodeName+"/")
            if (len(node) == 0):
               raise AttributeError(AdminUtilities._formatNLS(resourceBundle, "WASL6040E", ["nodeName", nodeName]))
            optionalParamList = optionalParamList + ['-nodeName', nodeName]

        # List servers with specified server type
        servers = AdminTask.listServers(optionalParamList)

        # Convert Jython string to list
        servers = AdminUtilities.convertToList(servers)

        # Loop through each server in server list
        newservers = []
        for aServer in servers:
            # Obtain server and node names
            sname = aServer[0:aServer.find("(")]
            nname = aServer[aServer.find("nodes/")+6:aServer.find("servers/")-1]
            # Retrieve the server config id
            sid = AdminConfig.getid("/Node:appNode1"+nname+"/Server:"+sname)
            # convert unicode string to normal string
            sid = str(sid)
            if (newservers.count(sid) <= 0):
            #AdminUtilities.infoNotice("Server: " + sid)  
        return newservers
        typ, val, tb = sys.exc_info()
        if (typ==SystemExit):  raise SystemExit,`val`
        if (failonerror != AdminUtilities._TRUE_):
            print "Exception: %s %s " % (sys.exc_type, sys.exc_value)
            val = "%s %s" % (sys.exc_type, sys.exc_value)
            raise Exception("ScriptLibraryException: " + val)
            return -1
            return, val, tb), failonerror)

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't get it. Why are you running Python on a Java application server?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.