Exemplo n.º 1
0
    def summary_hz(self,threshold, Test_Version, Test_Batch, Time_Stamp):  # 读写汇总页数据,输出汇总语数据
        now = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(Time_Stamp))
        data = json.loads(CulturalAPI().get_results_summary_data(Test_Version, Test_Batch))

        datalist = data['datalist']
        logger.info(datalist)

        SumNumbers = []
        SumPass = []
        SumFail = []
        Standard = []
        UnStandard = []
        for i in datalist:
            SumNumbers.append(i['Test_Number'])
            SumPass.append(i['PASS'])
            SumFail.append(i['FAIL'])
            if i['Accuracy'] >= threshold:
                Standard.append(i['Accuracy'])
            else:
                UnStandard.append(i['Accuracy'])
        dic_hz = {
            'Test_Batch': Test_Batch,
            'Test_Version': Test_Version,
            'Test_Time': now,
            'Time_Stamp': Time_Stamp,
            'Total_Type': len(SumNumbers),
            'Sum_Numbers': sum(SumNumbers),
            'Sum_Pass': sum(SumPass),
            'Sum_Fail': sum(SumFail),
            'Standard': len(Standard),
            'UnStandard': len(UnStandard),
            'threshold': threshold,
            'StandardRate': len(Standard) / len(SumNumbers),
        }
        InsertDB().insert_summary('summary', dic_hz)
Exemplo n.º 2
0
 def download(self,filename, Test_Version, Test_Batch):  # 下载数据到表格
     addr=os.getcwd() + '\\excle\\'+filename
     logger.info('开始获取导出数据……')
     data = (CulturalAPI().get_summary_data(Test_Version, Test_Batch))
     data1 = (CulturalAPI().get_results_summary_data(Test_Version, Test_Batch))
     sql = "select * from  %s WHERE test_version='%s' AND test_batch='%s' ;" % (
     'test_record_sheet', Test_Version, Test_Batch)
     logger.info(data)
     logger.info(data1)
     summary = json.loads(data)['datalist'][0]
     results_summary = json.loads(data1)['datalist']
     record_sheet = Query_DB().query_db_all(sql)
     logger.info('开始导出数据到Excle!')
     ExportExcle(addr, record_sheet)
     SummaryExcle(addr, results_summary)
     VerticalExcle(addr, summary)
     logger.info('导出Excle完成!')
Exemplo n.º 3
0
def Linechart():  #获取折线图基础数据
    params = flask.request.json  # 当客户端没有传json类型或者没传时候,直接get就会报错。
    # params = flask.request.json #入参是字典时候用这个。
    if params:
        dic = {
            'test_version': params.get('test_version'),
            'test_batch': params.get('test_batch')
        }
        data = CulturalAPI().Linechart(dic['test_version'], dic['test_batch'])
        logger.info("'/Linechart',methods=['post']:%s;%s" %
                    (str(dic), str(data)))
        return data
    else:
        data = json.dumps({"result_code": 3002, "msg": "入参必须为json类型。"})
        logger.info("'/Linechart',methods=['post']:" + str(data))
        return data
Exemplo n.º 4
0
def GetOnesheet():  # 获取某一个文物
    params = flask.request.json  # 当客户端没有传json类型或者没传时候,直接get就会报错。
    # params = flask.request.json #入参是字典时候用这个。
    if params:
        dic = {
            'test_version': params.get('test_version'),
            'test_batch': params.get('test_batch'),
            'Code': params.get('Code')
        }
        data = CulturalAPI().get_one_sheet_data(dic)
        logger.info("'/GetOnesheet',methods=['post']:%s;%s" %
                    (str(dic), str(data)))
        return data
    else:
        data = json.dumps({"result_code": 3002, "msg": "入参必须为json类型。"})
        logger.info("'/GetOnesheet',methods=['post']:" + str(data))
        return data
Exemplo n.º 5
0
def del_summary_data():  #删除一行数据
    params = flask.request.json  # 当客户端没有传json类型或者没传时候,直接get就会报错。
    # params = flask.request.json #入参是字典时候用这个。
    if params:
        dic = {
            "dic_data": params.get("dic_data"),
        }
        logger.info("'/del_summary_data',methods=['post']:%s;" %
                    (str(dic["dic_data"])))
        #data = CulturalAPI().del_summary_data(dic["table_name"],dic['Test_Version'],dic['Test_Batch'])
        data = CulturalAPI().del_summary_data(dic["dic_data"])
        logger.info("'/del_summary_data',methods=['post']:%s" %
                    (str(dic["dic_data"])))
        return data
    else:
        data = json.dumps({"result_code": 3002, "msg": "入参必须为json类型。"})
        logger.info("'/del_summary_data',methods=['post']:" + str(data))
        return data
Exemplo n.º 6
0
def Addtestinfo():
    params = flask.request.json  # 当客户端没有传json类型或者没传时候,直接get就会报错。
    # params = flask.request.json #入参是字典时候用这个。
    if params:
        dic = {
            "version": params.get("version"),
            "Test_Time": params.get("Test_Time"),
            "developer": params.get("developer"),
            "deletes": 0
        }
        data = CulturalAPI().Addtestinfo(dic)
        logger.info("'/Addtestinfo',methods=['post']:%s;%s" %
                    (str(dic), str(data)))
        return data
    else:
        data = json.dumps({"result_code": 3002, "msg": "入参必须为json类型。"})
        logger.info("'/Addtestinfo',methods=['post']:" + str(data))
        return data
Exemplo n.º 7
0
def login_ajax_check():
    params = flask.request.json  # 当客户端没有传json类型或者没传时候,直接get就会报错。
    # params = flask.request.json #入参是字典时候用这个。
    if params:
        dic = {
            "username": params.get("username"),
            "password": params.get("password"),
        }
        #dic_data = {"username": username, 'password': password}
        logger.info(dic)
        logger.info("'/login_ajax_check',methods=['post']:%s;" % (str(dic)))
        #data = CulturalAPI().del_summary_data(dic["table_name"],dic['Test_Version'],dic['Test_Batch'])
        data = CulturalAPI().login_ajax_check(dic)
        logger.info("'/login_ajax_check',methods=['post']:%s" % (str(dic)))
        return data
    else:
        data = json.dumps({"result_code": 3002, "msg": "入参必须为json类型。"})
        logger.info("'/login_ajax_check',methods=['post']:" + str(data))
        return data
Exemplo n.º 8
0
def DownloadExcle():  #下载excel

    params = flask.request.json  # 当客户端没有传json类型或者没传时候,直接get就会报错。
    # params = flask.request.json #入参是字典时候用这个。
    if params:
        dic = {
            "filename": params.get("filename"),
            "Test_Version": params.get("Test_Version"),
            "Test_Batch": params.get("Test_Batch"),
        }

        logger.info("'/DownloadExcle',methods=['post']:%s;" % (str(dic)))
        data = CulturalAPI().download_excle(dic)
        logger.info("'/DownloadExcle',methods=['post']:%s" % (str(data)))
        return data
    else:
        data = json.dumps({"result_code": 3002, "msg": "入参必须为json类型。"})
        logger.info("'/DownloadExcle',methods=['post']:" + str(data))
        return data
Exemplo n.º 9
0
def getform():  #获取列表数据
    # table_name = 'summary'
    # data = CulturalAPI().getform(table_name)
    # logger.info("'/GetSummary',methods=['post']:%s" % (str(data)))
    # return data

    params = flask.request.json  # 当客户端没有传json类型或者没传时候,直接get就会报错。
    # params = flask.request.json #入参是字典时候用这个。
    if params:
        dic = {
            "table_name": params.get("table_name"),
            'Latest_name': params.get("Latest_name")
            # "Test_Version": params.get("Test_Version"),
            # "Test_Batch": params.get("Test_Batch"),
        }
        # Latest_name 指导字段最新排序
        logger.info("'/getform',methods=['post']:%s;" % (str(dic)))
        data = CulturalAPI().getform(dic)
        logger.info("'/getform',methods=['post']:%s" % (str(data)))
        return data
    else:
        data = json.dumps({"result_code": 3002, "msg": "入参必须为json类型。"})
        logger.info("'/DownloadExcle',methods=['post']:" + str(data))
        return data
Exemplo n.º 10
0
def SampleBatch():
    params = flask.request.json  # 当客户端没有传json类型或者没传时候,直接get就会报错。
    # params = flask.request.json #入参是字典时候用这个。

    if params:
        try:
            batch_path = params.get("batch_path")
            imageinfo = Getimage(batch_path)
            types_num = len(list(set(imageinfo[1])))
            total_num = len(imageinfo[0])

            dic = {
                "batch": params.get("batch"),
                "types_num": types_num,
                "total_num": total_num,
                "Test_Time": params.get("Test_Time"),
                "delete": 0,
                "batch_path": batch_path.replace('\\', '/'),
            }

            data = CulturalAPI().SampleBatch(dic)
            logger.info("'/SampleBatch',methods=['post']:入参: %s;出参:%s" %
                        (str(dic), str(data)))
            return data
        except Exception as e:
            data = json.dumps({
                "result_code": 4000,
                "message": "样本路径不准确,请重新输入(%s)。" % e
            })
        logger.error("'/SampleBatch',methods=['post']:" +
                     str(json.loads(data)))
        return data
    else:
        data = json.dumps({"result_code": 3002, "message": "入参必须为json类型。"})
        logger.info("'/SampleBatch',methods=['post']:" + str(data))
        return data
Exemplo n.º 11
0
def GetStart():  #获取测试批次和版本列表
    data = CulturalAPI().get_start_recording()
    logger.info("'/GetStart',methods=['post']:%s" % (str(data)))
    return data
Exemplo n.º 12
0
# -*- coding: utf-8 -*-
# !/usr/bin/python3

from framework.Sendmail import SendEmail
from framework.Shutdown import Shutdown
from framework.TestValue import *
from framework.CulturalAPI import CulturalAPI
from framework.Statistics import Statistics
from framework.logger import Logger

logger = Logger(logger="run").getlog()

data = json.loads(CulturalAPI().get_start_recording())

Test_Batch = '20200713_1'  # 测试批次
Test_Version = 'v1.0_201812181345'

pathimage = data['dicdata'][Test_Batch][
    'batch_path']  #pathimage =r'E:\小雁塔\test'
Batchinfo = data['dicdata'][Test_Batch]  #样本信息
threshold = 0.95  # 汇总页达标率阈值
filename = '%s_%s.xlsx' % (Test_Batch, Test_Version)
proce = 1  # 测试进程数

if __name__ == '__main__':
    TestValue2(pathimage, proce, Test_Batch, Test_Version,
               Batchinfo)  #数据测试写入表格
    Statistics().Statistics(threshold, Test_Version, Test_Batch)  # 汇总测试数据到数据库
    Statistics().download(filename, Test_Version,
                          Test_Batch)  #下载测试数据及汇总结果数据到Excel
    #get_failimage(Test_Version, Test_Batch)#获取失败图片
Exemplo n.º 13
0
import subprocess
import os, json

from framework.CulturalAPI import CulturalAPI
#
# cmd='"D:\Program Files (x86)\python3\python3.exe" E:\小雁塔\program+pycaffe20190701\文物测试\Cultural_db/run.py'
#
# subprocess.Popen(cmd, shell=True)
dic = {'table_name': 'summary', 'Latest_name': 'Test_Time'}
data = (CulturalAPI().getform(dic))
print(json.loads(data))
# /
# # download(filename, Test_Version, Test_Batch)