Python - AttributeError: index
Question: 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....


Answer: 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?

