def genReport2(date): DB = DBfunction.getDB() ListU = DBfunction.getUserlist(DB) for i in range(0, len(ListU)): User = ListU[i] ListS = DBfunction.getUserStock(DB, User) ListM = DBfunction.getUserMethod(DB, User) page = Page() l1 = Reporter.plotKline('sh') l3 = Reporter.plotKline('hs300') page.add_chart(l1, name='the 200 day Kline of SH ') page.add_chart(l3, name='the 200 day Kline of HS300') for i in range(0, len(ListS)): Symbol = ListS[i] l1 = Reporter.plotKline(Symbol) page.add_chart(l1, name='the 200 day Kline of ' + Symbol) for j in range(0, len(ListM)): stg = ListM[j] exec('l = Reporter.plot2{}(Symbol)'.format(stg)) exec('page.add_chart(l)') page.render('./report/' + User + '.html') page.render('./hist/' + User + ' ' + date + '.html')
def list_data(): # 建立或取得資料庫 db = Leveldbutil.init("nbaDB") # 即時賽事資料來源 url = "http://sports.ltn.com.tw/nba" # 取得即時賽事資料 report = Reporter.reporter(Reporter.get_nba_report(url)) # print(sys.path) if report: print('Report not null') # 以下單純以當前時間作為key(記錄到秒) 收集每一次取到的即時賽事結果 time_form = "%Y-%m-%d %H:%M:%S" today = datetime.today().strftime(time_form) # 寫入DB(key:時分秒 value:即時賽事資料) Leveldbutil.insert(db, today, report) report_dict = {"time":today, "report": report} # 查看DB所有資料 # Leveldbutil.dump(db) return render_template("index.html", report_data=report_dict)
def reinstall(self): self.uninstall() Reporter.print_to_log_file('Deleting unwanted project files') self.cleanupFiles() self.install()
def styleAttributesLint(text, start, end): oAttrs = styleAttributesParse(text, start, end) for k, v in oAttrs.items(): if (v.find(":") != -1): lineNum = Reporter.getLineNum(text, start) Reporter.warning(lineNum, "colon found in a value", "maybe a missing semi-colon?", '"{}":"{}"'.format(k, v))
def print_report(self): self.clear_console() len_checked = True while len_checked: dialog = SecondWindow(self) dialog.exec_() if dialog.selection_parameter > 0: self.msg_date_filter = self.report_date_filter( dialog.labeled_slider.sl.value()) if len(self.topsis_copy_df) != 0: len_checked = False self.topsis_df = self.topsis_copy_df else: for i in range(dialog.labeled_slider.sl.value() + 1, 4): self.recommend_filter = self.report_date_filter(i) if len(self.topsis_copy_df) != 0: self.msg_date_filter_list.append( self.recommend_filter) self.get_info_message_text_by_code(16) else: self.get_info_message_text_by_code(6) return directory = str(QFileDialog.getExistingDirectory(self, "Save Reports")) if directory == '': self.get_info_message_text_by_code(6) return messagebox = TimerMessageBox(5, 3, self) messagebox.exec_() reporter = Reporter(appctext, directory, self.cluster_df, self.msg_date_filter, self.initial_date) reporter.topsis_analyzer.transformer = self.transformer reporter.topsis_analyzer.topsis_df = self.topsis_df reporter.topsis_analyzer.city_distance_df = self.city_distance_df reporter.topsis_analyzer.city_df = self.city_df self.results_df = reporter.create_report() self.get_info_message_text_by_code(12) self.display_results(overall=True) _translate = QtCore.QCoreApplication.translate self.label_8.setText( _translate( "PyTOP", "<html><head/><body><p align=\"center\"><span style=\" font-size:14pt; " "font-weight:600;\">Adjuster Overall Rankings</span></p></body></html>" )) self.Push_Btn_RUN_CLASSIFICATION_NEW_ACCIDENT.setStyleSheet( "background-color: lightgray") self.Push_Btn_RUN.setStyleSheet("background-color: lightgray") self.Push_Btn_RESET.setStyleSheet("background-color: lightgray")
def createXmlTestFile(self): os.chdir('C:\\fw\\Test\\GuiTestDriver\\TeModel') # Convert the spreadsheet comma delineated file of test cases to Xml os.system('CSV2XML Import' + self.type + '.CSV') # Apply a style sheet to the xml file to produce a more readable test case xml file command = ('%sXmlFromCsvStylesheet.bat %s') % (Constants.desktop_directory,Constants.user) p = subprocess.check_call(command, shell=True) Reporter.print_to_log_file('Created the ' + self.type + ' XML test cases file') Reporter.print_to_log_file(' ')
def list(): db = Leveldbutil.init("nbaDB") # get database object URL = "http://sports.ltn.com.tw/nba" report = Reporter.reporter(Reporter.get_nba_report(URL)) # print(sys.path) # report = None # For Batch Test if report: print('Report not null') # 以下單純以當前時間作為key(記錄到秒) 收集每一次取到的即時賽事結果 timeForm = "%Y-%m-%d %H:%M:%S" today = datetime.today().strftime(timeForm) # 寫入DB Leveldbutil.insert(db, today, report) # 從DB取得此次即時賽事資訊並匯出音檔 try: # create FileUtils object fileUtil = Utils.FileUtils() # call object method fileUtil.generate_sound(Leveldbutil.search(db, today)) except: print("No data found : {}".format( datetime.today().strftime("%Y-%m-%d %H:%M:%S"))) # 查看DB所有資料 # Leveldbutil.dump(db) else: print('Start Batch Test') # 取得Batch batch = Leveldbutil.init_batch() # 異動或新增資料 Leveldbutil.write_batch(batch, 'hello', 'world_hello') Leveldbutil.write_batch(batch, 'hello again', 'world_hello_again') # 寫入或更新 Leveldbutil.commit_batch(db, batch) # Get test data get_batch_test_data(db) # Delete test data (批次刪除) Leveldbutil.delete_batch(batch, 'hello') Leveldbutil.delete_batch(batch, 'hello again') # 執行刪除 Leveldbutil.commit_batch(db, batch) # Get test data get_batch_test_data(db) # 查看DB所有資料 Leveldbutil.dump(db) return render_template("index.html", reportData=report)
def createXmlTestFile(self): os.chdir('C:\\fw\\Test\\GuiTestDriver\\TeModel') # Convert the spreadsheet comma delineated file of test cases to Xml os.system('CSV2XML Import' + self.type + '.CSV') # Apply a style sheet to the xml file to produce a more readable test case xml file command = ('%sXmlFromCsvStylesheet.bat %s') % ( Constants.desktop_directory, Constants.user) p = subprocess.check_call(command, shell=True) Reporter.print_to_log_file('Created the ' + self.type + ' XML test cases file') Reporter.print_to_log_file(' ')
def create_server(address, options, root): import Reporter reporters = Reporter.getReporters() return ScanViewServer(address, ScanViewRequestHandler, root, reporters, options)
def __init__(self, params): self.reporter = Reporter.Reporter("grid_search_results/" + file + "/" + self.__class__.__name__ + 'iter=' + str(amountOfiterations) + '_stopcrit' + str(stopIteratingAfter) + '_lambda=' + str(params["lam"]) + '_alpha=' + str(params["alpha"]) + '_k=' + str(params["k"]) + '_' + file) self.lam = params["lam"] self.alpha = params["alpha"] self.k = params["k"] self.distanceMatrix = [] self.listMeans = np.zeros(shape=(amountOfiterations)) self.stopIter = 0
def submit_bug(self, c): title = self.get_scalar_field('title') description = self.get_scalar_field('description') report = self.get_scalar_field('report') reporterIndex = self.get_scalar_field('reporter') files = [] for fileID in self.fields.get('files', []): try: i = int(fileID) except: i = None if i is None or i < 0 or i >= len(c.files): return (False, 'Invalid file ID') files.append(c.files[i]) if not title: return (False, "Missing title.") if not description: return (False, "Missing description.") try: reporterIndex = int(reporterIndex) except: return (False, "Invalid report method.") # Get the reporter and parameters. reporter = self.server.reporters[reporterIndex] parameters = {} for o in reporter.getParameters(): name = '{0!s}_{1!s}'.format(reporter.getName(), o.getName()) if name not in self.fields: return ( False, 'Missing field "{0!s}" for {1!s} report method.'.format( name, reporter.getName())) parameters[o.getName()] = self.get_scalar_field(name) # Update config defaults. if report != 'None': self.server.config.set('ScanView', 'reporter', reporterIndex) for o in reporter.getParameters(): if o.saveConfigValue(): name = o.getName() self.server.config.set(reporter.getName(), name, parameters[name]) # Create the report. bug = Reporter.BugReport(title, description, files) # Kick off a reporting thread. t = ReporterThread(bug, reporter, parameters, self.server) t.start() # Wait for thread to die... while t.isAlive(): time.sleep(.25) submitStatus = t.status return (t.success, t.status)
def createBaseProject(self): # Format the command specifying the test-category to run and the output log file for the results test_category = self.testCategory log_file = self.projectLogFile command = ('%sRunTeAutoTests.bat %s >> %s%s') % ( Constants.desktop_directory, test_category, Constants.test_directory, log_file) try: subprocess.check_call(command, shell=True) except: # catch *all* exceptions self.createProjectSucceeded = False Reporter.print_to_log_file('Creating "' + self.backupFile + '" base project FAILED') else: # Backup the project Reporter.print_to_log_file('Backing up project "' + self.backupFile + ' IMPORT TEST"') #db backup "MALAY PARATEXT 5 IMPORT TEST" "MALAY PARATEXT 5 IMPORT TEST.bak" command = ('db backup "' + self.backupFile + ' IMPORT TEST" "' + self.backupFile + ' IMPORT TEST.bak"') p = subprocess.check_call(command, shell=True) Reporter.print_to_log_file( '====================================================')
def modelLintRec(children): # for errors only possible after the model is populated by style for obj in children: # text objects have/need text oType = obj.otype if (oType in TextObjects and (not ("text" in obj.oattrs))): Reporter.error( "[Unknown]", "This object needs text for definition", "other objects may take optional text, these need text", '{}'.format(obj)) # check markup values oattrs = obj.oattrs if ("text" in oattrs): #print(str(obj)) for k, v in oattrs.items(): if (k in MarkupValues): if (not (v in MarkupValues[k])): Reporter.warning( "[Unknown]", "Unecognized markup value", "valid values are {}".format(MarkupValues[k]), '"{}:{}"'.format(k, v)) # radios have osClass for grouping if (oType == "RadioButton" and (not obj.sClass)): Reporter.error( "[Unknown]", "RadioButton needs a structure class for definition", "GUI will not function", '{}'.format(obj)) modelLintRec(obj.children)
def modelParseLint(text): # Assume no interest in indenting idStash = [] for idx, l in enumerate(iter(text.splitlines())): lineNum = idx + 1 lStripLine = l.strip() lStriplineLen = len(lStripLine) # if empty line... if (lStriplineLen == 0): continue obj = modelLineParse(lStriplineLen, lStripLine) #print(obj) # unidentified type # if (not obj.otype): # error( # lineNum, # "No selector type", # "values will be ignored, structure disrupted", # '"{}"'.format(l) # ) # Also covers accidental appearance of 'Root' oType = obj.otype if (oType and not (oType in Object.WidgetTypes)): Reporter.error(lineNum, "Selector type failed to match a known type", "values will case a compile error", ' "{}"'.format(oType)) # duplicate id oId = obj.oid if (oId): if (oId in idStash): Reporter.error( lineNum, "Id used twice", "styles will probably be applied to second instance, but undefined", '"{}"'.format(oId)) idStash.append(oId)
def ORFliner(basefile): '''This will run EMBOSS 'getorf' and use 2 scripts to filter the results and write a report. The paramters for 'getorf' are changed here.''' os.chdir(os.path.split(basefile)[0]) cli = [ config.get('Program paths', 'GetORF_path'), '-sequence', basefile + '.SNPs.fasta', '-outseq', basefile + '.allORFs.fasta', '-find', '3' ] print("\nRunning EMBOSS 'getorf' using the following command:") print(' '.join(cli)) RunProgram(cli, 0) # After this we go to ORFmaker.py: print("\nRunning ORFmaker module...") ORFmaker.RunModule(basefile + '.allORFs.fasta') # Next we BLAST the resulting ORFs against the local 'nr' database: if config.get('Program paths', 'BLAST_path').endswith('blast2'): cli = [ config.get('Program paths', 'BLAST_path'), '-p', 'blastx', '-d', config.get('Program paths', 'BLASTdb_path'), '-i', basefile + '.BestORF.fasta', '-H', 'T', '-a', config.get('Variables', 'seqcores'), '-o', basefile + '.ORFblast.html' ] else: cli = [ config.get('Program paths', 'BLAST_path'), '-db', config.get('Program paths', 'BLASTdb_path'), '-query', basefile + '.BestORF.fasta', '-html', '-num_threads', config.get('Variables', 'seqcores'), '-out', basefile + '.ORFblast.html' ] print("\nRunning NCBI 'blastx' using the following command:") print(' '.join(cli)) RunProgram(cli, 0) # Then we write the metrics report: print("\nRunning the metrics calculator module...") seqclean_log_path = "%s/seqcl_%s.fasta.log" % (os.path.split(basefile)[0], miraproject) Metrics.Run_module( seqclean_log_path, basefile + '.fasta', basefile + '.clean.fasta', basefile + '.fasta.qual', basefile + '.clean.fasta.qual', basefile + '_assembly/' + miraproject + '_d_info/' + miraproject + '_info_assembly.txt', basefile + '.SNPs.fasta', basefile + '.BestORF.fasta', basefile + '.Metrics.html') # Finally we write down our report using the data gathered so far: print("\nRunning Reporter module...") Reporter.RunModule(basefile + '.BestORF.fasta', basefile + '.SNPs.fasta', basefile + '.ORFblast.html', basefile + '.Report.html', basefile + '_out.short.tcs')
def __init__(self): self.reporter = Reporter.Reporter(self.__class__.__name__) self.population = [] self.offspring = [] self.dist_matrix = [] self.no_cities = 0 self.pop_size = 200 # desired lambda size self.no_offspring = self.pop_size * 3 # offspring generation size self.tolerance = 1e-2 self.checkInterval = 10 self.iteration = 0 self.timing = 0 self.c = 1 # to increase size of 2-opt for best individuals self.stop_time = 30 # max time left for the last local search # METHODS self.initialization = self.initialization_smart self.selection = self.selection_round_robin self.recombination = self.recombination_SCX self.mutation = self.mutation_all_keep_better self.local_search = self.lopt_two_opt_all self.elimination = self.elimination_round_robin_k_crowding # META parameters # selection # round robin selection self.round_robin_q_selection = int(self.pop_size * 0.1) # recombination # - # mutation self.init_mut_prob_flip = 0.4 # initial probability of flip mutation self.init_mut_prob_shuf = 0.25 # initial probability of shuffle mutation self.min_mut_prob = 0.01 # minimal mutation probability for all self.mut_boost_treshold = 0.1 # with lower mutation average a boost will ocur # mutation gets boosted by Coef * Init_mut_prob self.mut_boost_coefficient = 0.5 # local optimization self.two_opt_subinterval_size = int(self.pop_size * 0.2) # elimination self.crowding_k = int( (self.pop_size + self.no_offspring) * 0.3) # k-tournament crowding # number of individuals poped due to crowding self.crowding_pop_count = min(self.pop_size, self.no_offspring) self.round_robin_q_elimination = int(self.pop_size * 0.15) # round robin elimination
def styleSelectorLint(text, start, end): selector = styleSelectorParse(text, start, end) if (not (selector.oType or selector.oId or selector.oClass)): lineNum = Reporter.getLineNum(text, start) Reporter.warning(lineNum, "failed to parse a style selector", "declaration will be ignored", '"{}"'.format(text)) if (selector.oType and (not selector.oType in Object.WidgetTypes)): lineNum = Reporter.getLineNum(text, start) Reporter.warning(lineNum, "Selector type failed to match a known type", "declaration will be ignored", '"{}"'.format(text))
def install(self): Reporter.print_to_log_file('Getting the latest FieldWorks installer') os.system('copy \\\\jar-file\\SilLangSoft\\FW_6_0\\FieldWorks\\SetupFW.msi c:\\') Reporter.print_to_log_file('Installing latest FieldWorks') os.system('msiexec /i c:\setupfw.msi /qb') #for handle in GetHandles('SQL Failure'): # for childHandle in GetHandles('ok', handle): # user32.SendMessageA(childHandle, 0x00F5, 0, 0) # 0x00F5 = BM_CLICK os.system('path=%path%;C:\\"Program Files"\\"Common Files"\\SIL') Reporter.print_to_log_file('Finished installing FieldWorks')
def createBaseProject(self): # Format the command specifying the test-category to run and the output log file for the results test_category = self.testCategory log_file = self.projectLogFile command = ('%sRunTeAutoTests.bat %s >> %s%s') % (Constants.desktop_directory,test_category,Constants.test_directory,log_file) try: subprocess.check_call(command, shell=True) except: # catch *all* exceptions self.createProjectSucceeded = False Reporter.print_to_log_file('Creating "' + self.backupFile + '" base project FAILED') else: # Backup the project Reporter.print_to_log_file('Backing up project "' + self.backupFile + ' IMPORT TEST"') #db backup "MALAY PARATEXT 5 IMPORT TEST" "MALAY PARATEXT 5 IMPORT TEST.bak" command = ('db backup "' + self.backupFile + ' IMPORT TEST" "' + self.backupFile + ' IMPORT TEST.bak"') p = subprocess.check_call(command, shell=True) Reporter.print_to_log_file('====================================================')
def runSingleTest(self): if self.runTestCases == True: if self.initTimesSena3Db == True: # Initialize / clean-up the file named TimesSena3Db.xml os.chdir(Constants.desktop_directory_fmt2) shutil.copy('Original_TimesSena3Db.xml', 'TimesSena3Db.xml') shutil.copy('Original_TimesSena3Db.xml', 'Times1Sena3Db.xml') startTime = time.clock() self.createProject == False # Create the test directory subprocess.check_call(["md", Constants.test_directory_fmt2 + self.type], shell=True) #Delete the old result files os.system('del/q "C:\\GuiTestResults\\' + self.resultFilesDirectory + '\\*.*"') testFailuresCount = 0 log_file = Constants.test_directory + self.type + '\\TestCase' + '.log' log_file_no_quotes = Constants.test_directory_fmt2 + self.type + '\\TestCase' + '.log' # Prints '*** RoundTrip_Oxes' test_case_type_nbr = '*** ' + self.type Reporter.print_to_log_file(test_case_type_nbr) # Format the command specifying the test-category to run and the output log file for the results command = ('%sRunTeAutoTests.bat %s >> %s') % (Constants.desktop_directory,self.testCategory,log_file) p = subprocess.call(command, shell=True) self.testPassed = False # The test passed if there are no Failures for line in fileinput.FileInput(log_file_no_quotes): if ", Failures: 0," in line: self.testPassed = True if self.testPassed == True or self.testPassed == False: os.chdir(Constants.desktop_directory_fmt2) # Apply a style sheet to the xml file to produce a more readable test case xml file p = subprocess.check_call(self.updateTimes1PerfFile, shell=True) # Copy 'Times1Sena3Db.xml' to 'TimesSena3Db.xml' shutil.copy(self.times1PerfDbFile, self.timesPerfDbFile) # Checking on the existence of the Performance directory performDirPath = Constants.test_directory_fmt2 + 'Performance' performDirPathExists = os.path.isdir(performDirPath) # Create the Performance directory if it doesn't exist if performDirPathExists == False: subprocess.check_call(["md", performDirPath], shell=True) os.chdir(performDirPath) shutil.copy((Constants.desktop_directory_fmt2 + self.timesPerfDbFile), self.timesPerfDbFile) shutil.copy((Constants.desktop_directory_fmt2 + self.perfChartFile), self.perfChartFile) shutil.copy((Constants.desktop_directory_fmt2 + self.dbPerfChartFile), self.dbPerfChartFile) if self.testPassed == False: Reporter.print_to_log_file('*** Failed ***') test_case_name = '*** ' + self.testCategory Reporter.only_print_to_specified_log(self.testFailureLog,test_case_name) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,test_case_type_nbr) sourceDirectory = 'C:\\GuiTestResults\\' + self.resultFilesDirectory file_count = len(os.walk(sourceDirectory).next()[2]) if file_count > 0: # Copy all the test result files from the generic GuiTestResults directory to # the new GuiTestResults folder for permanently storing the export output files. targetDirectory = Constants.test_directory_fmt2 + 'GuiTestResults\\' + self.resultFilesDirectory shutil.copytree(sourceDirectory,targetDirectory) Reporter.print_to_log_file(' ') if self.testPassed == False: Constants.testFailures = True testCaseFailuresStr = "%i" %testFailuresCount Reporter.print_to_log_file('!!! ' + self.type + ' Test Failure !!!') Reporter.only_print_to_specified_log(Constants.test_fail_comp_file,self.type + ' Test Failures = ' + testCaseFailuresStr) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,'=======================') else: Reporter.print_to_log_file('!!! SUCCESS -> ' + self.type + ' Test Failures = 0 !!!') Reporter.print_to_log_file('====================================================')
from configuration import Conf from test_details import ReportElementStatus, ReportElementType from time import localtime, strftime import time import Reporter as Difido difido_suite_name = None # type: str difido_test_name = None # type: str testAttr = {} reporter = Difido.Reporter() config_file = "config.cfg" automation_ver = "Some version Here" def pytest_runtest_setup(item): global current_test_number global testAttr testAttr = {'starttime': strftime("%Y%m%d %H:%M:%S", localtime()), 'doc': "", 'className': item.nodeid.split("::")[1].replace("Test", "")} testname = item.name.replace("test_", "") reporter.start_test(testname, testAttr) def pytest_runtest_logreport(report): if report.when == 'call': if report.outcome == 'failed': testAttr['status'] = ReportElementStatus.ERROR reporter.report("", "<pre>" + str(report.longreprtext) + "</pre>", element_type=ReportElementType.HTML, status=ReportElementStatus.ERROR) else: testAttr['status'] = ReportElementStatus.SUCCESS time.sleep(1)
def run(self): self.createProjectSucceeded = True # Create the Xml Test File self.createXmlTestFile() Reporter.print_to_log_file( 'Checking on the existence of the base project') backupFilePath = 'C:\\Documents and Settings\\All Users\\Application Data\\SIL\\FieldWorks\\Data\\' + self.backupFile + ' IMPORT TEST.bak' backupFilePathExists = os.path.isfile(backupFilePath) # Create the base project if self.createProject == True or backupFilePathExists == False: Reporter.print_to_log_file('Creating the ' + self.type + ' Test base project') self.createBaseProject() if self.createProjectSucceeded: # Run the test cases if self.runTestCases: # Create the test directory subprocess.check_call( ["md", Constants.test_directory_fmt2 + self.type], shell=True) #Delete the old result files os.system('del/q "C:\\GuiTestResults\\' + self.resultFilesDirectory + '\\*.*"') testFailuresCount = 0 # Loop thru the test cases for test_case_nbr in self.testCases: aTestcase = TestCase.TestCase(test_case_nbr) aTestcase.type = self.type aTestcase.resultFilesDirectory = self.resultFilesDirectory aTestcase.backupFile = self.backupFile aTestcase.testFailureLog = self.testFailureLog if aTestcase.run(): os.chdir(Constants.desktop_directory_fmt2) # Apply a style sheet to the xml file to produce a more readable test case xml file p = subprocess.check_call(self.updateTimes1PerfFile, shell=True) # Copy 'Times1.xml' to 'Times.xml' shutil.copy(self.times1PerfDbFile, self.timesPerfDbFile) # Checking on the existence of the Performance directory performDirPath = Constants.test_directory_fmt2 + 'Performance' performDirPathExists = os.path.isdir(performDirPath) # Create the Performance directory if it doesn't exist if performDirPathExists == False: subprocess.check_call(["md", performDirPath], shell=True) os.chdir(performDirPath) shutil.copy((Constants.desktop_directory_fmt2 + self.timesPerfDbFile), self.timesPerfDbFile) shutil.copy((Constants.desktop_directory_fmt2 + self.perfChartFile), self.perfChartFile) shutil.copy((Constants.desktop_directory_fmt2 + self.dbPerfChartFile), self.dbPerfChartFile) else: testFailuresCount += 1 sourceDirectory = 'C:\\GuiTestResults\\' + self.resultFilesDirectory file_count = len(os.walk(sourceDirectory).next()[2]) if file_count > 0: # Copy all the test result files from the generic GuiTestResults directory to # the new GuiTestResults folder for permanently storing the export output files. targetDirectory = Constants.test_directory_fmt2 + 'GuiTestResults\\' + self.resultFilesDirectory shutil.copytree(sourceDirectory, targetDirectory) Reporter.print_to_log_file(' ') if testFailuresCount > 0: Constants.testFailures = True testCaseFailuresStr = "%i" % testFailuresCount Reporter.print_to_log_file('!!! ' + self.type + ' Test Failures = ' + testCaseFailuresStr + ' !!!') Reporter.only_print_to_specified_log( Constants.test_fail_comp_file, self.type + ' Test Failures = ' + testCaseFailuresStr) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, '=======================') else: Reporter.print_to_log_file('!!! SUCCESS -> ' + self.type + ' Test Failures = 0 !!!') Reporter.print_to_log_file( '====================================================')
def run(self): startTime = time.clock() # Convert the test case number int to a string testCase_Nbr = "%i" %self.name test_category = 'Test_Case_' + testCase_Nbr if self.name < 10: log_file = Constants.test_directory + self.type + '\\TestCase0' + testCase_Nbr + '.log' log_file_no_quotes = Constants.test_directory_fmt2 + self.type + '\\TestCase0' + testCase_Nbr + '.log' else: log_file = Constants.test_directory + self.type + '\\TestCase' + testCase_Nbr + '.log' log_file_no_quotes = Constants.test_directory_fmt2 + self.type + '\\TestCase' + testCase_Nbr + '.log' Reporter.print_to_log_file('Restoring base project') #db restore "MALAY PARATEXT 5 IMPORT TEST" "MALAY PARATEXT 5 IMPORT TEST.bak" command = ('db restore "' + self.backupFile + ' IMPORT TEST" "' + self.backupFile + ' IMPORT TEST.bak"') p = subprocess.check_call(command, shell=True) # Prints '*** PARATEXT5_BT / Test_Case_1' test_case_type_nbr = '*** ' + self.type + ' / ' + test_category Reporter.print_to_log_file(test_case_type_nbr) # Format the command specifying the test-category to run and the output log file for the results command = ('%sRunTeAutoTests.bat %s >> %s') % (Constants.desktop_directory,test_category,log_file) p = subprocess.call(command, shell=True) # The test passed if there are no Failures for line in fileinput.FileInput(log_file_no_quotes): if ", Failures: 0," in line: self.testPassed = True if not self.testPassed: Reporter.print_to_log_file('*** Failed ***') test_case_name = '*** ' + test_category Reporter.only_print_to_specified_log(self.testFailureLog,test_case_name) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,test_case_type_nbr) for line in fileinput.FileInput(log_file_no_quotes): if "1) GuiTestDriver.ImportParatext6.ImportCase" in line: Reporter.print_to_log_file(line) Reporter.only_print_to_specified_log(self.testFailureLog,line) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,line) for line in fileinput.FileInput(log_file_no_quotes): if " File-Comp Assert:" in line: # Clear the linecache because 'CompareFiles.txt' has changed linecache.clearcache() mrfPathName = linecache.getline(Constants.compare_files_log, 1) testCaseResultFile = linecache.getline(Constants.compare_files_log, 2) exportScriptureFilePath = linecache.getline(Constants.compare_files_log, 3) #example-> C:\Documents and Settings\JonesT\Desktop\Tests Results\2009-07-30 13.27.39\GuiTestResults\ImportParatext6\Test Case 4 Scripture.sf exportFilePathName = ' \"' + Constants.test_directory_fmt2 + 'GuiTestResults\\' + self.resultFilesDirectory + '\\' + testCaseResultFile[:-1] + '\"' kdiff3_formatted_line = Constants.kdiff3_path + mrfPathName[:-1] + exportFilePathName kdiff3_formatted_line2 = Constants.kdiff3_path + mrfPathName[:-1] + ' ' + exportScriptureFilePath instruction = 'NOTE - Paste this line into a cmd window to compare the export file with the MRF' instruction2 = 'NOTE - Use this line for compare when test cases are stopped before their completion' Reporter.only_print_to_specified_log(self.testFailureLog,instruction2) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,instruction2) Reporter.only_print_to_specified_log(self.testFailureLog,kdiff3_formatted_line2) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,kdiff3_formatted_line2) #Reporter.only_print_to_specified_log(self.testFailureLog,' ') #Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,' ') Reporter.only_print_to_specified_log(self.testFailureLog,instruction) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,instruction) Reporter.only_print_to_specified_log(self.testFailureLog,kdiff3_formatted_line) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,kdiff3_formatted_line) Reporter.only_print_to_specified_log(self.testFailureLog,'---------------') Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,'---------------') seconds = time.clock() - startTime total_time = Reporter.elapsed_time( seconds, [' day',' hour',' minute',' second'], add_s=True, separator=', ') Reporter.print_to_log_file(total_time) Reporter.print_to_log_file('---------------') if self.testPassed: return True else: return False
def run(self): startTime = time.clock() # Convert the test case number int to a string testCase_Nbr = "%i" % self.name test_category = 'Test_Case_' + testCase_Nbr if self.name < 10: log_file = Constants.test_directory + self.type + '\\TestCase0' + testCase_Nbr + '.log' log_file_no_quotes = Constants.test_directory_fmt2 + self.type + '\\TestCase0' + testCase_Nbr + '.log' else: log_file = Constants.test_directory + self.type + '\\TestCase' + testCase_Nbr + '.log' log_file_no_quotes = Constants.test_directory_fmt2 + self.type + '\\TestCase' + testCase_Nbr + '.log' Reporter.print_to_log_file('Restoring base project') #db restore "MALAY PARATEXT 5 IMPORT TEST" "MALAY PARATEXT 5 IMPORT TEST.bak" command = ('db restore "' + self.backupFile + ' IMPORT TEST" "' + self.backupFile + ' IMPORT TEST.bak"') p = subprocess.check_call(command, shell=True) # Prints '*** PARATEXT5_BT / Test_Case_1' test_case_type_nbr = '*** ' + self.type + ' / ' + test_category Reporter.print_to_log_file(test_case_type_nbr) # Format the command specifying the test-category to run and the output log file for the results command = ('%sRunTeAutoTests.bat %s >> %s') % ( Constants.desktop_directory, test_category, log_file) p = subprocess.call(command, shell=True) # The test passed if there are no Failures for line in fileinput.FileInput(log_file_no_quotes): if ", Failures: 0," in line: self.testPassed = True if not self.testPassed: Reporter.print_to_log_file('*** Failed ***') test_case_name = '*** ' + test_category Reporter.only_print_to_specified_log(self.testFailureLog, test_case_name) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, test_case_type_nbr) for line in fileinput.FileInput(log_file_no_quotes): if "1) GuiTestDriver.ImportParatext6.ImportCase" in line: Reporter.print_to_log_file(line) Reporter.only_print_to_specified_log( self.testFailureLog, line) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, line) for line in fileinput.FileInput(log_file_no_quotes): if " File-Comp Assert:" in line: # Clear the linecache because 'CompareFiles.txt' has changed linecache.clearcache() mrfPathName = linecache.getline( Constants.compare_files_log, 1) testCaseResultFile = linecache.getline( Constants.compare_files_log, 2) exportScriptureFilePath = linecache.getline( Constants.compare_files_log, 3) #example-> C:\Documents and Settings\JonesT\Desktop\Tests Results\2009-07-30 13.27.39\GuiTestResults\ImportParatext6\Test Case 4 Scripture.sf exportFilePathName = ' \"' + Constants.test_directory_fmt2 + 'GuiTestResults\\' + self.resultFilesDirectory + '\\' + testCaseResultFile[: -1] + '\"' kdiff3_formatted_line = Constants.kdiff3_path + mrfPathName[: -1] + exportFilePathName kdiff3_formatted_line2 = Constants.kdiff3_path + mrfPathName[: -1] + ' ' + exportScriptureFilePath instruction = 'NOTE - Paste this line into a cmd window to compare the export file with the MRF' instruction2 = 'NOTE - Use this line for compare when test cases are stopped before their completion' Reporter.only_print_to_specified_log( self.testFailureLog, instruction2) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, instruction2) Reporter.only_print_to_specified_log( self.testFailureLog, kdiff3_formatted_line2) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, kdiff3_formatted_line2) #Reporter.only_print_to_specified_log(self.testFailureLog,' ') #Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,' ') Reporter.only_print_to_specified_log( self.testFailureLog, instruction) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, instruction) Reporter.only_print_to_specified_log( self.testFailureLog, kdiff3_formatted_line) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, kdiff3_formatted_line) Reporter.only_print_to_specified_log(self.testFailureLog, '---------------') Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, '---------------') seconds = time.clock() - startTime total_time = Reporter.elapsed_time( seconds, [' day', ' hour', ' minute', ' second'], add_s=True, separator=', ') Reporter.print_to_log_file(total_time) Reporter.print_to_log_file('---------------') if self.testPassed: return True else: return False
def callApendFile(self, path, KeywordName, expected, actual, imgPath, count): report = Reporter.Reporter() report.apendFile(path, KeywordName, expected, actual, imgPath, count)
print(us,"vs",adversary) runAuctions(generateBotList(us,adversary,num_advertisers)) def runMultipleBotCombinationsAuctions2(): #execution for us in all_bots_list: for adversary in all_bots_list: print(us,"vs",adversary) runAuctions(generateBotList(us,adversary,num_advertisers)) def runAllSameBotAuctions(): for bot_type in all_bots_list: print("Running ",bot_type) runAuctions(generateBotList(bot_type,bot_type,num_advertisers)) no = randint(1,1000) rep = Reporter() rep.executionNumber = no print("Executing ",no) printAuctionSettings(no,num_advertisers+1,minSlots,maxSlots,minValue,maxValue,minBudget,maxBudget,nAuctions,max_step,isVCG) # runMultipleBotCombinationsAuctions() # runMultipleBotCombinationsAuctions2() # runAllBotsAuction() # runSingleBotCombinationAuction() runAllSameBotAuctions() print("Executed ",no)
def __init__(self): self.reporter = Reporter.Reporter(self.__class__.__name__)
class Test(object): report: Difido.Reporter = Difido.Reporter()
def uninstall(self): Reporter.print_to_log_file('Uninstalling current FieldWorks') os.system('msiexec /x c:\setupfw.msi /qb')
def lint(modelText, styleText): modelParseLint(modelText) styleLint(styleText) #! should only continue if not overwhelmed by errors objectModel = modelParse(modelText) styleModel = styleParse(styleText) stylePopulate(objectModel, styleModel) modelLint(objectModel) ## Tests if __name__ == "__main__": Reporter.testHeader("ModelParse") o = modelParse(""" VBox#support.warning """) print(str(o.children[0])) # over-indexed #o = modelParse(""" #support """, 0, 22) #print(str(o)) # handle late-repeated marks o = modelParse(""" IconButton|/images/image.png """) print(str(o.children[0])) Reporter.testHeader("ModelParseLint") modelParseLint("VBox\n Button|Go\n Button|Stop ") # undefined type modelParseLint("VBox\n Button|Go\n ColourSelect|Stop ") # duplicate ids modelParseLint("VBox#truth\n Button|Go\n Button#truth|Stop ")
def run(self): self.createProjectSucceeded = True # Create the Xml Test File self.createXmlTestFile() Reporter.print_to_log_file('Checking on the existence of the base project') backupFilePath = 'C:\\Documents and Settings\\All Users\\Application Data\\SIL\\FieldWorks\\Data\\' + self.backupFile + ' IMPORT TEST.bak' backupFilePathExists = os.path.isfile(backupFilePath) # Create the base project if self.createProject == True or backupFilePathExists == False: Reporter.print_to_log_file('Creating the ' + self.type + ' Test base project') self.createBaseProject() if self.createProjectSucceeded: # Run the test cases if self.runTestCases: # Create the test directory subprocess.check_call(["md", Constants.test_directory_fmt2 + self.type], shell=True) #Delete the old result files os.system('del/q "C:\\GuiTestResults\\' + self.resultFilesDirectory + '\\*.*"') testFailuresCount = 0 # Loop thru the test cases for test_case_nbr in self.testCases: aTestcase = TestCase.TestCase(test_case_nbr) aTestcase.type = self.type aTestcase.resultFilesDirectory = self.resultFilesDirectory aTestcase.backupFile = self.backupFile aTestcase.testFailureLog = self.testFailureLog if aTestcase.run(): os.chdir(Constants.desktop_directory_fmt2) # Apply a style sheet to the xml file to produce a more readable test case xml file p = subprocess.check_call(self.updateTimes1PerfFile, shell=True) # Copy 'Times1.xml' to 'Times.xml' shutil.copy(self.times1PerfDbFile, self.timesPerfDbFile) # Checking on the existence of the Performance directory performDirPath = Constants.test_directory_fmt2 + 'Performance' performDirPathExists = os.path.isdir(performDirPath) # Create the Performance directory if it doesn't exist if performDirPathExists == False: subprocess.check_call(["md", performDirPath], shell=True) os.chdir(performDirPath) shutil.copy((Constants.desktop_directory_fmt2 + self.timesPerfDbFile), self.timesPerfDbFile) shutil.copy((Constants.desktop_directory_fmt2 + self.perfChartFile), self.perfChartFile) shutil.copy((Constants.desktop_directory_fmt2 + self.dbPerfChartFile), self.dbPerfChartFile) else: testFailuresCount += 1 sourceDirectory = 'C:\\GuiTestResults\\' + self.resultFilesDirectory file_count = len(os.walk(sourceDirectory).next()[2]) if file_count > 0: # Copy all the test result files from the generic GuiTestResults directory to # the new GuiTestResults folder for permanently storing the export output files. targetDirectory = Constants.test_directory_fmt2 + 'GuiTestResults\\' + self.resultFilesDirectory shutil.copytree(sourceDirectory,targetDirectory) Reporter.print_to_log_file(' ') if testFailuresCount > 0: Constants.testFailures = True testCaseFailuresStr = "%i" %testFailuresCount Reporter.print_to_log_file('!!! ' + self.type + ' Test Failures = ' + testCaseFailuresStr + ' !!!') Reporter.only_print_to_specified_log(Constants.test_fail_comp_file,self.type + ' Test Failures = ' + testCaseFailuresStr) Reporter.only_print_to_specified_log(Constants.all_Tests_Failure_Log,'=======================') else: Reporter.print_to_log_file('!!! SUCCESS -> ' + self.type + ' Test Failures = 0 !!!') Reporter.print_to_log_file('====================================================')
from auto_Data import * from BronKerbosch import bronker_bosch1 from PivotBronKerbosch import bronker_bosch2 from Reporter import * if __name__ == '__main__': funcs = [bronker_bosch1, bronker_bosch2] for func in funcs: report = Reporter(func) func([], set(NODES), set(), report) report.print_report() report.export_report()
def runSingleTest(self): if self.runTestCases == True: if self.initTimesSena3Db == True: # Initialize / clean-up the file named TimesSena3Db.xml os.chdir(Constants.desktop_directory_fmt2) shutil.copy('Original_TimesSena3Db.xml', 'TimesSena3Db.xml') shutil.copy('Original_TimesSena3Db.xml', 'Times1Sena3Db.xml') startTime = time.clock() self.createProject == False # Create the test directory subprocess.check_call( ["md", Constants.test_directory_fmt2 + self.type], shell=True) #Delete the old result files os.system('del/q "C:\\GuiTestResults\\' + self.resultFilesDirectory + '\\*.*"') testFailuresCount = 0 log_file = Constants.test_directory + self.type + '\\TestCase' + '.log' log_file_no_quotes = Constants.test_directory_fmt2 + self.type + '\\TestCase' + '.log' # Prints '*** RoundTrip_Oxes' test_case_type_nbr = '*** ' + self.type Reporter.print_to_log_file(test_case_type_nbr) # Format the command specifying the test-category to run and the output log file for the results command = ('%sRunTeAutoTests.bat %s >> %s') % ( Constants.desktop_directory, self.testCategory, log_file) p = subprocess.call(command, shell=True) self.testPassed = False # The test passed if there are no Failures for line in fileinput.FileInput(log_file_no_quotes): if ", Failures: 0," in line: self.testPassed = True if self.testPassed == True or self.testPassed == False: os.chdir(Constants.desktop_directory_fmt2) # Apply a style sheet to the xml file to produce a more readable test case xml file p = subprocess.check_call(self.updateTimes1PerfFile, shell=True) # Copy 'Times1Sena3Db.xml' to 'TimesSena3Db.xml' shutil.copy(self.times1PerfDbFile, self.timesPerfDbFile) # Checking on the existence of the Performance directory performDirPath = Constants.test_directory_fmt2 + 'Performance' performDirPathExists = os.path.isdir(performDirPath) # Create the Performance directory if it doesn't exist if performDirPathExists == False: subprocess.check_call(["md", performDirPath], shell=True) os.chdir(performDirPath) shutil.copy( (Constants.desktop_directory_fmt2 + self.timesPerfDbFile), self.timesPerfDbFile) shutil.copy( (Constants.desktop_directory_fmt2 + self.perfChartFile), self.perfChartFile) shutil.copy( (Constants.desktop_directory_fmt2 + self.dbPerfChartFile), self.dbPerfChartFile) if self.testPassed == False: Reporter.print_to_log_file('*** Failed ***') test_case_name = '*** ' + self.testCategory Reporter.only_print_to_specified_log(self.testFailureLog, test_case_name) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, test_case_type_nbr) sourceDirectory = 'C:\\GuiTestResults\\' + self.resultFilesDirectory file_count = len(os.walk(sourceDirectory).next()[2]) if file_count > 0: # Copy all the test result files from the generic GuiTestResults directory to # the new GuiTestResults folder for permanently storing the export output files. targetDirectory = Constants.test_directory_fmt2 + 'GuiTestResults\\' + self.resultFilesDirectory shutil.copytree(sourceDirectory, targetDirectory) Reporter.print_to_log_file(' ') if self.testPassed == False: Constants.testFailures = True testCaseFailuresStr = "%i" % testFailuresCount Reporter.print_to_log_file('!!! ' + self.type + ' Test Failure !!!') Reporter.only_print_to_specified_log( Constants.test_fail_comp_file, self.type + ' Test Failures = ' + testCaseFailuresStr) Reporter.only_print_to_specified_log( Constants.all_Tests_Failure_Log, '=======================') else: Reporter.print_to_log_file('!!! SUCCESS -> ' + self.type + ' Test Failures = 0 !!!') Reporter.print_to_log_file( '====================================================')
def styleLint(text): sStart = 0 aOpen = text.find("{") aClose = text.find("}") #print(str(aOpen)) #print(str(aClose)) # EOF case if (not (aClose == -1 and aOpen == -1)): if (aClose == -1): lineNum = Reporter.getLineNum(text, aOpen) line = Reporter.getLine(text, aOpen) Reporter.warning(lineNum, "missing close bracket", "following definitions will be unused", '{}'.format(line)) if (aOpen == -1 or (aClose != -1 and aClose < aOpen)): lineNum = Reporter.getLineNum(text, aClose) line = Reporter.getLine(text, aClose) Reporter.warning(lineNum, "missing open bracket", "preceeding definitions will be unused", '{}'.format(line)) # relies on -1 if aClose not found while ((aOpen != -1) and (aOpen < aClose)): selector = styleSelectorLint(text, sStart, aOpen) sAttrs = styleAttributesLint(text, aOpen + 1, aClose) sStart = aClose + 1 aOpen = text.find("{", sStart) aClose = text.find("}", sStart) #print(str(aOpen)) #print(str(aClose)) # EOF case if (not (aClose == -1 and aOpen == -1)): if (aClose == -1): lineNum = Reporter.getLineNum(text, aOpen) line = Reporter.getLine(text, aOpen) Reporter.warning(lineNum, "missing close bracket", "following definitions will be unused", '{}'.format(line)) if (aOpen == -1 or (aClose != -1 and aClose < aOpen)): lineNum = Reporter.getLineNum(text, aClose) line = Reporter.getLine(text, aClose) Reporter.warning(lineNum, "missing sopen bracket", "preceeding definitions will be unused", '{}'.format(line))
else: aTestPlan.testCases[0:] = testCases if aTestPlan.runTestCases: aTestPlan.run() #---------------------------------------------------------------------- startTime = time.clock() # Prepare for the timing performance tests os.chdir(Constants.desktop_directory_fmt2) shutil.copy('Original_TimesMalayDb.xml', 'TimesMalayDb.xml') shutil.copy('Original_TimesMalayDb.xml', 'Times1MalayDb.xml') # Create the test directory subprocess.check_call(["md", Constants.test_directory_fmt2], shell=True) Reporter.createReportHeading() #------ RUN TESTS -------- Reinstall_Fieldworks = False ONLY_Install_Fieldworks = False ONLY_Reinstall_Fieldworks = False Force_Create_Base_Projects = False Run_ALL_Test_Cases = False if ONLY_Install_Fieldworks: FieldWorks.FieldWorks().install() elif Reinstall_Fieldworks or ONLY_Reinstall_Fieldworks: FieldWorks.FieldWorks().reinstall() # =============== aTestPlan = TestPlan.RoundTripOxes()
def callCreateFile(self, path): report = Reporter.Reporter() report.createFile(path)