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

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -