Index: palm/trunk/SCRIPTS/palmrungui
===================================================================
--- palm/trunk/SCRIPTS/palmrungui	(revision 4405)
+++ palm/trunk/SCRIPTS/palmrungui	(revision 4411)
@@ -25,4 +25,8 @@
 # -----------------
 # $Id$
+# Added new features: individual tag for submitted runs, automatic finding of
+# configuration, start of palmbuild from GUI
+# 
+# 4405 2020-02-12 19:11:11Z maronga
 # Major revisions: New layout. Merged with palm job manager (palm_jm).
 # Minor revisions: Misc. bugs fixed.
@@ -127,4 +131,13 @@
         self.load_jobs()
 
+        # look up configuration files and add to combo box
+        
+        self.group_execution.findChild(QtGui.QComboBox,"combo_configuration").addItem("")
+        
+        for files in os.listdir(palm_dir):
+           if files.startswith(".palm.config"):
+              tmpstring = filter(None,files.split(".palm.config."))[0]
+              self.group_execution.findChild(QtGui.QComboBox,"combo_configuration").addItem(tmpstring)
+
         commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline")
         commandline.setText("")
@@ -154,4 +167,5 @@
 
 
+
     
         QtGui.QApplication.processEvents()
@@ -166,5 +180,5 @@
         
         # Check for empty line
-        palmrunline_save = palmrunline;
+        palmrunline_save = palmrunline
         if (userline != ""):
             palmrunline = "%s %s" % (palmrunline,userline)
@@ -174,4 +188,5 @@
         self.tabWidget.setEnabled(False)
         self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False)
+        self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(False)
         self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("wait...")      
         self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmrun in xterm...")        
@@ -195,5 +210,5 @@
         
         mString = "xterm %s" % (palmrunline)
-        palmrun.start(mString);
+        palmrun.start(mString)
     
         if( palmrun.waitForStarted() is False ):
@@ -201,5 +216,5 @@
         
         # Wait until palmrun has finished or wait for 200 minutes
-        palmrun.waitForFinished(3600000);        
+        palmrun.waitForFinished(3600000)        
         
         # Jobs has been submitted or aborted. Continuing...
@@ -207,7 +222,8 @@
         filename = "%s/.palmrungui.history" % (palm_dir)
         tmstamp = strftime("%Y/%m/%d %H:%M")
+        tag = str(self.groupBox.findChild(QtGui.QLineEdit,"line_tag").text())
     
         file = open(filename,"a")
-        s = "%s %s\n" % (tmstamp,history_line)
+        s = "%s %s (%s)\n" % (tmstamp,history_line,tag)
         file.write(s)
         file.close()              
@@ -216,6 +232,7 @@
         self.tabWidget.setEnabled(True)
         self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True)
-        self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("Start palmrun") 
-        self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline_save);
+        self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("palmrun") 
+        self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline_save)
+        self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
         
         # Reload recent jobs
@@ -223,4 +240,52 @@
         
         
+        
+    # starts xterm with palmbuild commandline
+    #######################################
+    def startpalmbuild(self):
+        palmbuildline = 'palmbuild -c ' + str(self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText())
+        
+        # Disable the main window
+        self.tabWidget.setEnabled(False)
+        self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False)
+        self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(False)  
+        self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmbuild in xterm...")        
+        
+        # Wait until all commands have been executed (ugly) ?
+        #for i in range(0,21):
+        #    qApp->processEvents()       
+        
+        # Start xterm as QProcess
+        palmbuild = QProcess()
+        palmbuild.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels
+        palmbuild.setWorkingDirectory(palm_dir)
+    
+        geomet = self.frameGeometry()
+        
+        posx = geomet.x()+geomet.width()
+        posy = geomet.y()
+      
+        s = " -title \"Executing palmbuild...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy)
+        palmbuildline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmbuildline.replace("\"","\'"))
+        
+        mString = "xterm %s" % (palmbuildline)
+        palmbuild.start(mString)
+    
+        if( palmbuild.waitForStarted() is False ):
+            return
+        
+        # Wait until palmbuild has finished or wait for 200 minutes
+        palmbuild.waitForFinished(3600000)        
+        
+          
+        
+        # Enable main window again
+        self.tabWidget.setEnabled(True)
+        self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True)
+        self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
+        
+        # Reload recent jobs
+        self.recent_jobs(50)
+
     # loads recent jobs 
     ######################################
@@ -235,6 +300,7 @@
         history = file.readlines()
         tmphistory = list()
-        file.close();
-        j = 0;
+        tmptag = list()
+        file.close()
+        j = 0
 
         list_jobname = self.group_history.findChild(QtGui.QListWidget,"list_jobname")
@@ -247,4 +313,5 @@
             timestamp = history[i][:16]
             listitem = history[i][17:len(history[i])-1]
+            tagitem = listitem
             matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly)
 
@@ -252,9 +319,19 @@
                 listitem = filter(None,listitem.split(" -r"))[1]
                 listitem = filter(None,listitem.split(" -"))[0]
-                listitem = listitem.replace(" ",""); 
-                list_jobname.addItem(listitem);
-                s = "%s (%s)" % (listitem,timestamp)
-                tmphistory.append(s);
+                listitem = listitem.replace(" ","") 
+                list_jobname.addItem(listitem)
+                s = "%s: %s" % (timestamp,listitem)
+                tmphistory.append(s)
+                
+                
+                tagitem = filter(None,tagitem.split(" ("))[1]
+                tagitem = tagitem.replace(")","")  
+                if ( len(tagitem) == 0 ): 
+                   s = "Tag: empty"
+                else:
+                   s = "Tag: %s" % (tagitem)                
+                tmptag.append(s)
                 count = count +1
+
                 j = j+1
                 
@@ -264,9 +341,10 @@
             
         # Send to list
-        list_jobname.clear();
+        list_jobname.clear()
         
         i=0
         while i<len(tmphistory):
-            list_jobname.addItem(tmphistory[i]);
+            list_jobname.addItem(tmphistory[i])
+            list_jobname.item(i).setToolTip(tmptag[i])
             i = i+1
             
@@ -291,7 +369,7 @@
         filename = str(list_jobname.currentItem().text())
             
-        timestamp = filename[len(filename)-17:][:16]
-        jobname = filename[:len(filename) - 19];
-        
+        timestamp = filename[:16]
+        jobname = filename[18:]
+                
         itemint = list_jobname.currentRow()
 
@@ -301,10 +379,13 @@
     
         # Set selected item to jobname
-        list_jobname.item(itemint).setSelected(True);
+        list_jobname.item(itemint).setSelected(True)
     
         # Set selected item to jobname in "available jobs" list
         item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive)
-        self.list_jobs.setCurrentItem(item2int[0])
+        
+        if ( item2int != [] ):
+           self.list_jobs.setCurrentItem(item2int[0])
         self.update_input()
+           
     
         fileDir = "%s/.palmrungui.history" % (palm_dir)
@@ -312,5 +393,5 @@
         history = file.readlines()
         tmphistory = list()
-        file.close();        
+        file.close()        
     
         i = len(history)
@@ -319,5 +400,5 @@
             listitem = filter(None,listitem.split(" -r"))[1]
             listitem = filter(None,listitem.split(" -"))[0]
-            listitem = listitem.replace(" ","");                
+            listitem = listitem.replace(" ","")  
 
             # Select command line with correct timestamp and jobname
@@ -326,7 +407,15 @@
                 palmrunline = palmrunline[17:]
                 palmrunline = palmrunline[:len(palmrunline)-1]
-                self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline);
-                self.setup_gui(palmrunline);
-                self.list_jobname.item(itemint).setSelected(True);    
+                palmrunline = filter(None,palmrunline.split("("))[0]
+                self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline)
+                
+              
+                tag = history[i-1].split('\n')[0]
+                tag = filter(None,tag.split("("))[1]
+                tag = tag.replace(")","")
+
+                self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setText(tag)
+                self.setup_gui(palmrunline)
+                self.list_jobname.item(itemint).setSelected(True)    
                 
                 return
@@ -389,4 +478,5 @@
                 self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) 
                 self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(True)
+                self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
             
             elif ( param[0] == ""):            
@@ -396,4 +486,5 @@
                 self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(False)
                 self.group_advanced.setEnabled(False)
+                self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
                 self.delete_commandline("r")
                 self.change_commandline("a","remove")
@@ -504,4 +595,5 @@
                 self.button_start.setEnabled(True)
                 self.action_save.setEnabled(True)
+                self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
 
         # Change in any other parameter
@@ -528,7 +620,12 @@
     ###################################################################################
     def change_lineinput(self):
-        if ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit, "line_host") ):
-            tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_host").text()
-            self.change_commandline("c",tmptext)
+        if ( self.sender() == self.group_execution.findChild(QtGui.QComboBox, "combo_configuration") ):
+            tmptext = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText()
+            if tmptext.isEmpty():
+               self.change_commandline("c"," ")
+               self.group_execution.findChild(QtGui.QPushButton,'button_palmbuild').setEnabled(False)
+            else:
+               self.change_commandline("c",tmptext)
+               self.group_execution.findChild(QtGui.QPushButton,'button_palmbuild').setEnabled(True)          
 
         elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_q")):
@@ -819,6 +916,9 @@
                 
             elif ( parameter == "c"):
-                self.group_execution.findChild(QtGui.QLineEdit,"line_host").setText(options) 
-             
+                tmpindex = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").findText(options,QtCore.Qt.MatchExactly)
+                if tmpindex != -1: 
+                   self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").setCurrentIndex(tmpindex)
+                else:
+                   self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").setCurrentIndex(0)
             elif ( parameter == "q"):
                 self.group_execution.findChild(QtGui.QLineEdit,"line_q").setText(options) 
@@ -975,4 +1075,5 @@
             self.group_advanced.setEnabled(False) 
             self.check_advanced.setEnabled(False) 
+            self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(False)
          
         else:
@@ -982,4 +1083,5 @@
             self.group_execution.findChild(QtGui.QComboBox, "drop_job").setEnabled(True) 
             self.group_advanced.setEnabled(True) 
+            self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
          
         self.tabWidget.setCurrentIndex(0)
@@ -1053,10 +1155,12 @@
        
        list_of_files = os.listdir(job_dir)
-             
+      
+
        for i in range(0,len(list_of_files)):
           tmp_file = job_dir + "/" + list_of_files[i]
 
           if ( os.path.isdir(tmp_file) ):
-	     self.list_jobs.addItem(str(list_of_files[i]))
+             self.list_jobs.addItem(str(list_of_files[i]))
+       
 
 
@@ -1310,5 +1414,4 @@
         selection = self.list_output.selectedItems()
         
-        print("test")
         if ( len(selection) != 0 ):
 
