Angel491 Angel491 - 1 year ago 111
Python Question

NameError: checkDeployStatus in script

While executing the below script to deploy SOA composites and getting NameError: checkDeployStatus.The below script deploys every composite and checks the log to see if it's deployed or not.

from import FileInputStream
from java.util import HashMap
from java.util import HashSet
from java.util import ArrayList
from import File
from import URL
import sys
import os
import javax
import java
print '++++++++starting deployment+++++++++'
connect('weblogic', 'password', 't3://stabc:8001')
for jarfile in dirList:
if (jarfile.startswith("sca_") & jarfile.endswith(".jar")):
print 'deploying ' + jarfile + ' with ' + jarfile.replace(' ', '')[:-11] + '_cfgplan' + '.xml'
sys.stdout = open("/tmp/sca_deploy.out","w")
sca_deployComposite(serverURL, sarLocation, [overwrite], [user], [password], [forceDefault], [configplan], [partition])
sys.stdout = oldstdout
print '++++++++++++++++++Checking deploy Status++++++++++++++++'
print '+++++++++++++++++++Test passed++++++++++++++++++++++'

def checkDeployStatus(filename):
success = false
for line in open(filename):
if "Deploying composite success" in line:
print '++++++++++++++++++++++++++++++Composite is Alright++++++++++++++++++++++'
if "error" in line:
if success is false:
print line
raise Exception("Deployment Failed")

Answer Source

It's hard to tell because the indentation is off, but it appears that checkDeployStatus is defined after it is first called which would lead to the NameError.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download