Python - 属性错误:索引

发布于 2024-11-06 14:20:25 字数 1514 浏览 5 评论 0原文

我被困在这里...

正在使用用户 ID weblogic 连接到 t3://localhost:7001 ... 已成功连接到属于域“wl_server”的管理服务器“examplesServer”。

警告:使用不安全的协议连接到 服务器。为了确保线路安全,SSL 端口或 应改用管理端口。

[MBeanServerIncationHandler]com.bea:名称=mainWebApp,类型=AppDeployment ParcelLienData.war 包裹留置权数据 磷 调用 WLST 时出现问题 - 回溯(最里面的最后一个): 文件“D:\RM-Share\RM-Scripts\wl_deploy_localhost-WC.py”,第 30 行,在? AttributeError:index

我的代码看起来像:

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

请建议,我哪里出错了......

谢谢......

I am stuck here...

Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'examplesServer' that belongs to domain 'wl_server'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

[MBeanServerInvocationHandler]com.bea:Name=mainWebApp,Type=AppDeployment
ParcelLienData.war
ParcelLienData
P
Problem invoking WLST - Traceback (innermost last):
File "D:\RM-Share\RM-Scripts\wl_deploy_localhost-WC.py", line 30, in ?
AttributeError: index

My code looks like:

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

Please advice, where am I going wrong....

Thanks....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沙沙粒小 2024-11-13 14:20:25

该错误告诉您这一行:

appName=dep_file[num1:num2]

是错误的。您确定可以使用切片对 dep_file 对象进行索引吗?

也许您应该首先在 dep_name 上调用 getName()

The error tells you that this line:

appName=dep_file[num1:num2]

Is wrong. Are you sure the dep_file object can be indexed with a slice?

Maybe you should call getName() on dep_name first?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文