Пример #1
0
def plan_run(request):
    if request.method == 'POST':
        plan_id = request.POST['plan_id']
        plan = Plan.objects.get(plan_id=plan_id)
        env_id = plan.environment.env_id
        case_id_list = eval(plan.content)
        case_num = len(case_id_list)
        content = []
        pass_num = 0
        fail_num = 0
        error_num = 0
        for case_id in case_id_list:
            execute = Execute(case_id, env_id)
            case_result = execute.run_case()
            content.append(case_result)
            if case_result["result"] == "pass":
                pass_num += 1
            if case_result["result"] == "fail":
                fail_num += 1
            if case_result["result"] == "error":
                error_num += 1
        report_name = plan.plan_name + "-" + time.strftime("%Y%m%d%H%M%S")
        if Report.objects.filter(plan=plan):
            Report.objects.filter(plan=plan).update(report_name=report_name, content=content, case_num=case_num,
                                                    pass_num=pass_num, fail_num=fail_num, error_num=error_num)
        else:
            report = Report(plan=plan, report_name=report_name, content=content, case_num=case_num,
                            pass_num=pass_num, fail_num=fail_num, error_num=error_num)
            report.save()
        return HttpResponse(plan.plan_name + " 执行成功!")
Пример #2
0
def case_run(request):
    if request.method == 'POST':
        case_id = request.POST['case_id']
        env_id = request.POST['env_id']
        execute = Execute(case_id, env_id)
        case_result = execute.run_case()
        return JsonResponse(case_result)
Пример #3
0
 def post(self, requests):
     #运行用例调试类视图
     case_id = requests.POST.get("case_id")  #用例ID
     env_id = requests.POST.get("env_id")  #环境
     execute = Execute(case_id, env_id)  #实例化执行类得到execute()对象
     execute_result = execute.run_case()  #执行后的结果
     #调试结果返回至前端回调函数
     return JsonResponse(execute_result)
Пример #4
0
 def post(self, requests):
     plan_id = requests.POST.get("plan_id")
     plan = Plan.objects.get(plant_id=plan_id)
     env = plan.env.env_id  #计划对象对应的环境
     content = eval(plan.content)  #计划对应的content
     case_num = len(content)  #测试用例数
     pass_num = 0  #用例通过数
     fail_num = 0  # 用例失败数
     error_num = 0  # 用例错误数
     case_list = []  #测试计划中测试用例集
     for case_obj in content:
         execute_obj = Execute(case_obj, env)
         run_result = execute_obj.run_case()
         case_list.append(run_result)
         if run_result["result"] == "pass":
             pass_num += 1
         elif run_result["result"] == "fail":
             fail_num += 1
         else:
             error_num += 1
     report_name = plan.plant_name + "-" + time.strftime("%Y%m%d%H%M%S")
     if Report.objects.filter(plant=plan):
         Report.objects.filter(plant=plan).update(report_name=report_name,
                                                  plant=plan,
                                                  content=case_list,
                                                  case_num=case_num,
                                                  pass_num=pass_num,
                                                  fail_num=fail_num,
                                                  error_num=error_num,
                                                  task=None)
     else:
         Report(report_name=report_name,
                plant=plan,
                content=case_list,
                case_num=case_num,
                pass_num=pass_num,
                fail_num=fail_num,
                error_num=error_num,
                task=None).save()
     return HttpResponse(plan.plant_name + "执行成功!")
Пример #5
0
    with open(args.config) as rptr:
        config = EasyDict(yaml.load(rptr))
    config = parser_config(config)

    torch.manual_seed(config.SEED)
    torch.cuda.manual_seed(config.SEED)
    np.random.seed(config.SEED)
    random.seed(config.SEED)

    rhf = RandomHorizontalFlip(p=0.5)
    rc_ = RandomCrop(ratio=0.75)
    cj_ = ColorJitter(brightness=0.4, saturation=0.4, hue=0.4)
    rb_ = RandomBlur(p=0.5, r=(2, 3))
    rsf = RandomShift(p=0.5, ratio=0.15)
    rs_ = Resize(size=(448, 448))
    tt_ = ToTensor()
    gco = ToGridCellOffset((448, 448), (7, 7))
    img_trans = Compose([rhf, rc_, cj_, rb_, rsf, rs_, tt_])
    box_trans = Compose([rhf, rc_, rsf, rs_, gco])

    dataloader = MakeDataLoader(dataset=VOCDataset(config,
                                                   phase='train',
                                                   img_transform=img_trans,
                                                   box_transform=box_trans),
                                batch_size=config.TRAIN.BATCH_SIZE,
                                shuffle=True)

    exe = Execute(config=config, dataloader=dataloader)

    exe.train()
Пример #6
0
def test_Execute():
    exe = Execute(config)
Пример #7
0
parser = argparse.ArgumentParser(description='test object-detection of single stage.')
parser.add_argument('--config', type=str, default='cfgs/yolo.yaml',
                    help='configuration file')
args = parser.parse_args()


if __name__ == '__main__':
    with open(args.config) as rptr:
        config = EasyDict(yaml.load(rptr))
    config = parser_config(config)

    torch.manual_seed(config.SEED)
    torch.cuda.manual_seed(config.SEED)
    np.random.seed(config.SEED)
    random.seed(config.SEED)

    rs_ = Resize(size=(448, 448))
    tt_ = ToTensor()
    img_trans = Compose([rs_, tt_])

    dataloader = MakeDataLoader(
        dataset=VOCDataset(config, phase='test',
                           img_transform=img_trans),
        batch_size=config.TEST.BATCH_SIZE,
        shuffle=False)

    exe = Execute(config=config, dataloader=dataloader, phase='test')

    exe.test()