def statistics(): all = Record.select() passed = Record.select().where(Record.passed == True).count() failed = Record.select().where(Record.passed == False).count() nightwatch_passed = Record.select().where( Record.nightwatch_result == "0").count() r = [] for a in all: r.append({ "nightwatch_result": a.nightwatch_result, "uuid": str(a.id), "logfile": a.logfile, "expectfile": a.expectfile, "passed": a.passed, "casename": a.casename }) return render_template('index.html', all=r, passed=passed, failed=failed)
def open_expect_data(): uuid = request.args.get('uuid') r = Record.select().where(Record.id == uuid).first() if (not r): return "record not found" os.system( "osascript /Users/sunjun/Desktop/dotemacs/emacs_with_line.scpt " + r.logfile + ".data_expect" + " " + "1") return r.logfile + ".data_expect"
def post(self): args = parser.parse_args() print(args) print(request.get_data()) if args["passed"] == "true": arg_passed = True else: arg_passed = False action = Record.create(id=str(uuid.uuid4()), expectfile=args["expectfile"], logfile=args["logfile"], passed=arg_passed, casename=args["casename"], history_cwd=args["history_cwd"], nightwatch_result=args["nightwatch_result"]) return ""
def rerun(): uuid = request.args.get('uuid') print(uuid) r = Record.select().where(Record.id == uuid).first() if (not r): return "record not found" cmd = "test " + r.logfile.rstrip("_test") + " \"" + r.casename + "\"\n" env = Environment(loader=FileSystemLoader(statistics_template_path)) template = env.get_template('case_runner.template.sh') output_from_parsed_template = template.render( cmd=cmd, history_cwd=r.history_cwd, nightwatch_result=r.nightwatch_result) print(output_from_parsed_template) with open("/tmp/my_new_file.html", "w") as fh: fh.write(output_from_parsed_template) os.system("osascript shell.scpt 'sh /tmp/my_new_file.html'") return "run again"
def log(): uuid = request.args.get('uuid') print(uuid) r = Record.select().where(Record.id == uuid).first() try: with open(r.logfile, 'r') as parse_f: logfile = parse_f.read() except FileNotFoundError: logfile = "[fault]The file " + r.logfile + " can't find." try: with open(r.expectfile, 'r') as parse_f: expectfile = parse_f.read() except FileNotFoundError: expectfile = "[fault]The file " + r.logfile + " can't find." try: with open(r.logfile + ".data", 'r') as parse_f: logdatafile = parse_f.read() except FileNotFoundError: logdatafile = "[fault]The file " + r.logfile + " can't find." try: with open(r.logfile + ".data_expect", 'r') as parse_f: logdata_expect_file = parse_f.read() except FileNotFoundError: logdata_exepect_file = "[fault]The file " + r.logfile + " can't find." return render_template('log.html', testname="result flow", expectname="expect flow", uuid=uuid, expectfile=expectfile, logfile=logfile, data=logdatafile, data_expect=logdata_exepect_file, r=r)
def clear_statistics(): deletequery = Record.delete() deletequery.execute() return "clear!"