Пример #1
0
def isaSaturneSyrthesCouplingStudy(theStudyPath):
    log.debug("isaSaturneSyrthesCouplingStudy")
    iok = False
    hasCFDCase     = False
    hasSyrthesCase = False
    if not os.path.isdir(theStudyPath):
        mess = cfdstudyMess.trMessage(ObjectTR.tr("MUST_BE_A_DIRECTORY"),[theStudyPath])
        cfdstudyMess.criticalMessage(mess)
        return False
    # TODO replace by a more robust test, using a query function of the
    # main code_saturne command or subcommand (to be added)
    dirList = os.listdir(theStudyPath)
    if not (dirList.count("RESU_COUPLING") and dirList.count("run.cfg")):
        return False
    for i in dirList:
        ipath = os.path.join(theStudyPath,i)
        if os.path.isdir(ipath):
            if i not in ["MESH", "RESU_COUPLING"]:
                if isaCFDCase(ipath):
                    hasCFDCase = True
                if isSyrthesCase(ipath):
                    hasSyrthesCase = True
    if hasCFDCase and hasSyrthesCase:
        iok = True
    return iok
    def accept(self):
        aDirLE                      = self.findChild(QLineEdit,"StudyDirName")
        aNameLE                     = self.findChild(QLineEdit,"StudyLineEdit")
        aCaseLE                     = self.findChild(QLineEdit,"CaseLineEdit")
        CreateOption                = self.findChild(QCheckBox,"checkBoxCreate")
        Neptune                     = self.findChild(QRadioButton,"radioButtonNeptune")
        Saturne                     = self.findChild(QRadioButton,"radioButtonSaturne")
        self.CaseNames              = str(self.findChild(QLineEdit,"CaseLineEdit").text())
        self.CopyFromOption         = self.findChild(QCheckBox, "checkBoxCopyFrom").isChecked()
        self.CouplingSaturneSyrthes = self.findChild(QCheckBox, "checkBoxCouplingSaturneSyrthes").isChecked()
        self.Nprocs                 = str(self.findChild(QLineEdit,"NprocsLineEdit").text())
        if  aNameLE.text() == "" :
            mess = cfdstudyMess.trMessage(self.tr("LOCATION_DLG_ERROR_MESS"),[])
            cfdstudyMess.criticalMessage(mess)
            return False

        # check study directory
        aStudyDir = str(aDirLE.text())
        # Load from study dir + study name
        if aNameLE.text() != aNameLE.text():
            raise ValueError("Names must not contain special characters.")

        aStudyDirName = str(aNameLE.text())
        self.StudyPath = os.path.join(aStudyDir, aStudyDirName)
        self.StudyName = aStudyDirName

        if Neptune.isChecked():
            self.code = "NEPTUNE_CFD"
        else:
            self.code = "Code_Saturne"

        if self.checkBoxLoad.isChecked():
            if self.StudyName == '':
                mess = cfdstudyMess.trMessage(self.tr("LOCATION_DLG_ERROR_MESS"),[])
                cfdstudyMess.criticalMessage(mess)
                self.reinit()
                return False
            if not CFDSTUDYGUI_Commons.isaSaturneSyrthesCouplingStudy(self.StudyPath):
                if not CFDSTUDYGUI_Commons.isaCFDStudy(self.StudyPath):
#                   search if the cfd study directory self.StudyPath is in fact a cfd case directory: by calling  method isaCFDCase
                    if not CFDSTUDYGUI_Commons.isaCFDCase(self.StudyPath):
                        mess = cfdstudyMess.trMessage(self.tr("NOT_A_STUDY_OR_CASE_DIRECTORY"),[self.StudyPath,"CFD","SYRTHES"])
                        cfdstudyMess.criticalMessage(mess)
                        self.reinit()
                        return False
        # ckeck case name
        if self.checkBoxCreate.isChecked() :
            if self.StudyName == '':
                mess = cfdstudyMess.trMessage(self.tr("LOCATION_DLG_ERROR_MESS"),[aStudyDir])
                cfdstudyMess.criticalMessage(mess)
                return False
            self.CaseNames = str(aCaseLE.text())
            self.CreateOption = True
            if self.CouplingSaturneSyrthes :
                self.SyrthesCase = str(self.findChild(QLineEdit,"syrthesCase").text())
                if self.SyrthesCase == "":
                    mess = cfdstudyMess.trMessage(self.tr("EMPTY_SYRTHES_CASENAME_MESS"),[])
                    cfdstudyMess.criticalMessage(mess)
                    return False
        SetTreeLocationDialog.accept(self)
Пример #3
0
def isaSaturneSyrthesCouplingStudy(theStudyPath):
    log.debug("isaSaturneSyrthesCouplingStudy")
    iok = False
    hasCFDCase = False
    hasSyrthesCase = False
    if not os.path.isdir(theStudyPath):
        mess = cfdstudyMess.trMessage(ObjectTR.tr("MUST_BE_A_DIRECTORY"),
                                      [theStudyPath])
        cfdstudyMess.criticalMessage(mess)
        return False
    dirList = os.listdir(theStudyPath)
    if not (dirList.count("MESH") and dirList.count("RESU_COUPLING")
            and dirList.count("coupling_parameters.py")
            and dirList.count("runcase")):
        return False
    for i in dirList:
        ipath = os.path.join(theStudyPath, i)
        if os.path.isdir(ipath):
            if i not in ["MESH", "RESU_COUPLING"]:
                if isaCFDCase(ipath):
                    hasCFDCase = True
                if isSyrthesCase(ipath):
                    hasSyrthesCase = True
    if hasCFDCase and hasSyrthesCase:
        iok = True
    return iok
 def accept(self):
     iok, mess = CheckCFD_CodeEnv(CFD_Code())
     if iok:
         if mess != "" :
             mess = cfdstudyMess.trMessage(self.tr("CFDSTUDY_INVALID_ENV"),[]) + mess
             cfdstudyMess.criticalMessage(mess)
         else :
             InfoDialog.accept(self)
     else:
         mess = cfdstudyMess.trMessage(self.tr("INFO_DLG_INVALID_ENV"),[]) + mess
         cfdstudyMess.criticalMessage(mess)