python glob file exist or not -
testids=subprocess.popen('ls cskpisummary-310410-lte-k-m2m-l-*ue1* | cut -d"-" -f7 | uniq', shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout) try: os.chdir(qmdlpath) except oserror: print 'qmdl directory not found' exit() testid in testids.stdout: file in glob.glob("*"+testid+"*"): print file
would able point out doing wrong here? testids = subprocess extracts list of testids(e.g: 20150422111035146). want use pattern see if file exists or not under qmdlpath directory have changed through chdir. if "not" present, print test id otherwise print message no files missing.the sample file name diag-20150422111035146-server1.txt
the problem reading in line pipe , line includes newline. when included in glob statement doesn't match anything. need strip whitespace end of string. replace loop line with:
for file in glob.glob("*"+testid.rstrip()+"*"):
Comments
Post a Comment