I'm trying to open a text file called filteredApps.txt which contains "app1.ear, app2.ear, app3.ear, app4.ear" as new lines, pass it to a list and then compare it to another list. Then finally call the deploy function in the main() method but I get AttributeError: getitem in the line hightlighted below on the code:
appNames = ['/opt/app1.ear', '/opt/app2.ear', '/opt/app3.ear', '/opt/app4.ear']
def filteredApps():
filteredAppsList = []
appToDeploy = open("filteredApps.txt","r")
for deploy in appToDeploy: #Code breaks here
filteredAppsList.append(deploy)
return map(str.strip, filteredAppsList)
def main():
finalListToDeploy = []
listToDeploy = filteredApps() #Code breaks here as well
for paths in appNames:
for apps in listToDeploy:
if apps in paths:
finalListToDeploy.append(apps)
deployApplication(finalListToDeploy)
if __name__ == "__main__":
main()
deployApplicationdefined?appToDeploy = open("filteredApps.txt","r")not the right way to do it