My goal: search webapps folder to find all .war files and make sure a folder exists with the same name(indicating .war expansion)
My Code:
import os
import stat
file = open("hosts.txt","r")
for servername in file:
path = '\\\\'+servername.strip()+'\\d$\\tomcat\\Servers\\'
server_name = servername.strip()
for r,d,f in os.walk(path, topdown=False):
for files in f:
print os.path.join(r,files)
if files.endswith(".war"):
statinfo=os.stat(os.path.join(r,files))
print "FILE LOCATION: " + os.path.join(r,files)+ " FILE SIZE: " +str(statinfo.st_size)
print os.path.join(r,files)
folder= os.path.join(r,files).replace('.war','')
if os.path.isdir(folder):
None
else:
print "folder missing:",folder
My problem:
on each server i'm searching the directory structure is such:
\server\d$\tomcat\servers\servername(random)\webapps
my search is taking forever because i can't put a wildcard in at \servername\ to skip down to the webapps folder where the .war files exist. If i do this with 200 vm's then the search will be quite expensive.
the folder missing print indicates to me the .war file did not expand because there's no folder matching.
Would someone know of a way to search the specific directory or now to skip a directory?
Thank you