def dealresult(basepath): for dirname,subdirlist,filelist in os.walk(basepath): #topdown=False): print('found directory: %s' %dirname) global pdfcount, csvcount for fname in filelist: if fname.endswith('.pdf'): print 'the pdf report is',fname shutil.copy(os.path.join(dirname,fname),'./result/ixia%d.pdf'%count) pdfcount +=1 #if fname.endswith('.csv') and fname.startswith('Result'): # shutil.copy(os.path.join(dirname,fname),'ttttest.csv') if fname.endswith('.csv') and fname.startswith('Aggreg'): upload_result["csvfile"]=os.path.join(dirname,fname) shutil.copy(os.path.join(dirname,fname),'./result/ixia%d.csv'%csvcount) csvcount +=1 print 'the csv file is copied' print '\t%s'%fname def clear_tmpresult(basepath): for i in os.listdir('tmpresult'): print i shutil.rmtree('tmpresult/'+i) if __name__=__main__: print 'The current directory is:',os.getcwd() print 'Copy the running test case to case_to_run folder' print "----Now Start the test, Please Input the required parameters-----------" #port_conf['port1']=raw_input("Port 1 : ") #port_conf['port2']=raw_input(" #upload_result['testnote']=raw_input("Enter test notes: ") print "----Please refer to the page http://10.206.1.21/tms/productinfo.php for the following informaton"-----" #upload_result["resulttype"]=0 ixauto #upload_result["tstype"]="RFC2544"" upload_result["product_id"]=int(raw_input("Enter the product ID: ")) upload_result["swbuild_id"]=int(raw_input("Enter the swbuild_id: ")) upload_result["dutsn"]=raw_input("Enter the dut's serieal no: ") for testcase in os.listdir('./case_to_run'): print "Now To run the case :",testcase totest=raw_input("Do you want to run it? yes/no") if totest=='no': break else: upload_result["testtype_id"]=int(raw_input("Enter the testtype_id ")) upload_result['testnote']=raw_input("Enter test notes: ") upload_result['trial']=int(raw_input("Enter trial no: ")) print >>log, (os.system("./ixos/bin/ixwish "+testcase)) print "Finishing IXIA Test Case:"+testcase time.sleep(30) print "Now starting to upload the result to TMS server" tmsupload_wopdf.tms_upload_ixia(tms_server,upload_result) time.sleep(30) print "Now clear the tmpresult folder, all the files in the folder will be deleted." clear_tmpresult(basepath):
file.close() loopbreak=True break retrycounter+=1 clear_tmpresult(basepath) file.close() continue break if loopbreak: continue print "Now uploading the result to TMS server for test:"+testname upload_result['testnote']=str(counter1) + ',' + str(retrycounter)+ ' Uploaded_on_%s' % time.strftime('%H:%M') tmsupload_wopdf.tms_upload_ixia(tms_server,upload_result) #print upload_result['testnote'] time.sleep(15) retrycounter=0 for line in f3: print line #print "Now clear the tmpresult folder, all the files in the folder will be deleted." clear_tmpresult(basepath) file.close() runningcase.close() #print "------Ixia test ---Done----Please check the tms result-------Also there is a backup in the result foler-----" print "ALL test cases have been executed."