예제 #1
0
		changed_models = codecs.open(self.list_path, "r", encoding='utf8')
		modelica_models = [] 
		Lines =  changed_models.readlines()
		Line= str(Lines)
		Line = Line.split(":")
		for i in Line:
			if i.rfind(".mo")> -1:
				#define modelica models
				model_number = i.rfind(self.package)
				model_name = i[model_number:]
				model_name = model_name.lstrip()
				model_name = model_name.replace(os.sep,".")
				model_name = model_name[:model_name.rfind(".mo")]
				model_name = model_name.replace("..",".")
				modelica_models.append(model_name)
				continue
			else:
				continue
		changed_models.close()
		if len(modelica_models) == 0:
			print("No Models to check")
			exit(0)
		return modelica_models

if  __name__ == '__main__':
	# Import git_model class
	list_path = ".."+os.sep+'bin'+os.sep+'03_WhiteLists'+os.sep+'changedmodels.txt'
	from sort_models import git_models
	list_mo_models = git_models(".mo","AixLib",list_path)
	list_mo_models.sort_mo_models()
	
예제 #2
0
        changed_models = codecs.open(list_path, "r", encoding='utf8')
        modelica_models = []
        Lines = changed_models.readlines()
        Line = str(Lines)
        Line = Line.split(":")
        for i in Line:
            if i.rfind(".mo") > -1:
                #define modelica models
                model_number = i.rfind(self.package)
                model_name = i[model_number:]
                model_name = model_name.lstrip()
                model_name = model_name.replace(os.sep, ".")
                model_name = model_name[:model_name.rfind(".mo")]
                model_name = model_name.replace("..", ".")
                modelica_models.append(model_name)
                continue
            else:
                continue
        changed_models.close()
        if len(modelica_models) == 0:
            print("No Models to check")
            exit(0)
        return modelica_models


if __name__ == '__main__':
    # Import git_model class
    from sort_models import git_models
    list_mo_models = git_models(".mo", "AixLib")
    list_mo_models.sort_mo_models()
예제 #3
0
    def sort_mo_models(self):
        list_path = 'bin' + os.sep + '03_WhiteLists' + os.sep + 'changedmodels.txt'
        #print(list_path)
        changed_models = open(list_path, "r")
        modelica_models = []
        Lines = changed_models.readlines()
        for i in Lines:

            if i.rfind(".mo") > -1:
                #define modelica models
                model_number = i.rfind(" ")
                model_name = i[model_number:]
                model_name = model_name.lstrip()
                #model_name = model_name.replace(os.sep,".")
                model_name = model_name.replace('/', ".")
                model_name = model_name[:model_name.rfind(".mo")]
                modelica_models.append(model_name)
                continue
            else:
                continue
        print(modelica_models)
        return modelica_models


if __name__ == '__main__':
    # Import git_model class
    from sort_models import git_models
    list_mo_models = git_models(".mo")
    list_mo_models.sort_mo_models()
예제 #4
0
    def _CheckStyle(self):
        DymolaVersion = self.DymolaVersion
        from dymola.dymola_interface import DymolaInterface
        from dymola.dymola_exception import DymolaException
        import buildingspy.development.regressiontest as u
        ut = u.Tester(tool=self.tool)
        if platform.system() == "Windows":
            dymola = DymolaInterface(showwindow=True)
        else:
            dymola = DymolaInterface(dymolapath="/usr/local/bin/dymola")
        # Load AixLib
        LibraryCheck = dymola.openModel(self.Library)
        if LibraryCheck == True:
            print("Found AixLib Library and start style check")
        elif LibraryCheck == False:
            print(
                "Library Path is wrong. Please Check Path of AixLib Library Path"
            )
            exit(1)

        # Load ModelManagement
        if platform.system() == "Windows":
            dymola.ExecuteCommand(
                'cd("C:\Program Files\Dymola ' + DymolaVersion +
                '\Modelica\Library\ModelManagement 1.1.8\package.moe");')

        else:
            dymola.ExecuteCommand(
                'cd("/opt/dymola-' + DymolaVersion +
                '-x86_64/Modelica/Library/ModelManagement 1.1.8/package.moe");'
            )
        # Start CheckLibrary in ModelManagement
        print("Start Style Check")
        if self.Changedmodels == False:
            print("Check package or model " + self.Package)
            dymola.ExecuteCommand(
                'ModelManagement.Check.checkLibrary(false, false, false, true, "'
                + self.Package + '", translationStructure=false);')
            Logfile = self.Library.replace(
                "package.mo", self.Package + "_StyleCheckLog.html")
        else:
            changed_model_list = []
            list_mo_models = git_models(".mo", self.Package)
            model_list = list_mo_models.sort_mo_models()
            for l in model_list:
                print("Check package or model " + l)
                path = self.Library.replace("package.mo", "")
                dymola.ExecuteCommand(
                    'ModelManagement.Check.checkLibrary(false, false, false, true, "'
                    + l + '", translationStructure=false);')
                inputfile = path + l + "_StyleCheckLog.html"
                log = codecs.open(inputfile, "r", encoding='utf8')
                for line in log:
                    changed_model_list.append(line)
                log.close()
                os.remove(inputfile)
            path_outfile = "ChangedModels_StyleCheckLog.html"
            all_logs = codecs.open(path + path_outfile, "w", encoding='utf8')
            for i in changed_model_list:
                all_logs.write(i)
            all_logs.close()
            Logfile = path + path_outfile
        dymola.close()
        print("Style Check Complete")
        return Logfile, model_list
예제 #5
0
	def _SimulateModel(self):
		from dymola.dymola_interface import DymolaInterface
		from dymola.dymola_exception import DymolaException
		import buildingspy.development.regressiontest as u
		ut = u.Tester(tool = self.tool)
		### Set Number of Threads
		ut.setNumberOfThreads(self.n_pro)
		### Set GUI Show
		ut.showGUI(self.show_gui)
		### Set in Batch Mode
		ut.batchMode(self.batch)
		### Sets the Dymola path to activate the GUI
		if platform.system()  == "Windows":
			dymola = DymolaInterface()
		else:
			dymola = DymolaInterface(dymolapath="/usr/local/bin/dymola")
		### Writes all information in the log file, not only the last entries
		dymola.ExecuteCommand("Advanced.TranslationInCommandLog:=true;")
		dym_sta_lic_available = dymola.ExecuteCommand('RequestOption("Standard");')
		if not dym_sta_lic_available:
			dymola.ExecuteCommand('DymolaCommands.System.savelog("Log_NO_DYM_STANDARD_LIC_AVAILABLE.txt");')
			print("No Dymola License is available")
			dymola.close()
			exit(1)
		else:
			print("Dymola License is available")
	
		
		PackageCheck = dymola.openModel(self.Library)
		if PackageCheck == True:
			print("Found AixLib Library and start Checkmodel Tests \n Check Package " + self.Package+" \n")
		elif PackageCheck == None:
			print("Library Path is wrong. Please Check Path of AixLib Library Path")
			exit(1)
		
		ErrorList = []
		if self.Changedmodels == False:	
			ModelList = ValidateTest._listAllExamples(self)
			if len(ModelList) == 0:
				print("Wrong Path")
				exit(0)
			for i in ModelList:
				result=dymola.checkModel(i,simulate=True)
				if result == True:
					print('\n Successful: '+i+'\n')
				if result == False:
					print("Second Check Test")
					result=dymola.checkModel(i,simulate=True)
					if result == True:
						print('\n Successful: '+i+'\n')
					if result == False:
						ErrorList.append(i)
						Log = dymola.getLastError()
						print('\n Error: '+i+'\n')
						print(Log)
		
		if self.Changedmodels == True:
			list_path = 'bin'+os.sep+'03_WhiteLists'+os.sep+'changedmodels.txt'
			list_mo_models = git_models(".mo",self.Package, list_path)
			model_list= list_mo_models.sort_mo_models()
			ErrorList = []
			for i in model_list:
				result=dymola.checkModel(i,simulate=True)
				if result == True:
					print('\n Successful: '+i+'\n')
				if result == False:
					print("Second Check Test")
					result=dymola.checkModel(i,simulate=True)
					if result == True:
						print('\n Successful: '+i+'\n')
					if result == False:
						ErrorList.append(i)
						Log = dymola.getLastError()
						print('\n Error: '+i+'\n')
						print(Log)		
		dymola.savelog(self.Package+"-log.txt")
		dymola.close()
		logfile = self.Package+"-log.txt"
		ValidateTest._WriteErrorlog(self,logfile)
		return ErrorList