Changeset 1751
- Timestamp:
- Feb 15, 2016 7:44:16 AM (9 years ago)
- Location:
- palm/trunk/SCRIPTS
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/palm_wd
r1619 r1751 20 20 # Current revisions: 21 21 # ----------------- 22 # 22 # Bugfixes: runs on multiple hosts caused crash of the watchdog. Progress bar 23 # occasionally showed wrong progress. 24 # New: Hosts can be switched on/off and update_frequency can be modified via 25 # File->Options. Security check for cancelation of jobs. 23 26 # 24 27 # Former revisions: … … 69 72 import time 70 73 74 global update_frequency 75 71 76 # Determine PALM directories 72 77 try: … … 99 104 100 105 if ( description_tmp != 'Settings' ): 101 description.append(description_tmp) 102 hostname.append(config.get(description_tmp, 'hostname')) 103 username.append(config.get(description_tmp, 'username')) 106 107 if ( config.get(description_tmp, 'enabled') == 'true' ): 108 description.append(description_tmp) 109 hostname.append(config.get(description_tmp, 'hostname')) 110 username.append(config.get(description_tmp, 'username')) 104 111 else: 105 112 update_frequency = int(config.get(description_tmp, 'update_frequency'))*60000 … … 123 130 job_data_list = [] 124 131 132 # Message box for showing RUN_CONTROL output 125 133 class MessageBoxScroll(QtGui.QMessageBox): 126 134 def __init__(self): … … 149 157 150 158 return result 159 160 161 # Message box for showing RUN_CONTROL output 162 class OptionBox(QtGui.QDialog): 163 def __init__(self): 164 165 super(OptionBox, self).__init__() 166 167 uic.loadUi(palm_bin + '/palm_wd_files/wdoptions.ui', self) 168 169 hostname = [] 170 self.checkbox = [] 171 j = -1 172 ypos = 0 173 174 self.vbox = QtGui.QVBoxLayout(self) 175 self.vbox.setSpacing(0) 176 self.vbox.setMargin(0) 177 178 config.read(palm_dir + '/.wd.config') 179 180 for i in range(0,len(config.sections())): 181 182 description_tmp = config.sections()[i] 183 184 if ( description_tmp != 'Settings' ): 185 description.append(description_tmp) 186 hostname.append(config.get(description_tmp, 'hostname')) 187 188 j = j + 1 189 self.checkbox.append(j) 190 self.checkbox[j] = QtGui.QCheckBox(description_tmp, self) 191 ypos = ypos + 20 192 self.checkbox[j].move(10,0) 193 if ( config.get(description_tmp, 'enabled') == 'true' ): 194 self.checkbox[j].toggle() 195 196 self.vbox.addWidget(self.checkbox[j]) 197 else: 198 self.update_spin.setValue(int(config.get(description_tmp, 'update_frequency'))) 199 200 self.hostBox.setLayout(self.vbox) 201 self.hostBox.setGeometry(0, 0, 272, 50+ypos) 202 self.settingBox.setGeometry(281, 0, 214, 50+ypos) 203 self.ok.setGeometry(385, 50+ypos, 111, 24) 204 self.cancel.setGeometry(270, 50+ypos, 111, 24) 205 206 self.setGeometry(0, 0, 500, 80+ypos) 207 self.show() 208 209 return 210 211 # save updtes to file 212 def SaveAndClose(self): 213 214 for i in range(0,len(self.checkbox)): 215 216 if ( self.checkbox[i].checkState() == 0 ): 217 config.set(str(self.checkbox[i].text()),'enabled','false') 218 else: 219 config.set(str(self.checkbox[i].text()),'enabled','true') 220 221 config.set('Settings','update_frequency',self.update_spin.text()) 222 223 with open(palm_dir + '/.wd.config', 'wb') as configfile: 224 config.write(configfile) 225 226 227 self.close() 228 229 return 230 151 231 152 232 … … 273 353 274 354 # Use global variables 275 global jobs_save276 355 global pbars 356 global update_frequency 277 357 278 358 # Deactivate timer processes until update is finished … … 317 397 job_data = [] 318 398 job_data_n = [] 319 job_data_old = []320 job_data_old_n = []321 399 job_progress = 0 322 400 … … 353 431 result = file2.readlines() 354 432 file2.close() 355 433 434 job_data_old = [] 435 job_data_old_n = [] 436 k = -1 356 437 for j in range(0,len(result)): 357 438 if ( result[j].split()[1] == description[h] ): 358 job_data_old.append(j)359 job_data_old[j] = result[j].split(" ")360 job_data_old[ j] = filter(None, job_data_old[j])361 job_data_old[ j] = [line.rstrip('\n') for line in job_data_old[j]]362 363 job_data_old_n.append( j)364 job_data_old_n[ j] = job_data_old[j][6]439 k = k + 1 440 job_data_old.append(k) 441 job_data_old[k] = result[j].split(" ") 442 job_data_old[k] = filter(None, job_data_old[k]) 443 job_data_old[k] = [line.rstrip('\n') for line in job_data_old[k]] 444 job_data_old_n.append(k) 445 job_data_old_n[k] = job_data_old[k][6] 365 446 366 447 # Merge the job_data and job_data_old to find completed, new and … … 410 491 # Apply a color depending on the status of the job 411 492 if ( job_data[to_display[j]][3] == "Running" ): 412 self.table.setCellWidget(i,4,pbars[ j])493 self.table.setCellWidget(i,4,pbars[i]) 413 494 self.table.item(i,0).setBackground(QtGui.QColor(255, 251, 168)) 414 495 self.table.item(i,1).setBackground(QtGui.QColor(255, 251, 168)) … … 419 500 else: 420 501 pbars[j].setEnabled(False) 421 self.table.setCellWidget(i,4,pbars[ j])502 self.table.setCellWidget(i,4,pbars[i]) 422 503 self.table.item(i,0).setBackground(QtGui.QColor(255, 112, 118)) 423 504 self.table.item(i,1).setBackground(QtGui.QColor(255, 112, 118)) … … 549 630 del(jobs_new) 550 631 del(result) 551 632 del(job_data_old) 633 del(job_data_old_n) 634 552 635 file.close() 553 636 … … 564 647 self.label2.setText("Last update: " + timestamp) 565 648 self.label.setText("Update complete.") 566 self.timetimer.restart() 567 self.timer.start() 568 self.labeltimer.start() 649 self.timetimer.start() 650 self.timer.start(update_frequency) 651 self.labeltimer.start(update_frequency/10) 652 self.UpdateLabel() 569 653 QtGui.QApplication.processEvents() 570 654 … … 577 661 # Check description of job in order to login on the correct host 578 662 descr = self.table.item(self.table.currentRow(),1).text() 579 for h in range(0,len(description)): 580 if ( descr == description[h] ): 581 host = username[h] + "@" + hostname[h] 582 583 ssh = sub.Popen(["ssh", "%s" % host, "/sw/tools/python/2.7.6/generic/bin/python palm_wdd cancel " + jobname], 584 shell=False, 585 stdout=sub.PIPE, 586 stderr=sub.PIPE) 587 result = ssh.stdout.readlines() 588 result = filter(None, result) 589 590 # In case of error display a warning message 591 if ( len(result) == 0 ): 592 error = ssh.stderr.readlines() 593 notify = QtGui.QMessageBox.warning(self,'Cancel job',"Error. Could not cancel job " + jobname + ".\n\nError message:\n" + ''.join(error)) 594 595 # Otherwise inform the user and mark the job in the table 596 else: 597 self.table.setItem(self.table.currentRow(),3,QtGui.QTableWidgetItem("Canceled")) 598 notify = QtGui.QMessageBox.information(self,'Cancel job',"Job" + jobname + " canceled!\n\nServer message:\n" + ''.join(result)) 663 664 querybox = QtGui.QMessageBox() 665 querybox.setText("Attention!\nYou are trying to cancel a job. It will not be able to terminate properly.") 666 querybox.setInformativeText("Do you really want to cancel " + jobname + " on host " + descr + "?") 667 querybox.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 668 querybox.setDefaultButton(QtGui.QMessageBox.No) 669 returnvalue = querybox.exec_() 670 671 if ( returnvalue == QtGui.QMessageBox.Yes ): 672 673 for h in range(0,len(description)): 674 if ( descr == description[h] ): 675 host = username[h] + "@" + hostname[h] 676 677 ssh = sub.Popen(["ssh", "%s" % host, "/sw/tools/python/2.7.6/generic/bin/python palm_wdd cancel " + jobname], 678 shell=False, 679 stdout=sub.PIPE, 680 stderr=sub.PIPE) 681 result = ssh.stdout.readlines() 682 result = filter(None, result) 683 684 # In case of error display a warning message 685 if ( len(result) == 0 ): 686 error = ssh.stderr.readlines() 687 notify = QtGui.QMessageBox.warning(self,'Cancel job',"Error. Could not cancel job " + jobname + ".\n\nError message:\n" + ''.join(error)) 688 689 # Otherwise inform the user and mark the job in the table 690 else: 691 self.table.setItem(self.table.currentRow(),3,QtGui.QTableWidgetItem("Canceled")) 692 notify = QtGui.QMessageBox.information(self,'Cancel job',"Job" + jobname + " canceled!\n\nServer message:\n" + ''.join(result)) 599 693 600 694 … … 650 744 else: 651 745 self.table.setItem(self.table.currentRow(),3,QtGui.QTableWidgetItem("Terminated")) 652 notify = QtGui.QMessageBox.information(self,'Terminat ie job',"Termination of job " + jobname + " was initiated!\n\nServer message:\n" + ''.join(result))746 notify = QtGui.QMessageBox.information(self,'Terminate job',"Termination of job " + jobname + " was initiated!\n\nServer message:\n" + ''.join(result)) 653 747 654 748 … … 810 904 811 905 906 # Enter Options menu 907 def Options(self): 908 909 # disable mainwindow 910 self.setEnabled(False) 911 912 # show Options Dialog 913 opt = OptionBox() 914 opt.exec_() 915 916 self.UpdateHosts() 917 self.setEnabled(True) 918 919 # Update settings 920 def UpdateHosts(self): 921 922 global update_frequency 923 description = [] 924 hostname = [] 925 username = [] 926 927 for i in range(0,len(config.sections())): 928 929 description_tmp = config.sections()[i] 930 931 if ( description_tmp != 'Settings' ): 932 933 if ( config.get(description_tmp, 'enabled') == 'true' ): 934 description.append(description_tmp) 935 hostname.append(config.get(description_tmp, 'hostname')) 936 username.append(config.get(description_tmp, 'username')) 937 else: 938 update_frequency = int(config.get(description_tmp, 'update_frequency'))*60000 939 940 812 941 # Main loop 813 942 def main(): -
palm/trunk/SCRIPTS/palm_wd_files/.wd.config.default
r1618 r1751 3 3 4 4 [<Replace_by_your_description_of_hostname_1>] 5 hostname=<replace_by_the_remote_hostname> 6 username=<replace_by_your_remote_username> 5 enabled=true 6 hostname=<replace_by_the_remote_hostname_1> 7 username=<replace_by_your_remote_username_1> 7 8 8 [<Replace_by_your_description_of_hostname_1>] 9 hostname=<replace_by_the_remote_hostname> 10 username=<replace_by_your_remote_username> 9 [<Replace_by_your_description_of_hostname_2>] 10 enabled=true 11 hostname=<replace_by_the_remote_hostname_2> 12 username=<replace_by_your_remote_username_2> 11 13 12 14 [Settings] -
palm/trunk/SCRIPTS/palm_wd_files/.wd.config.hlrnIII
r1618 r1751 4 4 5 5 [Hannover] 6 enabled=true 6 7 hostname=hlogin.hlrn.de 7 8 username=<replace_by_your_remote_username> 8 9 9 10 [Berlin] 11 enabled=true 10 12 hostname=blogin.hlrn.de 11 13 username=<replace_by_your_remote_username>
Note: See TracChangeset
for help on using the changeset viewer.