Changeset 4470 for palm/trunk/SCRIPTS/palmrungui
- Timestamp:
- Mar 24, 2020 6:52:19 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/palmrungui
r4428 r4470 25 25 # ----------------- 26 26 # $Id$ 27 # Added file size output, more I/O functionalities, new/removed buttons 28 # 29 # 4428 2020-02-27 11:43:53Z maronga 27 30 # Bugfix for update button 28 31 # … … 96 99 import shutil 97 100 98 101 global update_frequency 102 update_frequency = 5*60000 99 103 100 104 # Determine PALM directories … … 103 107 palm_dir = os.getcwd() 104 108 palm_bin = palm_dir + '/trunk/SCRIPTS' 109 palm_source = palm_dir + '/trunk/SOURCE' 105 110 job_dir = palm_dir + '/JOBS' 106 111 user_dir = palm_dir + '/USER_CODE' … … 113 118 114 119 120 # returns the human readable file size of filename 121 def file_size(filename, suffix='B'): 122 size_raw = os.stat(filename).st_size 123 for unit in [' ',' K',' M',' G',' T']: 124 if abs(size_raw) < 1024.0: 125 return "%i%s%s" % (size_raw, unit, suffix) 126 size_raw /= 1024.0 127 return "%.1f%s%s" % (num, 'Y', suffix) 128 129 130 115 131 palmrunline = "" 116 132 set_list = [] … … 135 151 self.setupUi(self) 136 152 137 self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) 153 self.palm_logo.setPixmap(QtGui.QPixmap(palm_bin + "/palmrungui_files/logo.png")) 154 155 with open(palm_bin + "/palmrungui") as search: 156 for line in search: 157 line = line.rstrip() 158 if "$Id" in line: 159 version = "Version: r" + line.split(" ")[3] + " (" + line.split(" ")[4] + ")" 160 self.groupBox.findChild(QtGui.QLabel,"label_version").setText(version) 161 break 138 162 139 163 self.recent_jobs(50) … … 176 200 177 201 178 179 180 202 QtGui.QApplication.processEvents() 181 203 182 204 183 205 # Start refresh timer. On timeout perform update 206 self.timer = QtCore.QTimer(self) 207 self.timer.timeout.connect(self.update_all) 208 self.timer.setSingleShot(False) 209 self.timer.start(update_frequency) 210 211 # The timetimer counts the time since last update 212 self.timetimer= QtCore.QElapsedTimer() 213 self.timetimer.start() 214 215 # The labeltimer induces the update of the remaining time in the UI 216 self.labeltimer = QtCore.QTimer(self) 217 self.labeltimer.timeout.connect(self.UpdatePush) 218 self.labeltimer.setSingleShot(False) 219 220 # Update in the UI will be performed at each 1/10 of the update interval 221 self.labeltimer.start(update_frequency/10) 222 self.push_update.setText("Update (" + str(int(update_frequency/1000/60)) + " min)") 223 184 224 # starts xterm with palmrun commandline 185 225 ####################################### … … 200 240 self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("wait...") 201 241 self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmrun in xterm...") 202 242 203 243 # Wait until all commands have been executed (ugly) ? 204 244 #for i in range(0,21): 205 245 # qApp->processEvents() 206 246 207 247 # Start xterm as QProcess 208 248 palmrun = QProcess() 209 249 palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels 210 250 palmrun.setWorkingDirectory(palm_dir) 211 251 212 252 geomet = self.frameGeometry() 213 253 214 254 posx = geomet.x()+geomet.width() 215 255 posy = geomet.y() 216 217 s = " -title \"Executing palmrun...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy) 218 palmrunline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'")) 219 256 257 if ( os.path.isfile("palmrungui.log") ): 258 os.remove("palmrungui.log") 259 260 s = " -title \"Executing palmrun...\" -fa \"Monospace\" -l -lf \"palmrungui.log\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy) 261 palmrunline = "%s%s ;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'")) 262 220 263 mString = "xterm %s" % (palmrunline) 221 264 palmrun.start(mString) 222 265 223 266 if( palmrun.waitForStarted() is False ): 224 267 return 225 268 226 269 # Wait until palmrun has finished or wait for 200 minutes 227 270 palmrun.waitForFinished(3600000) 228 271 229 272 # Jobs has been submitted or aborted. Continuing... 230 273 # Save the palmrun command to history file … … 249 292 250 293 251 294 295 # Update the label 296 def UpdatePush(self): 297 remaining_time = (update_frequency - self.timetimer.elapsed()) / 1000 / 60 298 self.push_update.setText("Update (" + str(remaining_time) + " min)") 299 300 252 301 # starts xterm with palmbuild commandline 253 302 ####################################### 254 303 def startpalmbuild(self): 255 304 palmbuildline = 'palmbuild -c ' + str(self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText()) 256 305 306 full_build = self.group_execution.findChild(QtGui.QCheckBox,"check_rebuild").checkState() 307 308 if ( full_build == 2 ): 309 for filename in os.listdir(palm_source): 310 os.utime(palm_source + "/" + filename, None) 311 257 312 palmrunline_save = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()) 258 313 259 314 # Disable the main window 260 315 palmbuildline_save = palmbuildline … … 312 367 else: 313 368 return 314 369 315 370 file = open(fileDir,"r") 316 371 history = file.readlines() … … 330 385 listitem = history[i][17:len(history[i])-1] 331 386 tagitem = listitem 387 configitem = listitem 332 388 matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly) 333 389 334 390 if ( len(matchitems) == 0 ): 335 391 listitem = filter(None,listitem.split(" -r"))[1] 336 listitem = filter(None,listitem.split(" -"))[0] 337 listitem = listitem.replace(" ","") 392 listitem = listitem.strip() 393 listitem = filter(None,listitem.split(" "))[0] 394 listitem = listitem.replace("\"","") 338 395 list_jobname.addItem(listitem) 339 s = "%s: %s" % (timestamp,listitem) 396 397 configitem = filter(None,configitem.split(" -c"))[1] 398 configitem = configitem.strip() 399 configitem = filter(None,configitem.split(" "))[0] 400 configitem = configitem.replace("\"","") 401 402 s = "%s: %s (%s)" % (timestamp,listitem,configitem) 340 403 tmphistory.append(s) 341 404 … … 384 447 list_jobname = self.group_history.findChild(QtGui.QListWidget,"list_jobname") 385 448 filename = str(list_jobname.currentItem().text()) 386 449 387 450 timestamp = filename[:16] 388 jobname = filename[18:] 389 451 jobname = filename[18:].split(" ")[0] 452 390 453 itemint = list_jobname.currentRow() 391 454 … … 415 478 listitem = history[i-1][17:len(history[i-1])-1] 416 479 listitem = filter(None,listitem.split(" -r"))[1] 417 listitem = filter(None,listitem.split(" -"))[0] 418 listitem = listitem.replace(" ","") 480 listitem = listitem.strip() 481 listitem = filter(None,listitem.split(" "))[0] 482 listitem = listitem.replace("\"","") 419 483 420 484 # Select command line with correct timestamp and jobname … … 509 573 else: 510 574 511 # Check if _p3dr file is available, otherwise notice user512 drop_job = self.group_execution.findChild(QtGui.QComboBox,"drop_job").currentText()513 if ( self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() == 2 or514 drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)" ):515 516 jobname = self.group_execution.findChild(QtGui.QLineEdit, "line_jobname").text()517 restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)518 519 if (os.path.exists(restartfile) == True):520 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")521 522 523 if ( drop_job == "Restart run (coupled atmosphere ocean)" ):524 restartfileo = "%s/JOBS/%s/INPUT/%s_p3dor" % (palm_dir,jobname,jobname)525 if (os.path.exists(restartfileo) == True):526 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("hooo")527 528 else:529 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dor file found!</font>")530 531 else:532 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>")533 534 535 536 575 self.group_execution.setEnabled(True) 537 576 self.drop_job.setEnabled(True) … … 577 616 if (status_restarts == 2): 578 617 param[0]="%s restart" % (param[0]) 579 580 # Check if _p3dr file is available, otherwise notice user 581 if (status_restarts == 2): 582 jobname = str(self.group_execution.findChild(QtGui.QLineEdit, "line_jobname").text()) 583 restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname) 584 if (os.path.exists(restartfile) == True): 585 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") 586 587 else: 588 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>") 589 590 else: 591 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") 618 592 619 593 620 status_cycfill = self.group_execution.findChild(QtGui.QCheckBox,"check_cycfill").checkState() … … 831 858 self.load_jobs() 832 859 833 # Safes current commandline and user Parameters to .sav file 834 ################################################################################# 835 def save_to_file(self): 836 user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text() 837 cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text() 838 839 string_to_file = cmd_string 840 if (user_string != ""): 841 string_to_file = "%s%s" % (string_to_file,user_string) 842 843 #filename = QtGui.QInputDialog.getText(self, "Save File naming Dialog", "Insert filename", QtGui.QLineEdit.Normal) 844 filename = str(QtGui.QFileDialog.getSaveFileName(self, "Save File","filename.sav")) 845 extension = ".sav" 846 filename = "%s%s" % (filename, "") 847 tmstamp = strftime("%Y/%m/%d %H:%M") 848 849 file = open(filename,"w") 850 s = "%s %s" % (tmstamp, string_to_file) 851 file.write(s) 852 file.close() 853 860 854 861 # Safes current commandline and user parameters to default file 855 862 ################################################################################ … … 932 939 933 940 elif ( parameter == "c"): 934 tmpindex = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").findText(options ,QtCore.Qt.MatchExactly)941 tmpindex = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").findText(options.strip(),QtCore.Qt.MatchExactly) 935 942 if tmpindex != -1: 936 943 self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").setCurrentIndex(tmpindex) … … 1050 1057 if (options_all == "restart"): 1051 1058 self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").setChecked(True) 1052 # Check if _pdf file is available, otherwise notice user 1053 jobname = str(self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").text()) 1054 1055 restartfile = "%sJOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname) 1056 if (os.path.exists(restartfile) == True): 1057 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") 1058 1059 else: 1060 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file \found!</font>") 1059 1061 1060 j = j+1 1062 1061 … … 1100 1099 self.group_advanced.setEnabled(True) 1101 1100 self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True) 1102 1101 1102 1103 1103 self.tabWidget.setCurrentIndex(0) 1104 1105 # open saved commandline 1106 ################################## 1104 1105 1106 ## Open from history 1107 ################################### 1107 1108 def open_from_file(self): 1108 1109 # Select filename and open it 1110 filename = QtGui.QFileDialog.getOpenFileName(self, "Open File","Save files (*.sav)") 1111 1112 if ( filename != ""): 1113 file = open(filename, "r") 1114 1115 if ( file is not None ): 1116 # File opened successfully 1117 palmrunline = file.read() 1118 file.close() 1119 1120 # In case a palmrunline was found, load it to mainwindow 1121 if ( palmrunline != ""): 1122 palmrunline = palmrunline[17:] 1123 self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) 1124 self.setup_gui(palmrunline) 1125 1126 # open saved commandline 1127 ################################## 1128 def open_last(self): 1129 # Select filename and open it 1130 filename = "%s/.palmrungui.history" % (palm_dir) 1131 1132 if os.path.exists(filename): 1133 pass 1134 else: 1135 return 1136 1137 file = open(filename, "r") 1138 if ( file is not None ): 1139 # File opened successfully 1140 lines = file.readlines() 1141 palmrunline = lines[len(lines)-1] 1142 palmrunline = palmrunline[:len(palmrunline)-1] 1143 file.close() 1144 1145 # In case a palmrunline was found, load it to mainwindow 1146 if ( palmrunline != ""): 1147 palmrunline = palmrunline[17:len(palmrunline)] 1148 self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) 1149 self.setup_gui(palmrunline) 1150 1109 1110 # Show History 1111 opt = OpenHistoryBox() 1112 opt.exec_() 1113 1114 palmrunline = str(history_entry) 1115 palmrunline = palmrunline[17:] 1116 palmrunline = palmrunline[:len(palmrunline)-1] 1117 palmrunline = filter(None,palmrunline.split("("))[0] 1118 self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) 1119 1120 # Set selected item to jobname in "available jobs" list 1121 jobname = str(history_entry[17:]) 1122 jobname = filter(None,jobname.split(" -r"))[1] 1123 jobname = jobname.strip() 1124 jobname = filter(None,jobname.split(" "))[0] 1125 jobname = jobname.replace("\"","") 1126 item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive) 1127 1128 if ( item2int != [] ): 1129 self.list_jobs.setCurrentItem(item2int[0]) 1130 self.update_input() 1131 1132 # Add tooltip tag 1133 tag = str(history_entry).split('\n')[0] 1134 tag = filter(None,tag.split("("))[1] 1135 tag = tag.replace(")","") 1136 self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setText(tag) 1151 1137 1152 1138 # Process palmrungui to set up gui controls 1139 self.setup_gui(palmrunline) 1140 1141 1153 1142 def update_all(self): 1154 1143 … … 1162 1151 self.update_input() 1163 1152 1153 1164 1154 # Load jobs into list 1165 1155 def load_jobs(self): … … 1173 1163 1174 1164 self.list_jobs.clear() 1175 self.push_copy.setEnabled(False)1176 self.push_create_set.setEnabled(False)1177 1178 1165 self.line_path.setText(job_dir + "/") 1179 1166 … … 1197 1184 # Update input and user code lists 1198 1185 def update_input(self): 1186 1187 self.labeltimer.stop() 1188 1199 1189 1200 1190 self.list_input.clear() … … 1202 1192 self.list_monitoring.clear() 1203 1193 self.list_output.clear() 1204 self.push_copy.setEnabled(True)1205 self.push_create_set.setEnabled(True)1206 1194 1207 1195 jobitem = self.list_jobs.currentItem() … … 1219 1207 1220 1208 if ( os.path.isfile(tmp_file) ): 1221 self.list_input.addItem(str(list_of_files[i]) )1209 self.list_input.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") 1222 1210 1223 1211 job_to_show = job_dir + "/" + jobitem.text() + "/USER_CODE" … … 1243 1231 1244 1232 if ( os.path.isfile(tmp_file) ): 1245 self.list_monitoring.addItem(str(list_of_files[i]) )1233 self.list_monitoring.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") 1246 1234 1247 1235 job_to_show = job_dir + "/" + jobitem.text() + "/OUTPUT" 1248 1236 1249 1237 if ( os.path.isdir(job_to_show) ): 1250 1238 1251 1239 list_of_files = os.listdir(job_to_show) 1252 1240 1253 1241 for i in range(0,len(list_of_files)): 1254 1242 tmp_file = job_to_show + "/" + list_of_files[i] 1255 1243 1256 1244 if ( os.path.isfile(tmp_file) ): 1257 self.list_output.addItem(str(list_of_files[i]) )1245 self.list_output.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") 1258 1246 1259 1247 self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").setText(jobitem.text()) 1260 1248 self.group_history.findChild(QtGui.QListWidget,"list_jobname").clearSelection() 1261 1249 1250 self.timetimer.start() 1251 self.timer.start(update_frequency) 1252 self.labeltimer.start(update_frequency/10) 1253 self.push_update.setText("Update (" + str(int(update_frequency/1000/60)) + " min)") 1254 QtGui.QApplication.processEvents() 1255 1262 1256 # Change palmrunline accordingly 1263 1257 self.change_commandline("r","") 1264 self.change_commandline("a","") 1265 1266 1258 self.change_commandline("a","") 1259 1267 1260 # Make a copy of a job 1268 1261 def copy_job(self): … … 1412 1405 self.setEnabled(True) 1413 1406 set_list = [] 1414 1407 1408 1409 # Add a custom context menu for the job selection list 1410 def openmenujob(self, position): 1411 1412 menu = QtGui.QMenu() 1413 1414 selection = self.list_jobs.selectedItems() 1415 1416 if ( len(selection) != 0 ): 1417 1418 copyAction = QtGui.QAction('Copy job', self) 1419 copyAction.triggered.connect(self.copy_job) 1420 createAction = QtGui.QAction('Create set from job', self) 1421 createAction.triggered.connect(self.create_set) 1422 delAction = QtGui.QAction('Delete job', self) 1423 delAction.triggered.connect(self.DeleteJob) 1424 1425 menu.addAction(copyAction) 1426 menu.addAction(createAction) 1427 menu.addAction(delAction) 1428 1429 action = menu.exec_(self.list_jobs.mapToGlobal(position)) 1430 1431 1415 1432 # Add a custom context menu 1416 1433 def openmenuinput(self, position): … … 1422 1439 if ( len(selection) != 0 ): 1423 1440 1424 openAction = menu.addAction('Open selected files') 1441 1442 openAction = QtGui.QAction('Open file(s)', self) 1425 1443 openAction.setStatusTip('Open file(s) in your favorite editor') 1426 1444 openAction.triggered.connect(self.OpenFilesInput) 1445 1446 1447 delAction = QtGui.QAction('Delete file(s)', self) 1448 delAction.triggered.connect(self.DeleteFilesInput) 1449 1450 menu.addAction(openAction) 1451 menu.addAction(delAction) 1452 1427 1453 action = menu.exec_(self.list_input.mapToGlobal(position)) 1428 1454 … … 1436 1462 if ( len(selection) != 0 ): 1437 1463 1438 openAction = menu.addAction('Open selected files')1464 openAction = QtGui.QAction('Open file(s)', self) 1439 1465 openAction.setStatusTip('Open file(s) in your favorite editor') 1440 1466 openAction.triggered.connect(self.OpenFilesUser) 1467 1468 1469 delAction = QtGui.QAction('Delete file(s)', self) 1470 delAction.triggered.connect(self.DeleteFilesUser) 1471 1472 menu.addAction(openAction) 1473 menu.addAction(delAction) 1441 1474 action = menu.exec_(self.list_user.mapToGlobal(position)) 1442 1475 … … 1450 1483 if ( len(selection) != 0 ): 1451 1484 1452 openAction = menu.addAction('Open selected files')1485 openAction = QtGui.QAction('Open file(s)', self) 1453 1486 openAction.setStatusTip('Open file(s) in your favorite editor') 1454 1487 openAction.triggered.connect(self.OpenFilesOutput) 1488 1489 1490 delAction = QtGui.QAction('Delete file(s)', self) 1491 delAction.triggered.connect(self.DeleteFilesOutput) 1492 1493 menu.addAction(openAction) 1494 menu.addAction(delAction) 1455 1495 action = menu.exec_(self.list_output.mapToGlobal(position)) 1456 1496 … … 1464 1504 if ( len(selection) != 0 ): 1465 1505 1466 openAction = menu.addAction('Open selected files')1506 openAction = QtGui.QAction('Open file(s)', self) 1467 1507 openAction.setStatusTip('Open file(s) in your favorite editor') 1468 1508 openAction.triggered.connect(self.OpenFilesMonitoring) 1509 1510 1511 delAction = QtGui.QAction('Delete file(s)', self) 1512 delAction.triggered.connect(self.DeleteFilesMonitoring) 1513 1514 menu.addAction(openAction) 1515 menu.addAction(delAction) 1469 1516 action = menu.exec_(self.list_monitoring.mapToGlobal(position)) 1517 1518 def OpenConfig(self): 1519 1520 config = str(self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText()) 1521 if ( config != "" ): 1522 filename = ".palm.config." + config 1523 open_file = "xdg-open " + filename 1524 os.system(str(open_file)) 1470 1525 1471 1526 def OpenFilesInput(self): … … 1478 1533 open_files = "" 1479 1534 for i in range(0,len(sel_files)): 1480 open_files = open_files + "xdg-open " + input_dir + sel_files[i].text() + "; "1535 open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " 1481 1536 1482 1537 os.system(str(open_files)) … … 1505 1560 open_files = "" 1506 1561 for i in range(0,len(sel_files)): 1507 open_files = open_files + "xdg-open " + input_dir + sel_files[i].text() + "; "1562 open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " 1508 1563 1509 1564 os.system(str(open_files)) … … 1519 1574 open_files = "" 1520 1575 for i in range(0,len(sel_files)): 1521 open_files = open_files + "xdg-open " + input_dir + sel_files[i].text() + "; "1576 open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " 1522 1577 1523 1578 os.system(str(open_files)) 1524 1579 selection = self.list_jobs.selectedItems() 1525 1580 1581 def DeleteFilesInput(self): 1582 1583 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1584 1585 if status == QtGui.QMessageBox.Yes: 1586 1587 sel_job = self.list_jobs.currentItem().text() 1588 sel_files = self.list_input.selectedItems() 1589 1590 input_dir = job_dir + "/" + sel_job + "/INPUT/" 1591 1592 for i in range(0,len(sel_files)): 1593 filename = input_dir + sel_files[i].text().split("(")[0].trimmed() 1594 os.remove(filename) 1595 1596 self.update_all() 1597 1598 1599 def DeleteFilesUser(self): 1600 1601 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1602 1603 if status == QtGui.QMessageBox.Yes: 1604 1605 sel_job = self.list_jobs.currentItem().text() 1606 sel_files = self.list_user.selectedItems() 1607 1608 input_dir = job_dir + "/" + sel_job + "/USER/" 1609 1610 for i in range(0,len(sel_files)): 1611 filename = input_dir + sel_files[i].text().split("(")[0].trimmed() 1612 os.remove(filename) 1613 1614 self.update_all() 1615 1616 1617 def DeleteFilesMonitoring(self): 1618 1619 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1620 1621 if status == QtGui.QMessageBox.Yes: 1622 1623 sel_job = self.list_jobs.currentItem().text() 1624 sel_files = self.list_monitoring.selectedItems() 1625 1626 input_dir = job_dir + "/" + sel_job + "/MONITORING/" 1627 1628 for i in range(0,len(sel_files)): 1629 filename = input_dir + sel_files[i].text().split("(")[0].trimmed() 1630 os.remove(filename) 1631 1632 self.update_all() 1633 1634 1635 def DeleteFilesOutput(self): 1636 1637 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1638 1639 if status == QtGui.QMessageBox.Yes: 1640 1641 sel_job = self.list_jobs.currentItem().text() 1642 sel_files = self.list_output.selectedItems() 1643 1644 input_dir = job_dir + "/" + sel_job + "/OUTPUT/" 1645 1646 for i in range(0,len(sel_files)): 1647 filename = input_dir + sel_files[i].text().split("(")[0].trimmed() 1648 os.remove(filename) 1649 1650 self.update_all() 1651 1652 def DeleteJob(self): 1653 1654 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete this job?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1655 1656 if status == QtGui.QMessageBox.Yes: 1657 1658 sel_job = self.list_jobs.currentItem().text() 1659 1660 input_dir = job_dir + "/" + sel_job 1661 shutil.rmtree(str(input_dir)) 1662 1663 self.update_all() 1664 1526 1665 # Message box for showing RUN_CONTROL output 1527 1666 class CreateSetBox(QtGui.QDialog): 1528 1667 def __init__(self): 1529 1668 1530 1669 super(CreateSetBox, self).__init__() 1531 1670 1532 1671 uic.loadUi(palm_bin + '/palmrungui_files/create_set.ui', self) 1533 1672 1534 1673 self.show() 1535 1674 1536 1675 return 1537 1676 1538 1677 # Cancel button 1539 1678 def rejected(self): 1540 1679 1541 1680 self.close() 1542 1681 1543 1682 return 1544 1545 1683 1546 1684 # OK button 1547 1685 def accept(self): 1548 1686 1549 1687 global set_list 1550 1688 1551 1689 text = self.list.toPlainText() 1552 1690 set_list = text.split('\n') 1553 1691 self.close() 1554 1692 1555 1693 return 1556 1694 1557 1558 1695 # Message box for showing RUN_CONTROL output 1696 class OpenHistoryBox(QtGui.QDialog): 1697 def __init__(self): 1698 1699 super(OpenHistoryBox, self).__init__() 1700 1701 uic.loadUi(palm_bin + '/palmrungui_files/history.ui', self) 1702 1703 if os.path.exists(palm_dir + "/.palmrungui.history"): 1704 pass 1705 else: 1706 return 1707 1708 filename = open(palm_dir + "/.palmrungui.history","r") 1709 history = filename.readlines() 1710 filename.close() 1711 1712 1713 list_jobname = self.findChild(QtGui.QListWidget,"list_history") 1714 1715 # Read history entries and append to recent job list 1716 len_history=len(history)-1 1717 i = 0 1718 while i<=len_history: 1719 list_jobname.addItem(history[i]) 1720 i = i + 1 1721 1722 self.show() 1723 1724 return 1725 1726 # Select item / activate Load button 1727 def ItemSelected(self): 1728 1729 self.push_open.setEnabled(True) 1730 1731 return 1732 1733 1734 # Load job from history 1735 def OpenFromHistory(self): 1736 1737 global history_entry 1738 history_entry = self.list_history.selectedItems()[0].text() 1739 1740 self.close() 1741 1742 return 1743 1744 # Close history window 1745 def DiscardHistory(self): 1746 1747 1748 self.close() 1749 1750 return 1751 1752 # Clear history 1753 def ClearHistory(self): 1754 1755 status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete your history?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) 1756 1757 if status == QtGui.QMessageBox.Yes: 1758 1759 if os.path.exists(palm_dir + "/.palmrungui.history"): 1760 os.remove(palm_dir + "/.palmrungui.history") 1761 1762 1763 return 1559 1764 1560 1765 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.