Ejemplo n.º 1
0
def read_write_case(read_excel='D:/app/PICT/result.xls', write_excel='D:/app/PICT/result1.xls'):
    #dict_key = ['起始价格', '结束价格', '钻重起始重量', '钻重结束重量', '颜色', '净度', '切工', '抛光', '对称', '荧光', '形状', '证书']
    dict_key = ['订单状态', '开始时间', '结束时间', '会员信息']
    base_file(read_excel).check_file()
    base_file(write_excel).check_file()
    data = xlrd.open_workbook(read_excel)
    table = data.sheet_by_index(0)
    nrows = table.nrows
    ncols = table.ncols
    colnames = table.row_values(0) #one rows data
    list = []
    for rownum in range(1, nrows):
        row = table.row_values(rownum)
        if row:
            app = {}
            for i in range(len(colnames)):
                row[i] = colnames[i] + row[i]
                app[colnames[i]] = row[i]
            list.append(app)
    #写入到文件中
    print(list)
    workbook = xlsxwriter.Workbook(write_excel)
    worksheet = workbook.add_worksheet()
    for i in range(len(list)):
        worksheet.write(i, 0, "设置条件:" + "\n" + list[i][dict_key[0]] + "," + list[i][dict_key[1]] + ',' + list[i][dict_key[2]] +',' + list[i][dict_key[3]] +"\n" + "点击提交")

    workbook.close()
    return list
Ejemplo n.º 2
0
def read_xml(file='D:/web.xml'):
    base_file(file).check_file()
    doc = minidom.parse(file)
    root = doc.documentElement

    postparams = root.getElementsByTagName("postparams")
    ytitle = root.getElementsByTagName("ytitle")
    xtitle = root.getElementsByTagName("xtitle")
    title = root.getElementsByTagName("title")
    count = root.getElementsByTagName("count")
    baseurl = root.getElementsByTagName("baseurl")
    httpapi = root.getElementsByTagName("httpapi")
    method = root.getElementsByTagName("method")
    mat = root.getElementsByTagName("mat")
    xlim = root.getElementsByTagName("xlim")
    ylim = root.getElementsByTagName("ylim")

    list_xml = {}

    list_xml["ytitle"] = ytitle[0].getAttribute("value")
    list_xml["xtitle"] = xtitle[0].getAttribute("value")
    list_xml["title"] = title[0].getAttribute("value")
    list_xml["count"] = count[0].getAttribute("value")
    list_xml["baseurl"] = baseurl[0].getAttribute("value")
    list_xml["httpapi"] = httpapi[0].getAttribute("value")
    list_xml["method"] = method[0].getAttribute("value")
    list_xml["mat"] = mat[0].getAttribute("value")
    list_xml["xlim"] = xlim[0].getAttribute("value")
    list_xml["ylim"] = ylim[0].getAttribute("value")
    list_xml["postparams"] = postparams[0].getAttribute("value")
    return list_xml
Ejemplo n.º 3
0
def read_xml(file="D:/web.xml"):
    base_file(file).check_file()
    doc = minidom.parse(file)
    root = doc.documentElement

    postparams = root.getElementsByTagName("postparams")
    ytitle = root.getElementsByTagName("ytitle")
    xtitle = root.getElementsByTagName("xtitle")
    title = root.getElementsByTagName("title")
    count = root.getElementsByTagName("count")
    baseurl = root.getElementsByTagName("baseurl")
    httpapi = root.getElementsByTagName("httpapi")
    method = root.getElementsByTagName("method")
    mat = root.getElementsByTagName("mat")
    xlim = root.getElementsByTagName("xlim")
    ylim = root.getElementsByTagName("ylim")

    list_xml = {}

    list_xml["ytitle"] = ytitle[0].getAttribute("value")
    list_xml["xtitle"] = xtitle[0].getAttribute("value")
    list_xml["title"] = title[0].getAttribute("value")
    list_xml["count"] = count[0].getAttribute("value")
    list_xml["baseurl"] = baseurl[0].getAttribute("value")
    list_xml["httpapi"] = httpapi[0].getAttribute("value")
    list_xml["method"] = method[0].getAttribute("value")
    list_xml["mat"] = mat[0].getAttribute("value")
    list_xml["xlim"] = xlim[0].getAttribute("value")
    list_xml["ylim"] = ylim[0].getAttribute("value")
    list_xml["postparams"] = postparams[0].getAttribute("value")
    return list_xml
Ejemplo n.º 4
0
def write_excel(file='d:/result.xlsx', httpurl="", httpmethod="", response_time=[]):
    base_file(file).mkdir_file()
    workbook = xlsxwriter.Workbook(file)
    worksheet = workbook.add_worksheet()
    #worksheet.set_column('A:A', 20)
    worksheet.write(0, 0, "接口URL")
    worksheet.write(0, 1, "请求方法")
    worksheet.write(0, 2, "响应时间")
    for i in range(len(response_time)):
        worksheet.write(i + 1, 0, httpurl[i])
        worksheet.write(i + 1, 1, httpmethod)
        if response_time[i] == 0:
            worksheet.write(i + 1, 2, "请求超时")
        else:
             worksheet.write(i + 1, 2, response_time[i])
    #worksheet.insert_image('B5', 'logo.png')
    workbook.close()
Ejemplo n.º 5
0
def read_excel(file='c:/test.xls'):
    base_file(file).check_file()
    data = xlrd.open_workbook(file)
    table = data.sheet_by_index(0)
    nrows = table.nrows
    ncols = table.ncols
    colnames = table.row_values(0) #one rows data
    list = []
    for rownum in range(1, nrows):
        row = table.row_values(rownum)
        if row:
            app = {}
            for i in range(len(colnames)):
                row[i] = colnames[i] + row[i]
                app[colnames[i]] = row[i]
            list.append(app)
    return list
Ejemplo n.º 6
0
def read_xml(file='D:/web.xml'):
    base_file(file).check_file()
    doc = minidom.parse(file)
    root = doc.documentElement
    postparams = root.getElementsByTagName("postparams")
    count = root.getElementsByTagName("count")
    baseurl = root.getElementsByTagName("baseurl")
    httpapi = root.getElementsByTagName("httpapi")
    method = root.getElementsByTagName("method")
    port = root.getElementsByTagName("port")
    list_xml = {}

    list_xml["count"] = count[0].getAttribute("value")
    list_xml["baseurl"] = baseurl[0].getAttribute("value")
    list_xml["httpapi"] = httpapi[0].getAttribute("value")
    list_xml["method"] = method[0].getAttribute("value")
    list_xml["postparams"] = postparams[0].getAttribute("value")
    list_xml['port'] = port[0].getAttribute("value")
    return list_xml