Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 1.08 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Python - AttributeError: index
  2. import sys
  3. import getopt
  4. import os
  5.  
  6. loadProperties(sys.argv[1] +".props")
  7. connect(username,password,adminUrl)
  8.  
  9. cmd = "awk -F'Name=' '{print $2}' | awk -F',' '{print $1}'"
  10.  
  11. f = open(r'./applicationsList.txt','r')
  12. #In Above line you can specify the Complete Path of the "applications.txt" as well
  13.  
  14. print f
  15. for i in range(5):
  16.        line=f.readline()
  17.        line1=line[:-4]
  18.        line2=line1[:1]
  19.        #check if the service or application is already present on the server...
  20.        cd('AppDeployments')
  21.        myapps=cmo.getAppDeployments()
  22.        for dep_file in myapps:
  23.           print depfile
  24.           print line
  25.           print line1
  26.           print line2
  27.           num1=depfile.index(line2)
  28.           print num1
  29.           num2=depfile.index(",", num1)
  30.           print num2
  31.           appName=depfile[num1:num2]
  32.           print appName
  33.  
  34.           if appName == "line1":
  35.              print Redeploy
  36.           elif appName != "line1":
  37.              print "Not deploying"
  38.              continue
  39.           else:
  40.              print Deploying
  41.        
  42. appName=dep_file[num1:num2]