Ignore:
Timestamp:
Feb 18, 2020 2:28:02 PM (20 months ago)
Author:
maronga
Message:

Added NetCDf output for wind turbine model. Added new features to palmrungui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/palmrungui

    r4405 r4411  
    2525# -----------------
    2626# $Id$
     27# Added new features: individual tag for submitted runs, automatic finding of
     28# configuration, start of palmbuild from GUI
     29#
     30# 4405 2020-02-12 19:11:11Z maronga
    2731# Major revisions: New layout. Merged with palm job manager (palm_jm).
    2832# Minor revisions: Misc. bugs fixed.
     
    127131        self.load_jobs()
    128132
     133        # look up configuration files and add to combo box
     134       
     135        self.group_execution.findChild(QtGui.QComboBox,"combo_configuration").addItem("")
     136       
     137        for files in os.listdir(palm_dir):
     138           if files.startswith(".palm.config"):
     139              tmpstring = filter(None,files.split(".palm.config."))[0]
     140              self.group_execution.findChild(QtGui.QComboBox,"combo_configuration").addItem(tmpstring)
     141
    129142        commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline")
    130143        commandline.setText("")
     
    154167
    155168
     169
    156170   
    157171        QtGui.QApplication.processEvents()
     
    166180       
    167181        # Check for empty line
    168         palmrunline_save = palmrunline;
     182        palmrunline_save = palmrunline
    169183        if (userline != ""):
    170184            palmrunline = "%s %s" % (palmrunline,userline)
     
    174188        self.tabWidget.setEnabled(False)
    175189        self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False)
     190        self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(False)
    176191        self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("wait...")     
    177192        self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmrun in xterm...")       
     
    195210       
    196211        mString = "xterm %s" % (palmrunline)
    197         palmrun.start(mString);
     212        palmrun.start(mString)
    198213   
    199214        if( palmrun.waitForStarted() is False ):
     
    201216       
    202217        # Wait until palmrun has finished or wait for 200 minutes
    203         palmrun.waitForFinished(3600000);       
     218        palmrun.waitForFinished(3600000)       
    204219       
    205220        # Jobs has been submitted or aborted. Continuing...
     
    207222        filename = "%s/.palmrungui.history" % (palm_dir)
    208223        tmstamp = strftime("%Y/%m/%d %H:%M")
     224        tag = str(self.groupBox.findChild(QtGui.QLineEdit,"line_tag").text())
    209225   
    210226        file = open(filename,"a")
    211         s = "%s %s\n" % (tmstamp,history_line)
     227        s = "%s %s (%s)\n" % (tmstamp,history_line,tag)
    212228        file.write(s)
    213229        file.close()             
     
    216232        self.tabWidget.setEnabled(True)
    217233        self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True)
    218         self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("Start palmrun")
    219         self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline_save);
     234        self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("palmrun")
     235        self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline_save)
     236        self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
    220237       
    221238        # Reload recent jobs
     
    223240       
    224241       
     242       
     243    # starts xterm with palmbuild commandline
     244    #######################################
     245    def startpalmbuild(self):
     246        palmbuildline = 'palmbuild -c ' + str(self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText())
     247       
     248        # Disable the main window
     249        self.tabWidget.setEnabled(False)
     250        self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False)
     251        self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(False) 
     252        self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmbuild in xterm...")       
     253       
     254        # Wait until all commands have been executed (ugly) ?
     255        #for i in range(0,21):
     256        #    qApp->processEvents()       
     257       
     258        # Start xterm as QProcess
     259        palmbuild = QProcess()
     260        palmbuild.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels
     261        palmbuild.setWorkingDirectory(palm_dir)
     262   
     263        geomet = self.frameGeometry()
     264       
     265        posx = geomet.x()+geomet.width()
     266        posy = geomet.y()
     267     
     268        s = " -title \"Executing palmbuild...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy)
     269        palmbuildline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmbuildline.replace("\"","\'"))
     270       
     271        mString = "xterm %s" % (palmbuildline)
     272        palmbuild.start(mString)
     273   
     274        if( palmbuild.waitForStarted() is False ):
     275            return
     276       
     277        # Wait until palmbuild has finished or wait for 200 minutes
     278        palmbuild.waitForFinished(3600000)       
     279       
     280         
     281       
     282        # Enable main window again
     283        self.tabWidget.setEnabled(True)
     284        self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True)
     285        self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
     286       
     287        # Reload recent jobs
     288        self.recent_jobs(50)
     289
    225290    # loads recent jobs
    226291    ######################################
     
    235300        history = file.readlines()
    236301        tmphistory = list()
    237         file.close();
    238         j = 0;
     302        tmptag = list()
     303        file.close()
     304        j = 0
    239305
    240306        list_jobname = self.group_history.findChild(QtGui.QListWidget,"list_jobname")
     
    247313            timestamp = history[i][:16]
    248314            listitem = history[i][17:len(history[i])-1]
     315            tagitem = listitem
    249316            matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly)
    250317
     
    252319                listitem = filter(None,listitem.split(" -r"))[1]
    253320                listitem = filter(None,listitem.split(" -"))[0]
    254                 listitem = listitem.replace(" ","");
    255                 list_jobname.addItem(listitem);
    256                 s = "%s (%s)" % (listitem,timestamp)
    257                 tmphistory.append(s);
     321                listitem = listitem.replace(" ","")
     322                list_jobname.addItem(listitem)
     323                s = "%s: %s" % (timestamp,listitem)
     324                tmphistory.append(s)
     325               
     326               
     327                tagitem = filter(None,tagitem.split(" ("))[1]
     328                tagitem = tagitem.replace(")","") 
     329                if ( len(tagitem) == 0 ):
     330                   s = "Tag: empty"
     331                else:
     332                   s = "Tag: %s" % (tagitem)               
     333                tmptag.append(s)
    258334                count = count +1
     335
    259336                j = j+1
    260337               
     
    264341           
    265342        # Send to list
    266         list_jobname.clear();
     343        list_jobname.clear()
    267344       
    268345        i=0
    269346        while i<len(tmphistory):
    270             list_jobname.addItem(tmphistory[i]);
     347            list_jobname.addItem(tmphistory[i])
     348            list_jobname.item(i).setToolTip(tmptag[i])
    271349            i = i+1
    272350           
     
    291369        filename = str(list_jobname.currentItem().text())
    292370           
    293         timestamp = filename[len(filename)-17:][:16]
    294         jobname = filename[:len(filename) - 19];
    295        
     371        timestamp = filename[:16]
     372        jobname = filename[18:]
     373               
    296374        itemint = list_jobname.currentRow()
    297375
     
    301379   
    302380        # Set selected item to jobname
    303         list_jobname.item(itemint).setSelected(True);
     381        list_jobname.item(itemint).setSelected(True)
    304382   
    305383        # Set selected item to jobname in "available jobs" list
    306384        item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive)
    307         self.list_jobs.setCurrentItem(item2int[0])
     385       
     386        if ( item2int != [] ):
     387           self.list_jobs.setCurrentItem(item2int[0])
    308388        self.update_input()
     389           
    309390   
    310391        fileDir = "%s/.palmrungui.history" % (palm_dir)
     
    312393        history = file.readlines()
    313394        tmphistory = list()
    314         file.close();       
     395        file.close()       
    315396   
    316397        i = len(history)
     
    319400            listitem = filter(None,listitem.split(" -r"))[1]
    320401            listitem = filter(None,listitem.split(" -"))[0]
    321             listitem = listitem.replace(" ","");               
     402            listitem = listitem.replace(" ","") 
    322403
    323404            # Select command line with correct timestamp and jobname
     
    326407                palmrunline = palmrunline[17:]
    327408                palmrunline = palmrunline[:len(palmrunline)-1]
    328                 self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline);
    329                 self.setup_gui(palmrunline);
    330                 self.list_jobname.item(itemint).setSelected(True);   
     409                palmrunline = filter(None,palmrunline.split("("))[0]
     410                self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline)
     411               
     412             
     413                tag = history[i-1].split('\n')[0]
     414                tag = filter(None,tag.split("("))[1]
     415                tag = tag.replace(")","")
     416
     417                self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setText(tag)
     418                self.setup_gui(palmrunline)
     419                self.list_jobname.item(itemint).setSelected(True)   
    331420               
    332421                return
     
    389478                self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True)
    390479                self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(True)
     480                self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
    391481           
    392482            elif ( param[0] == ""):           
     
    396486                self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(False)
    397487                self.group_advanced.setEnabled(False)
     488                self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
    398489                self.delete_commandline("r")
    399490                self.change_commandline("a","remove")
     
    504595                self.button_start.setEnabled(True)
    505596                self.action_save.setEnabled(True)
     597                self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
    506598
    507599        # Change in any other parameter
     
    528620    ###################################################################################
    529621    def change_lineinput(self):
    530         if ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit, "line_host") ):
    531             tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_host").text()
    532             self.change_commandline("c",tmptext)
     622        if ( self.sender() == self.group_execution.findChild(QtGui.QComboBox, "combo_configuration") ):
     623            tmptext = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText()
     624            if tmptext.isEmpty():
     625               self.change_commandline("c"," ")
     626               self.group_execution.findChild(QtGui.QPushButton,'button_palmbuild').setEnabled(False)
     627            else:
     628               self.change_commandline("c",tmptext)
     629               self.group_execution.findChild(QtGui.QPushButton,'button_palmbuild').setEnabled(True)         
    533630
    534631        elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_q")):
     
    819916               
    820917            elif ( parameter == "c"):
    821                 self.group_execution.findChild(QtGui.QLineEdit,"line_host").setText(options)
    822              
     918                tmpindex = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").findText(options,QtCore.Qt.MatchExactly)
     919                if tmpindex != -1:
     920                   self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").setCurrentIndex(tmpindex)
     921                else:
     922                   self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").setCurrentIndex(0)
    823923            elif ( parameter == "q"):
    824924                self.group_execution.findChild(QtGui.QLineEdit,"line_q").setText(options)
     
    9751075            self.group_advanced.setEnabled(False)
    9761076            self.check_advanced.setEnabled(False)
     1077            self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(False)
    9771078         
    9781079        else:
     
    9821083            self.group_execution.findChild(QtGui.QComboBox, "drop_job").setEnabled(True)
    9831084            self.group_advanced.setEnabled(True)
     1085            self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
    9841086         
    9851087        self.tabWidget.setCurrentIndex(0)
     
    10531155       
    10541156       list_of_files = os.listdir(job_dir)
    1055              
     1157     
     1158
    10561159       for i in range(0,len(list_of_files)):
    10571160          tmp_file = job_dir + "/" + list_of_files[i]
    10581161
    10591162          if ( os.path.isdir(tmp_file) ):
    1060              self.list_jobs.addItem(str(list_of_files[i]))
     1163             self.list_jobs.addItem(str(list_of_files[i]))
     1164       
    10611165
    10621166
     
    13101414        selection = self.list_output.selectedItems()
    13111415       
    1312         print("test")
    13131416        if ( len(selection) != 0 ):
    13141417
Note: See TracChangeset for help on using the changeset viewer.