Index: palm/trunk/SCRIPTS/palm_wd
===================================================================
--- palm/trunk/SCRIPTS/palm_wd	(revision 1750)
+++ palm/trunk/SCRIPTS/palm_wd	(revision 1751)
@@ -20,5 +20,8 @@
 # Current revisions:
 # -----------------
-# 
+# Bugfixes: runs on multiple hosts caused crash of the watchdog. Progress bar
+# occasionally showed wrong progress.
+# New: Hosts can be switched on/off and update_frequency can be modified via 
+# File->Options. Security check for cancelation of jobs.
 # 
 # Former revisions:
@@ -69,4 +72,6 @@
 import time
 
+global update_frequency
+
 # Determine PALM directories
 try: 
@@ -99,7 +104,9 @@
  
     if ( description_tmp != 'Settings' ):
-       description.append(description_tmp)
-       hostname.append(config.get(description_tmp, 'hostname'))
-       username.append(config.get(description_tmp, 'username')) 
+      
+       if ( config.get(description_tmp, 'enabled') == 'true' ):
+          description.append(description_tmp)
+          hostname.append(config.get(description_tmp, 'hostname'))
+          username.append(config.get(description_tmp, 'username')) 
     else:
        update_frequency = int(config.get(description_tmp, 'update_frequency'))*60000
@@ -123,4 +130,5 @@
 job_data_list = []
 
+# Message box for showing RUN_CONTROL output
 class MessageBoxScroll(QtGui.QMessageBox):
     def __init__(self):
@@ -149,4 +157,76 @@
 
         return result
+
+
+# Message box for showing RUN_CONTROL output
+class OptionBox(QtGui.QDialog):
+    def __init__(self):
+      
+        super(OptionBox, self).__init__()
+      
+        uic.loadUi(palm_bin + '/palm_wd_files/wdoptions.ui', self)
+        
+        hostname = []
+        self.checkbox = []
+        j = -1
+        ypos = 0
+   
+        self.vbox = QtGui.QVBoxLayout(self)
+        self.vbox.setSpacing(0)
+        self.vbox.setMargin(0)       
+    
+        config.read(palm_dir + '/.wd.config')
+    
+        for i in range(0,len(config.sections())):
+
+           description_tmp = config.sections()[i]
+ 
+           if ( description_tmp != 'Settings' ):
+              description.append(description_tmp)
+              hostname.append(config.get(description_tmp, 'hostname'))
+              
+              j = j + 1
+              self.checkbox.append(j)
+              self.checkbox[j] = QtGui.QCheckBox(description_tmp, self)   
+              ypos = ypos + 20
+              self.checkbox[j].move(10,0)
+              if ( config.get(description_tmp, 'enabled') == 'true' ):
+                 self.checkbox[j].toggle()
+                       
+              self.vbox.addWidget(self.checkbox[j])
+           else:
+	      self.update_spin.setValue(int(config.get(description_tmp, 'update_frequency')))
+     
+        self.hostBox.setLayout(self.vbox)
+        self.hostBox.setGeometry(0, 0, 272, 50+ypos)
+        self.settingBox.setGeometry(281, 0, 214, 50+ypos)
+        self.ok.setGeometry(385, 50+ypos, 111, 24)
+        self.cancel.setGeometry(270, 50+ypos, 111, 24)
+        
+        self.setGeometry(0, 0, 500, 80+ypos)
+        self.show()
+        
+        return
+
+#   save updtes to file
+    def SaveAndClose(self):
+      
+       for i in range(0,len(self.checkbox)):
+          
+          if ( self.checkbox[i].checkState() == 0 ):
+	     config.set(str(self.checkbox[i].text()),'enabled','false')
+	  else:
+	     config.set(str(self.checkbox[i].text()),'enabled','true')       
+       
+       config.set('Settings','update_frequency',self.update_spin.text())  
+
+       with open(palm_dir + '/.wd.config', 'wb') as configfile:
+          config.write(configfile)
+
+
+       self.close()
+     
+       return
+
 
 
@@ -273,6 +353,6 @@
       
         # Use global variables
-        global jobs_save
         global pbars
+        global update_frequency
 
         # Deactivate timer processes until update is finished
@@ -317,6 +397,4 @@
             job_data = []
             job_data_n = []    
-	    job_data_old = []
-	    job_data_old_n = []
 	    job_progress = 0
 
@@ -353,14 +431,17 @@
 	    result = file2.readlines()
 	    file2.close()
-	    
+
+	    job_data_old = []
+	    job_data_old_n = []
+            k = -1
             for j in range(0,len(result)):
 	        if ( result[j].split()[1] == description[h] ):
-		    job_data_old.append(j)
-                    job_data_old[j] = result[j].split(" ")
-                    job_data_old[j] = filter(None, job_data_old[j])
-                    job_data_old[j] = [line.rstrip('\n') for line in job_data_old[j]]
-                
-                    job_data_old_n.append(j)
-                    job_data_old_n[j] = job_data_old[j][6]
+		    k = k + 1
+		    job_data_old.append(k)
+                    job_data_old[k] = result[j].split(" ")
+                    job_data_old[k] = filter(None, job_data_old[k])
+                    job_data_old[k] = [line.rstrip('\n') for line in job_data_old[k]]
+                    job_data_old_n.append(k)
+                    job_data_old_n[k] = job_data_old[k][6]
 
             # Merge the job_data and job_data_old to find completed, new and
@@ -410,5 +491,5 @@
                 # Apply a color depending on the status of the job
                 if ( job_data[to_display[j]][3] == "Running" ):
-                    self.table.setCellWidget(i,4,pbars[j]) 
+                    self.table.setCellWidget(i,4,pbars[i]) 
 		    self.table.item(i,0).setBackground(QtGui.QColor(255, 251, 168))
 		    self.table.item(i,1).setBackground(QtGui.QColor(255, 251, 168))
@@ -419,5 +500,5 @@
                 else:
 		    pbars[j].setEnabled(False)
-		    self.table.setCellWidget(i,4,pbars[j])
+		    self.table.setCellWidget(i,4,pbars[i])
                     self.table.item(i,0).setBackground(QtGui.QColor(255, 112, 118))
                     self.table.item(i,1).setBackground(QtGui.QColor(255, 112, 118))
@@ -549,5 +630,7 @@
             del(jobs_new)
             del(result)
-
+            del(job_data_old)
+            del(job_data_old_n)
+            
         file.close()
 
@@ -564,7 +647,8 @@
         self.label2.setText("Last update: " + timestamp)
         self.label.setText("Update complete.")
-        self.timetimer.restart()
-        self.timer.start()
-        self.labeltimer.start()
+        self.timetimer.start()
+        self.timer.start(update_frequency)
+        self.labeltimer.start(update_frequency/10)
+        self.UpdateLabel()
         QtGui.QApplication.processEvents()
        
@@ -577,24 +661,34 @@
         # Check description of job in order to login on the correct host
         descr = self.table.item(self.table.currentRow(),1).text()
-        for h in range(0,len(description)):
-	    if ( descr == description[h] ):
-                host = username[h] + "@" + hostname[h]
-
-        ssh = sub.Popen(["ssh", "%s" % host, "/sw/tools/python/2.7.6/generic/bin/python palm_wdd cancel " + jobname],
-                           shell=False,
-                           stdout=sub.PIPE,
-                           stderr=sub.PIPE)
-        result = ssh.stdout.readlines()
-        result = filter(None, result)
-        
-        # In case of error display a warning message
-        if ( len(result) == 0 ):
-            error = ssh.stderr.readlines()
-            notify = QtGui.QMessageBox.warning(self,'Cancel job',"Error. Could not cancel job " + jobname + ".\n\nError message:\n" + ''.join(error))
-
-        # Otherwise inform the user and mark the job in the table
-        else:
-	    self.table.setItem(self.table.currentRow(),3,QtGui.QTableWidgetItem("Canceled"))
-            notify = QtGui.QMessageBox.information(self,'Cancel job',"Job" + jobname + " canceled!\n\nServer message:\n" + ''.join(result))
+        
+        querybox = QtGui.QMessageBox()
+        querybox.setText("Attention!\nYou are trying to cancel a job. It will not be able to terminate properly.")
+        querybox.setInformativeText("Do you really want to cancel " + jobname + " on host " + descr + "?")
+        querybox.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+        querybox.setDefaultButton(QtGui.QMessageBox.No)
+        returnvalue = querybox.exec_()
+       
+        if ( returnvalue == QtGui.QMessageBox.Yes ):
+        
+           for h in range(0,len(description)):
+	       if ( descr == description[h] ):
+                  host = username[h] + "@" + hostname[h]
+
+           ssh = sub.Popen(["ssh", "%s" % host, "/sw/tools/python/2.7.6/generic/bin/python palm_wdd cancel " + jobname],
+                              shell=False,
+                              stdout=sub.PIPE,
+                              stderr=sub.PIPE)
+           result = ssh.stdout.readlines()
+           result = filter(None, result)
+        
+           # In case of error display a warning message
+           if ( len(result) == 0 ):
+               error = ssh.stderr.readlines()
+               notify = QtGui.QMessageBox.warning(self,'Cancel job',"Error. Could not cancel job " + jobname + ".\n\nError message:\n" + ''.join(error))
+
+           # Otherwise inform the user and mark the job in the table
+           else:
+	       self.table.setItem(self.table.currentRow(),3,QtGui.QTableWidgetItem("Canceled"))
+               notify = QtGui.QMessageBox.information(self,'Cancel job',"Job" + jobname + " canceled!\n\nServer message:\n" + ''.join(result))
 
 
@@ -650,5 +744,5 @@
         else:
 	    self.table.setItem(self.table.currentRow(),3,QtGui.QTableWidgetItem("Terminated"))
-            notify = QtGui.QMessageBox.information(self,'Terminatie job',"Termination of job " + jobname + " was initiated!\n\nServer message:\n" + ''.join(result))
+            notify = QtGui.QMessageBox.information(self,'Terminate job',"Termination of job " + jobname + " was initiated!\n\nServer message:\n" + ''.join(result))
 
 
@@ -810,4 +904,39 @@
         
 
+    # Enter Options menu
+    def Options(self):
+  
+#       disable mainwindow  
+        self.setEnabled(False)
+      
+#       show Options Dialog      
+        opt = OptionBox()
+        opt.exec_()
+
+        self.UpdateHosts()
+        self.setEnabled(True)
+
+# Update settings
+    def UpdateHosts(self):
+
+       global update_frequency
+       description = []
+       hostname = []
+       username = []
+
+       for i in range(0,len(config.sections())):
+
+          description_tmp = config.sections()[i]
+ 
+          if ( description_tmp != 'Settings' ):
+      
+             if ( config.get(description_tmp, 'enabled') == 'true' ):
+                description.append(description_tmp)
+                hostname.append(config.get(description_tmp, 'hostname'))
+                username.append(config.get(description_tmp, 'username')) 
+          else:
+             update_frequency = int(config.get(description_tmp, 'update_frequency'))*60000
+
+
 # Main loop       
 def main():
Index: palm/trunk/SCRIPTS/palm_wd_files/.wd.config.default
===================================================================
--- palm/trunk/SCRIPTS/palm_wd_files/.wd.config.default	(revision 1750)
+++ palm/trunk/SCRIPTS/palm_wd_files/.wd.config.default	(revision 1751)
@@ -3,10 +3,12 @@
 
 [<Replace_by_your_description_of_hostname_1>]
-hostname=<replace_by_the_remote_hostname>
-username=<replace_by_your_remote_username>
+enabled=true
+hostname=<replace_by_the_remote_hostname_1>
+username=<replace_by_your_remote_username_1>
 
-[<Replace_by_your_description_of_hostname_1>]
-hostname=<replace_by_the_remote_hostname>
-username=<replace_by_your_remote_username>
+[<Replace_by_your_description_of_hostname_2>]
+enabled=true
+hostname=<replace_by_the_remote_hostname_2>
+username=<replace_by_your_remote_username_2>
 
 [Settings]
Index: palm/trunk/SCRIPTS/palm_wd_files/.wd.config.hlrnIII
===================================================================
--- palm/trunk/SCRIPTS/palm_wd_files/.wd.config.hlrnIII	(revision 1750)
+++ palm/trunk/SCRIPTS/palm_wd_files/.wd.config.hlrnIII	(revision 1751)
@@ -4,8 +4,10 @@
 
 [Hannover]
+enabled=true
 hostname=hlogin.hlrn.de
 username=<replace_by_your_remote_username>
 
 [Berlin]
+enabled=true
 hostname=blogin.hlrn.de
 username=<replace_by_your_remote_username>
Index: palm/trunk/SCRIPTS/palm_wd_files/wdoptions.ui
===================================================================
--- palm/trunk/SCRIPTS/palm_wd_files/wdoptions.ui	(revision 1751)
+++ palm/trunk/SCRIPTS/palm_wd_files/wdoptions.ui	(revision 1751)
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Options</class>
+ <widget class="QDialog" name="Options">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>500</width>
+    <height>112</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+    <horstretch>0</horstretch>
+    <verstretch>1</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle">
+   <string>Watchdog Options</string>
+  </property>
+  <widget class="QPushButton" name="ok">
+   <property name="geometry">
+    <rect>
+     <x>385</x>
+     <y>85</y>
+     <width>111</width>
+     <height>24</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Save and Quit</string>
+   </property>
+  </widget>
+  <widget class="QGroupBox" name="hostBox">
+   <property name="geometry">
+    <rect>
+     <x>7</x>
+     <y>8</y>
+     <width>272</width>
+     <height>83</height>
+    </rect>
+   </property>
+   <property name="sizePolicy">
+    <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+     <horstretch>0</horstretch>
+     <verstretch>0</verstretch>
+    </sizepolicy>
+   </property>
+   <property name="title">
+    <string>Active Hosts</string>
+   </property>
+   <property name="flat">
+    <bool>false</bool>
+   </property>
+   <property name="checkable">
+    <bool>false</bool>
+   </property>
+  </widget>
+  <widget class="QGroupBox" name="settingBox">
+   <property name="geometry">
+    <rect>
+     <x>281</x>
+     <y>9</y>
+     <width>214</width>
+     <height>77</height>
+    </rect>
+   </property>
+   <property name="title">
+    <string>Settings</string>
+   </property>
+   <property name="flat">
+    <bool>false</bool>
+   </property>
+   <property name="checkable">
+    <bool>false</bool>
+   </property>
+   <widget class="QSpinBox" name="update_spin">
+    <property name="geometry">
+     <rect>
+      <x>155</x>
+      <y>27</y>
+      <width>52</width>
+      <height>23</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>10</x>
+      <y>31</y>
+      <width>148</width>
+      <height>16</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Update frequency (min)</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QPushButton" name="cancel">
+   <property name="geometry">
+    <rect>
+     <x>280</x>
+     <y>85</y>
+     <width>101</width>
+     <height>24</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Cancel</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>ok</sender>
+   <signal>clicked()</signal>
+   <receiver>Options</receiver>
+   <slot>SaveAndClose()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>431</x>
+     <y>96</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>343</x>
+     <y>96</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>cancel</sender>
+   <signal>clicked()</signal>
+   <receiver>Options</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>363</x>
+     <y>89</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>216</x>
+     <y>97</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
