Python - 属性错误:索引
我现在卡住了...
我正在尝试连接到 t3://localhost:7001,用户名是 weblogic ...
成功连接到了属于 'wl_server' 域的管理服务器 'examplesServer'。
警告:使用了不安全的协议连接到服务器。为了确保数据传输的安全,应该使用 SSL 端口或管理端口。
[MBeanServerInvocationHandler]com.bea:Name=mainWebApp,Type=AppDeployment ParcelLienData.war ParcelLienData P 调用 WLST 时出现问题 - 错误追踪(最内层的错误): 文件 "D:\RM-Share\RM-Scripts\wl_deploy_localhost-WC.py",第 30 行,在 ? 属性错误:索引
我的代码是这样的:
import sys
import getopt
import os
loadProperties(sys.argv[1] +".props")
connect(username,password,adminUrl)
cmd = "awk -F'Name=' '{print $2}' | awk -F',' '{print $1}'"
f = open(r'./applicationsList.txt','r')
#In Above line you can specify the Complete Path of the "applications.txt" as well
print f
for i in range(5):
line=f.readline()
line1=line[:-4]
line2=line1[:1]
#check if the service or application is already present on the server...
cd('AppDeployments')
myapps=cmo.getAppDeployments()
for dep_file in myapps:
print depfile
print line
print line1
print line2
num1=depfile.index(line2)
print num1
num2=depfile.index(",", num1)
print num2
appName=depfile[num1:num2]
print appName
if appName == "line1":
print Redeploy
elif appName != "line1":
print "Not deploying"
continue
else:
print Deploying
请告诉我,我哪里出错了....
谢谢....
1 个回答
2
这个错误告诉你,下面这一行:
appName=dep_file[num1:num2]
是错的。你确定 dep_file
这个对象可以用切片来索引吗?
也许你应该先对 dep_name
调用一下 getName()
呢?