def radiookapi_process_link(url, formated_time_run): article = hashlib.sha224(url).hexdigest() # This packages the request (it doesn't make it) request = requests.get(url, headers = {"User-Agent" : "Mozila Firefox 56.0.1"}) if request.status_code == 200 html = request.text # it is important to have the date we have accessed this data date_accessed = formated_time_run date_published = formated_time_run # Let us write the html to file locally for archiving purposes # Below is the format of the filename of the html data. # take it to BeautifulSoup soup = BeautifulSoup(html, "html.parser") # Now get all the images, download them and pass a list of them #images = get_images(soup) # Now we get the most important pieces of information from the beautifulsoup object date_infos = soup.findAll("div", {"class" : "pane-content"})[2].p.text images_url = [] images_url = radiookapi_image(soup) image_filename = radiookapi_download(images_url, url) title, body, short_message, tweet_message = radiookapi_content(soup) title, body, short_message, tweet_message = clean_up(title, body, short_message, tweet_message) # Now we get the infos formated as we would like it formated_article = get_formated_article(title, body, short_message, tweet_message, date_accessed, date_published, url, image_filename) html_file_name = date_published + "-%s" %article[:10] + ".html" fo.write_html(html_file_name, html) return formated_article
def createcase(casepath, defaultname, resultname, Speparamlist): bk = xlrd.open_workbook(casepath, formatting_info=True) # 打开excel文件 httpString = bk.sheet_by_name('Sheet1').cell_value(0, 0) # 接口url在表1里 sh = bk.sheet_by_name(defaultname) runFirstnullresult = [] methods = sh.cell_value(1, 1) a = FileOperation.FileExsit(os.getcwd() + r'/log/failresult.html') if a == True: FileOperation.DelFile(os.getcwd() + r'/log/failresult.html') try: list1 = getvalue.getdvalue(casepath, defaultname, methods) if methods == 'GET': mypermission = permission1 else: mypermission = permission2 for i in range(len(list1) - 1, len(list1)): ###大于等于列表长度-1参数 nulllist = [] iter = itertools.combinations(list1, i) ###i表示取列表中的n个参数进行组合 nulllist.append(list(iter)) ######iter是一个循环器,所以它的值只能用1次,需要把值存到变量里 # print nulllist for j in range(0, len(nulllist[0])): ####生成列表个数 parameter1 = mypermission parameter2 = list(nulllist[0][j]) testcase = parameter1 + parameter2 # print testcase AC_result = Requesttype.Requesttype(methods, testcase, httpString) eachcase = Requesttype.Requestcase(methods, testcase, httpString) # print eachcase # print EX_result runFirstnullresult.append(eachcase) runFirstnullresult.append(AC_result) for i in range(0, len(list1)): for y in Speparamlist: parameter1 = getvalue.getdvalue(casepath, defaultname, methods) x = sh.cell_value(i + 4, 0) if methods == 'GET': element2 = x + '=' + y else: element2 = '"' + x + '":"' + y + '"' parameter1.pop(i) # print list1 parameter1.append(element2) # print parameter1 parameter = mypermission testcase = parameter + parameter1 AC_result = Requesttype.Requesttype(methods, testcase, httpString) print AC_result eachcase = Requesttype.Requestcase(methods, testcase, httpString) runFirstnullresult.append(eachcase) runFirstnullresult.append(AC_result) # print runFirstnullresult return runFirstnullresult Execution.Executionmode1(runFirstnullresult, casepath, resultname) except Exception, e: print e
def runcase(casepath, sheetname, resultname): bk = xlrd.open_workbook(casepath) # 打开excel文件 httpString = bk.sheet_by_name('Sheet1').cell_value(0, 0) # 接口url在表1里 sh = bk.sheet_by_name(sheetname) # 测试数据在表2里 mrows = sh.nrows mcols = sh.ncols runFirstresult = [] a = FileOperation.FileExsit(os.getcwd() + r'/log/failresult.html') if a == True: FileOperation.DelFile(os.getcwd() + r'/log/failresult.html') try: #拼接参数名与参数值 for j in range(1, mrows): methods = sh.cell_value(j, 2) testcase = [] for i in range(3, mcols): x = sh.cell_value(0, i) # 参数名,获取单元格的数据类型 y = sh.cell_value(j, i) # 参数值 xtype = sh.cell(0, i).ctype ytype = sh.cell(j, i).ctype ###################ctype : 0 empty,1 string, 2 number, 3 date, 4 boolean, 5 error if (xtype == 2): x = str(int(x)) if (ytype == 2) or (ytype == 4): y = str(int(y)) y = str(y) if x.find(' ') != -1 or y.find(' ') != -1: x = x.replace(' ', '+') y = y.replace(' ', '+') if ytype == 4 and y == '1': y = 'True' elif ytype == 4 and y == '0': y = 'False' if methods == 'GET': element2 = x + '=' + y else: element2 = '"' + x + '":"' + y + '"' testcase.append(element2) # print testcase AC_result = Requesttype.Requesttype(methods, testcase, httpString) eachcase = Requesttype.Requestcase(methods, testcase, httpString) print AC_result runFirstresult.append(eachcase) runFirstresult.append(AC_result) # print runFirstresult return runFirstresult Execution.Executionmode(runFirstresult, casepath, casesheet, resultname) except Exception, e: print e
def dateBeforeCurrentDate(dataString): #Get today's year, month, date today=datetime.datetime.now() year=today.year month=today.month day=today.day #Generate a dictionary to connect the string month to month dic={'JAN':1,'FEB':2,'MAR':3,'APR':4,'MAY':5,'JUN':6,\ 'JUL':7,'AUG':8,'SEP':9,'OCT':10,'NOV':11,'DEC':12} #Get the date from the string words=FileOperation.splitLine(dataString) fyear=words[2] fmonth=words[1] fday=words[0] #compare the provided date and the current date if int(fyear)>int(year): print 'ERROR:The date is not correct' elif dic[fmonth]>int(month): print 'ERROR:The date is not correct' elif int(fday)>int(day): print 'ERROR:The date is not correct'
def sendEmail(): """ 发送邮件 """ failcase = os.path.dirname(os.path.abspath(__file__)) + r'\log\failresult.html' Failtest = [] isFExists = FileOperation.FileExsit(failcase) # print isFExists if not isFExists: pass else: Failtest = ['%s'%(failcase)] MSG_TEXT = "failed case result addreass : 到时候我会把附件里的文件放到服务器上,然后这个位置放个链接。目前暂时打开附件查看。" myEmail.SendEmailWithAttachment('*****@*****.**',['*****@*****.**','*****@*****.**'],'AutoTestResult-sentbyHSN',MSG_TEXT,Failtest,'smtp.qiye.163.com:25') print u"邮件已发送"
def ViewPCInfos(): output = os.popen('pip list') if 'WMI' not in output.read(): os.system('pip install wmi') pcname = socket.getfqdn(socket.gethostname()) currentusername = getpass.getuser() mac = uuid.UUID(int = uuid.getnode()).hex[-12:] mac_address = "-".join([mac[e:e+2] for e in range(0,11,2)]) n_ip = re.search('\d+\.\d+\.\d+\.\d+',str(Popen('ipconfig', stdout=PIPE).stdout.read())).group(0) #Add a str here to suit on python3 print("=====================PC Infos======================") os_version() cpu_mem() disk() print("PC name: " + pcname) print("Current login user: "******"Intranet IP: " + n_ip) print("Public network IP: " + GetPublicNetworkIP()) print("Mac address: " + mac_address) print("===================================================") FileOperation.CountineOrExit()
def get_opeind(appid, path): openid = 'NULL' a = FileOperation.FileExsit(os.getcwd() + path) if a == True: file = open(os.getcwd() + path, "r") for line in file.readlines(): if line[0] == '#' or line[0] == '#' or len(line.strip()) == 0: pass else: app_openid = eval(line.decode(encoding='utf-8')) # print app_openid if app_openid['appid'] != appid: continue else: openid = app_openid['openid'] else: print '请检查/appid/appidlist.txt文件是否存在。' send_emails.send_failEmail('请检查/appid/appidlist.txt文件是否存在。') return openid
def get_appidinfo(getvalue_dict): today = str(time.strftime("%Y-%m-%d %H.%M", time.localtime(time.time()))) a = FileOperation.FileExsit(os.getcwd() + r'/log/failresult.html') if a == True: FileOperation.Copy_file( os.getcwd() + r'/log/failresult.html', os.getcwd() + r'/log/failresult_history/failresult_%s.html' % today) FileOperation.DelFile(os.getcwd() + r'/log/failresult.html') b = FileOperation.FileExsit(os.getcwd() + r'/log/static.txt') if b == True: FileOperation.Copy_file( os.getcwd() + r'/log/static.txt', os.getcwd() + r'/log/staticlog/static_%s.txt' % today) FileOperation.DelFile(os.getcwd() + r'/log/static.txt') app_openid_data = [] # print getvalue_dict path = getvalue_dict['appid'] # print path a = FileOperation.FileExsit(os.getcwd() + path) if a == True: file = open(os.getcwd() + path, "r") for line in file.readlines(): if line[0] == '#' or line[0] == '#' or len(line.strip()) == 0: pass else: app_openid = eval(line.decode(encoding='utf-8')) app_openid_data.append(app_openid) # appid = line.strip('\n').decode(encoding='utf-8') # appidlist.append(appid) file.close() # print app_openid_data return app_openid_data else: print '请检查/appid/appidlist.txt文件是否存在。' send_emails.send_failEmail('请检查/appid/appidlist.txt文件是否存在。') return 'NULL'
def createtypecase(casepath, defaultname, resultname, Speparamlist): bk = xlrd.open_workbook(casepath, formatting_info=True) # 打开excel文件 httpString = bk.sheet_by_name('Sheet1').cell_value(0, 0) # 接口url在表1里 sh = bk.sheet_by_name(defaultname) nrows = sh.nrows runresult = [] methods = sh.cell_value(1, 1) a = FileOperation.FileExsit(os.getcwd() + r'/log/failresult.html') if a == True: FileOperation.DelFile(os.getcwd() + r'/log/failresult.html') try: list1 = getvalue.getdvalue(casepath, defaultname, methods) # print list1 if methods == 'GET': mypermission = permission1 else: mypermission = permission2 for i in range(5, nrows): ##所在行 x = sh.cell_value(i, 0) # 参数名,获取单元格的数据类型 y = sh.cell_value(i, 1) # 参数值 z = sh.cell_value(i, 2) #参数类型 if z == 'str': pass # print '不替换字符串类型参数' else: z = "<type '%s'>" % z testlist = [] for j in range(0, len(Speparamlist)): deparamtype = type(Speparamlist[j]) if z == str(deparamtype): pass # print '取出同类型参数不进行替换' else: testlist.append(Speparamlist[j]) # print testlist for n in range(0, len(testlist)): y = str(testlist[n]) x = sh.cell_value(i, 0) # print x parameter1 = getvalue.getdvalue(casepath, defaultname, methods) # print parameter1 if methods == 'GET': element2 = x + '=' + y else: element2 = '"' + x + '":"' + y + '"' # print element2 parameter1.pop(i - 4) parameter1.append(element2) # print parameter1 parameter = mypermission testcase = parameter + parameter1 # print testcase AC_result = Requesttype.Requesttype( methods, testcase, httpString) print AC_result eachcase = Requesttype.Requestcase(methods, testcase, httpString) runresult.append(eachcase) runresult.append(AC_result) # print runresult return runresult Execution.Executionmode( runresult, casepath, resultname, ) except Exception, e: print e
import dataCheck.CreateDict as createDict # [[ # '000636dc-b968-4540-a28e-5944f24d1d22', # '城中派出所', # '积分兑换#对方#积分#信用卡#电话#', # '王玲', # '女', # '34082319800317582X', # '15995617028.0', # '安徽省安庆市枞阳县', # '江苏省昆山市', # '1980年03月17日,02号,2017年6月12日,', '', '' # ]] extract_list = FileOperation.loadExtractInfo() addressDict = createDict.buildAddressDict() xbDict = createDict.buildXbDict() sfzhDict = createDict.buildSfzhDict() dhDict = createDict.buildDhDict() xmDict = createDict.buildXmDict() if __name__ == "__main__": zone = 0 Tright = 0 Terror = 0 Fright = 0 Ferror = 0 count = 0 for i in extract_list: try:
def runcase(casepath, sheetname, resultname): bk = xlrd.open_workbook(casepath) # 打开excel文件 httpString = bk.sheet_by_name('Sheet1').cell_value(0, 0) # 接口url在表1里 sh = bk.sheet_by_name(sheetname) # 测试数据在表2里 mrows = sh.nrows mcols = sh.ncols runFirstresult = [] a = FileOperation.FileExsit(os.getcwd() + r'/log/failresult.html') if a == True: FileOperation.DelFile(os.getcwd() + r'/log/failresult.html') try: #拼接参数名与参数值 for j in range(1, mrows): methods = sh.cell_value(j, 2) testcase = [] for i in range(3, mcols): x = sh.cell_value(0, i) # 参数名,获取单元格的数据类型 y = sh.cell_value(j, i) # 参数值 xtype = sh.cell(0, i).ctype ytype = sh.cell(j, i).ctype ###################ctype : 0 empty,1 string, 2 number, 3 date, 4 boolean, 5 error if (xtype == 2): x = str(int(x)) if (ytype == 2) or (ytype == 4): y = str(int(y)) y = str(y) if x.find(' ') != -1 or y.find(' ') != -1: x = x.replace(' ', '+') y = y.replace(' ', '+') if ytype == 4 and y == '1': y = 'True' elif ytype == 4 and y == '0': y = 'False' if methods == 'GET': element2 = x + '=' + y else: element2 = '"' + x + '":"' + y + '"' testcase.append(element2) # print testcase AC_result = Requesttype.Requesttype(methods, testcase, httpString) eachcase = Requesttype.Requestcase(methods, testcase, httpString) # print AC_result runFirstresult.append(eachcase) runFirstresult.append(AC_result) # print runFirstresult if resultname in bk.sheet_names(): ch = bk.sheet_by_name(resultname) nrows = ch.nrows ncols = ch.ncols resultlist = runFirstresult[1::2] # print resultlist for m in range(1, nrows): AC_result = resultlist[m - 1] EX_result = ch.cell_value(m, ncols - 1) finalresult = ACEXcompare.acex(AC_result, EX_result) if finalresult == False: writeLog.errorlog( 'FAIL:wrong datas case is number:case%s' % m, eachcase) else: return runFirstresult writeExcelresult.writeResult(runFirstnullresult, resultpath, defaultname) except Exception, e: print e
# coding: utf-8 import FileOperation as fo # 源数据校验方法 # 查看content中是否包含所有完全匹配字段 # 所有能够抽取到的字段都应该在对话中含有 # 关于地址方面 词袋模型 词频相似度算法 ?? # 源数据集最好使用dict # content_list = [] dict = fo.loadDict() print(len(dict)) # 加载抽取信息方法,获得所有抽取到的信息 content_list = fo.loadContentList() print(len(content_list)) print(content_list[1]) # 通过 extarct_list 来作为循环体,字典校验 address = 0 addressBlank = 0 addressNoin = 0 xm = 0 xmBlank = 0 xmNoin = 0 xb = 0 xbBlank = 0 xbNoin = 0 dh = 0
Usage() sys.exit(1) elif o in ('-v', '--version'): Version() sys.exit(0) elif o in ('-a', '--application'): f = MYFTP(FTP_HOST, FTP_USERNAME, FTP_PASSWD, rootdir_remote, FTP_PORT) f.login() for list in listAllDevices(a.split(':')[0]): print "/var/ftp/pub/%s/%s/cpumeminfo.log" % (a.split(':')[0], list) f.download_file( "./cpumeminfo.log", "/var/ftp/pub/%s/%s/cpumeminfo.log" % (a.split(':')[0], list)) result = CPUAndMemory('cpumeminfo.log', 'package.log', a.split(':')[1], a.split(':')[0], list) result.getCpuAndMemory() deleteFile = FileOperation() deleteFile.deleteFile('cpumeminfo.log') deleteFile.deleteFile('package.log') sys.exit(0) else: print 'unhandled option' sys.exit(3) if __name__ == '__main__': main(sys.argv)
from Sinonim import get_sinonim from PreProcessing import * import StringMatching import FileOperation import itertools import sys #Baca file faq Q, A = FileOperation.read_faq('pertanyaan.txt') #Pre-processing tiap pertanyaan proc_Q = [remove_nwhitespace(remove_stopwords(remove_noise(to_lowercase(question)))) for question in Q] #Pemanggilan query query = sys.argv[1] confidence = {} candidate_ques_ans = [] hasil = [] #Pre-processing query if len(query) > 0: proc_query = remove_nwhitespace(remove_stopwords(remove_noise(to_lowercase(query)))) #Exact matching query dengan proc_Q dengan bm if len(proc_query) > 0: #Simpan seluruh sinonim dari tiap kata di query dan kata di query tsb query_words = get_words(proc_query) synonyms_word = [get_sinonim(word) for word in query_words] for i in range(len(query_words)): synonyms_word[i] += [query_words[i]]
def readNewsRdcongo(country_name, formated_time_run): # Initializing a set of placeholders variables list_of_sites = [] filename = country_name + ".txt" urls_filename = formated_time_run + "-urls" + ".yml" content_filename = formated_time_run + "-content" + ".yml" with open(filename, 'rb') as fp: itemlist = [line.rstrip(u'\n') for line in fp] for item in itemlist: list_of_sites.append(item) print list_of_sites # Site by site # First site: radiookapi.net # radiookapi = str(list_of_sites[0]) actualite = str(list_of_sites[1]) politico = str(list_of_sites[2]) rfi = str(list_of_sites[3]) jeuneafrique = str(list_of_sites[4]) benilubero = str(list_of_sites[5]) # # # We connect to grab the html and date_accessed of every site listed above try: radiookapi_html, radiookapi_date_accessed = gl.getHtml(radiookapi) except: print "there was a problem to connect to the site: %s" % radiookapi pass try: actualite_html, actualite_date_accessed = gl.getHtml2(actualite) except: print "there was a problem to connect to the site: %s" % actualite pass try: politico_html, politico_date_accessed = gl.getHtml(politico) except: print "there was a problem to connect to the site: %s" % politico pass try: rfi_html, rfi_date_accessed = gl.getHtml(rfi) except: print "there was a problem to connect to the site: %s" % rfi pass try: jeuneafrique_html, jeuneafrique_date_accessed = gl.getHtml( jeuneafrique) except: print "there was a problem to connect to the site: %s" % jeuneafrique pass try: benilubero_html, benilubero_date_accessed = gl.getHtml(benilubero) except: print "there was a problem to connect to the site: %s" % benilubero pass # Getting list of urls of the site radiookapi.net radiookapi_date_published = gl.getDatetimeSlash() # Getting links # if html content is not grabbed for some reason, the script ends. So the statement getting links from html should be placed in a try statement in order to handle the exception try: radiookapi_links = gl.okapiLinks(radiookapi_html, radiookapi_date_published, radiookapi) except: pass print radiookapi_links # For Politico.cd politico_date_published = gl.getDatetimeSlash() try: politico_links = gl.politicoLinks(politico_html, politico_date_published, politico) except: pass print politico_links # For Actualite.cd actualite_date_published = gl.getDatetimeSlash() try: actualite_links = gl.actualiteLinks(actualite_html, actualite_date_published, actualite) except: pass print actualite_links # For benilubero.com benilubero_date_published = gl.getDatetimeSlash() try: benilubero_links = gl.beniluberoLinks(benilubero_html, benilubero) except: pass print benilubero_links # For jeuneafrique.com jeuneafrique_date_published = gl.getDatetimeSlash() try: jeuneafrique_links = gl.jeuneafriqueLinks(jeuneafrique_html, jeuneafrique) except: pass print jeuneafrique_links # Put links in a single array current_links = {} current_links["radiookapi"] = radiookapi_links current_links["politico"] = politico_links current_links["actualite"] = actualite_links current_links["benilubero"] = benilubero_links current_links["jeuneafrique"] = jeuneafrique_links #all_links = radiookapi_links + politico_links + actualite_links + benilubero_links + jeuneafrique_links # print all_links # print len(all_links) # print type(links) # now iterate over the array and just first get # items = fo.read_yaml(urls_filename) # print items # print type(items) # load only new urls # reload last urls and compare with current ones last_file_list = fo.loadFileToList("urlsfilesnames.txt") last_file = last_file_list[-1] last_links = fo.read_yaml(last_file) # compute new links links that are different from previous ones new_links = {} new_links["radiookapi"] = gl.getNewLinks(current_links["radiookapi"], last_links["radiookapi"]) new_links["politico"] = gl.getNewLinks(current_links["politico"], last_links["politico"]) new_links["actualite"] = gl.getNewLinks(current_links["actualite"], last_links["actualite"]) new_links["benilubero"] = gl.getNewLinks(current_links["benilubero"], last_links["benilubero"]) new_links["jeuneafrique"] = gl.getNewLinks(current_links["jeuneafrique"], last_links["jeuneafrique"]) fo.write_yaml(urls_filename, new_links) fo.stringToFile("urlsfilesnames.txt", urls_filename) print current_links print new_links # Now retrieving content from urls # Customised methods for radiookapi and other tagetted sites articles = {} for link in new_links["radiookapi"]: try: identifier = hashlib.sha224(link).hexdigest() article = gc.radiookapi_process_link(link, formated_time_run) articles[identifier] = article except: pass # for others, those for which we have not yet developped customised methods other_links = new_links["politico"] + new_links["actualite"] + new_links[ "benilubero"] + new_links["jeuneafrique"] for link in other_links: try: identifier = hashlib.sha224(link).hexdigest() article = gc.generic_process_link(link, formated_time_run) articles[identifier] = article except: pass # We proceed with handling the dictionnary and writing it to the yaml file fo.write_yaml(content_filename, articles) print "we have created the content file %s" % content_filename print "The file has %i articles " % len(articles) list_articles = ym.dicToList(articles) year, month, day, hour, minute = gl.getDateElements(formated_time_run) ym.insertMultiple(list_articles, year, month, day, hour, minute) print "the collection of articles has been saved to the MongoDB"
def main(): theme = sys.argv[1] time_run = datetime.datetime.now() formated_time_run = fo.datetimeToString(time_run) if theme == "rdc": readNewsRdcongo(theme, formated_time_run)
def runcase(casepath): bk = xlrd.open_workbook(casepath) # 打开excel文件 httpString = bk.sheet_by_name('Sheet1').cell_value(0, 0) #接口url在表1里 sh = bk.sheet_by_name('Sheet2') #测试数据在表2里 nrows = sh.nrows ncols = sh.ncols FileOperation.DelFile(r'./log/failresult.html') try: #拼接参数名与参数值 for j in range(1, nrows): mylist = [] myvalue = [] for i in range(3, ncols - 1): x = sh.cell_value(j, i) #参数值 y = sh.cell_value(0, i) #参数名 if isinstance(x, float): x = str(int(x)) if isinstance(x, float): y = str(int(y)) if x == True: x = 'TRUE' if x == False: x = 'FALSE' if x.find(' ') != -1: x = x.replace(' ', '+') if y.find(' ') != -1: y = y.replace(' ', '+') #param = '"'+y+'"'+'='+'"'+x+'"'#加双引号 param = y + '=' + x #不加双引号 mylist.append(param) s = '&' params = s.join(mylist) #拼接成get型 value = '"' + y + '":"' + x + '"' myvalue.append(value) values = ','.join(myvalue) #拼接成post型 #print params #print values num = sh.cell_value(j, 0) num = str(int(num)) name = sh.cell_value(j, 1) name = str(name) EX_result = sh.cell_value(j, ncols - 1) expectresult = json.loads(EX_result) Edatas = expectresult["datas"] Edesc = expectresult["desc"] Eflag = expectresult["flag"] methods = sh.cell_value(j, 2) if methods == 'GET': AC_result = httpRequests.httpRequests(httpString, params, methods) else: AC_result = httpRequests.httpRequests(httpString, values, methods) actualresult = json.loads(AC_result) #改为json格式 datas = actualresult["datas"] #取key对应的value flag = actualresult["flag"] desc = actualresult["desc"] url = httpRequests.URLreturn(httpString, params) #print url finalresult = checkPoint.check_result(datas, Edatas, desc, Edesc, flag, Eflag, name) if finalresult == False: writeLog.errorlog( 'FAIL:wrong datas case is number:' + num + ':' + name, url) except Exception, e: print e
def createcase(casepath, defaultname, resultname, Speparamlist): bk = xlrd.open_workbook(casepath, formatting_info=True) # 打开excel文件 httpString = bk.sheet_by_name('Sheet1').cell_value(0, 0) # 接口url在表1里 sh = bk.sheet_by_name(defaultname) runFirstnullresult = [] methods = sh.cell_value(1, 1) a = FileOperation.FileExsit(os.getcwd() + r'/log/failresult.html') if a == True: FileOperation.DelFile(os.getcwd() + r'/log/failresult.html') try: list1 = getvalue.getdvalue(casepath, defaultname, methods) if methods == 'GET': mypermission = permission1 else: mypermission = permission2 for i in range(len(list1) - 1, len(list1)): ###大于等于列表长度-1参数 nulllist = [] iter = itertools.combinations(list1, i) ###i表示取列表中的n个参数进行组合 nulllist.append(list(iter)) ######iter是一个循环器,所以它的值只能用1次,需要把值存到变量里 # print nulllist for j in range(0, len(nulllist[0])): ####生成列表个数 parameter1 = mypermission parameter2 = list(nulllist[0][j]) testcase = parameter1 + parameter2 # print testcase AC_result = Requesttype.Requesttype(methods, testcase, httpString) eachcase = Requesttype.Requestcase(methods, testcase, httpString) # print eachcase # print EX_result runFirstnullresult.append(eachcase) runFirstnullresult.append(AC_result) for i in range(0, len(list1)): for y in Speparamlist: parameter1 = getvalue.getdvalue(casepath, defaultname, methods) x = sh.cell_value(i + 4, 0) if methods == 'GET': element2 = x + '=' + y else: element2 = '"' + x + '":"' + y + '"' parameter1.pop(i) # print list1 parameter1.append(element2) # print parameter1 parameter = mypermission testcase = parameter + parameter1 AC_result = Requesttype.Requesttype(methods, testcase, httpString) eachcase = Requesttype.Requestcase(methods, testcase, httpString) runFirstnullresult.append(eachcase) runFirstnullresult.append(AC_result) # print runFirstnullresult if resultname in bk.sheet_names(): ch = bk.sheet_by_name(resultname) nrows = ch.nrows ncols = ch.ncols resultlist = runFirstnullresult[1::2] # print resultlist for m in range(1, nrows): AC_result = resultlist[m - 1] EX_result = ch.cell_value(m, ncols - 1) finalresult = ACEXcompare.acex(AC_result, EX_result) if finalresult == False: writeLog.errorlog( 'FAIL:wrong datas case is number:case%s' % m, eachcase) else: return runFirstnullresult writeExcelresult.writeResult(runFirstnullresult, resultpath, defaultname) except Exception, e: print e