NameError: checkDeployStatus in script

NameError: checkDeployStatus in script

在执行以下脚本部署 SOA 组合并出现 NameError 时:checkDeployStatus.The 下面的脚本部署每个组合并检查日志以查看它是否已部署。

Deploysoa.py

  from java.io import FileInputStream
  from java.util import HashMap
  from java.util import HashSet
  from java.util import ArrayList
  from java.io import File
  from java.net import URL
  import sys
  import os
  import javax
  import java
  print '++++++++starting deployment+++++++++'
  connect('weblogic', 'password', 't3://stabc:8001')
  dirList=os.listdir(sys.argv[0])
  for jarfile in dirList:
  if (jarfile.startswith("sca_") & jarfile.endswith(".jar")):
    print 'deploying ' + jarfile + ' with ' + jarfile.replace(' ', '')[:-11] + '_cfgplan' + '.xml'
    oldstdout=sys.stdout
    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++++++++++++++++'
    checkDeployStatus("/tmp/sca_deploy.out")
    print '+++++++++++++++++++Test passed++++++++++++++++++++++'

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

很难判断,因为缩进已关闭,但似乎 checkDeployStatus 已定义 首次调用后会导致 NameError.