Question : Jython - need try / except Logic for .py Script

Can someone help some try/except logic that will deal with the following error, which is due to the JVM/AppServer being down?  The calling jython script is listed below the error.

[05122010 13:24] :UNIX:------ End Routine(0) ----------
[05122010 13:24] :UNIX:# CL01EFCShip JVM Stop in Progress...
[05122010 13:24] :UNIX:
[05122010 13:24] :UNIX:/apps/WebSphere/AppServer/v70/ASRShip/PRD/profiles/ASRShip/bin/wsadmin.sh -lang jython -f /apps/WebSphere/AppServer/local/v70/admin/scripts/migration/jython/manageAppServer.py CL01EFCShipPRD ASRShipPRD01
WASX7209I: Connected to process "adminagent" on node ASRShipPRD01 using SOAP connector;  The type of process is: AdminAgent
WASX8011W: AdminTask object is not available.
Initializing Jython Environment...
Initialization Completes
Stopping Application Server CL01EFCShipPRD on ASRShipPRD01
WASX7015E: Exception running command: "stopAppServer('CL01EFCShipPRD', 'ASRShipPRD01')"; exception information:
 com.ibm.ws.scripting.ScriptingException: WASX7252E: Unable to locate running server "CL01EFCShipPRD".

manageAppServer.py
#===================================================================
# START stopAppServer
#===================================================================
def stopAppServer(appServer, node):

        print "Stopping Application Server", appServer, "on", node

        # Call AdminControl to stop the appServer
        AdminControl.stopServer(appServer, node)

        print "Application Server", appServer, "stopped"

#===================================================================
# END stopAppServer
#===================================================================


#===================================================================
# START startAppServer
#===================================================================
def startAppServer(appServer, node):

        print "Starting Application Server", appServer, "on", node

        # Call AdminControl to start the appServer
        AdminControl.startServer(appServer, node)

        print "Application Server", appServer, "started"

#===================================================================
# END stopAppServer
#===================================================================

Answer : Jython - need try / except Logic for .py Script

Something like this perhaps?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
wsadmin>
wsadmin>def stopAppServer( serverName, nodeName ) :
wsadmin>  print "Stopping Application Server %s on %s" % ( serverName, nodeName )
wsadmin>  try :
wsadmin>    AdminControl.stopServer( serverName, nodeName )
wsadmin>    print "Application Server %s stopped" % serverName
wsadmin>  except :
wsadmin>    print "Application Server %s not found - perhaps it's already stopped?" % serverName
wsadmin>


wsadmin>stopAppServer( 'CL01EFCShipPRD', 'ASRShipPRD01' )
Stopping Application Server CL01EFCShipPRD on ASRShipPRD01
Application Server CL01EFCShipPRD not found - perhaps it's already stopped?
wsadmin>
Random Solutions  
 
programming4us programming4us