1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | #--------------------------------------------------------------------------------# |
---|
4 | # This file is part of the PALM model system. |
---|
5 | # |
---|
6 | # PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | # of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | # either version 3 of the License, or (at your option) any later version. |
---|
9 | # |
---|
10 | # PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | # |
---|
14 | # You should have received a copy of the GNU General Public License along with |
---|
15 | # PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | # |
---|
17 | # Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
18 | #--------------------------------------------------------------------------------# |
---|
19 | # |
---|
20 | # Current revisions: |
---|
21 | # ----------------- |
---|
22 | # |
---|
23 | # |
---|
24 | # Former revisions: |
---|
25 | # ----------------- |
---|
26 | # $Id: palmrungui 4411 2020-02-18 14:28:02Z monakurppa $ |
---|
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 |
---|
31 | # Major revisions: New layout. Merged with palm job manager (palm_jm). |
---|
32 | # Minor revisions: Misc. bugs fixed. |
---|
33 | # |
---|
34 | # 4394 2020-02-04 21:40:38Z maronga |
---|
35 | # Bugfix: harmonized naming convention of configuration files |
---|
36 | # |
---|
37 | # 4393 2020-02-04 21:24:48Z maronga |
---|
38 | # Removed PALM_BIN dependency and os calls |
---|
39 | # |
---|
40 | # 3487 2018-11-05 07:18:02Z maronga |
---|
41 | # Renamed options -d and -h to -r and -c. |
---|
42 | # |
---|
43 | # 2825 2018-02-20 21:48:27Z maronga |
---|
44 | # Adjusted to work with newest version of palmrun |
---|
45 | # |
---|
46 | # 2718 2018-01-02 08:49:38Z maronga |
---|
47 | # Corrected "Former revisions" section |
---|
48 | # |
---|
49 | # 2696 2017-12-14 17:12:51Z kanani |
---|
50 | # Change in file header (GPL part) |
---|
51 | # |
---|
52 | # 2484 2017-09-20 14:22:42Z maronga |
---|
53 | # Added PALM logo |
---|
54 | # |
---|
55 | # 2480 2017-09-19 06:24:14Z maronga |
---|
56 | # option -A (project account number) added |
---|
57 | # |
---|
58 | # 2477 2017-09-18 08:42:29Z maronga |
---|
59 | # Renamed restart run appendix from "f" to "r". Bugfix for displaying restart runs.> |
---|
60 | # Revised list of recently submitted jobs |
---|
61 | # |
---|
62 | # 2413 2017-09-06 12:48:29Z maronga |
---|
63 | # Renamed to palmrungui and adapted for use with palmrun instead of mrun. |
---|
64 | # |
---|
65 | # 2316 2017-07-20 07:53:42Z maronga |
---|
66 | # Initial revision in python |
---|
67 | # |
---|
68 | # |
---|
69 | # |
---|
70 | # Description: |
---|
71 | # ------------ |
---|
72 | # Graphical user interface for the palmrun script. |
---|
73 | # @author Felix Gaschler |
---|
74 | # @author Björn Maronga (maronga@muk.uni-hannover.de) |
---|
75 | # |
---|
76 | # Instructions: |
---|
77 | # ------------- |
---|
78 | # |
---|
79 | #------------------------------------------------------------------------------! |
---|
80 | |
---|
81 | import sys |
---|
82 | import subprocess |
---|
83 | from PyQt4 import QtCore, QtGui, uic |
---|
84 | from PyQt4.QtCore import QProcess,pyqtSlot,SIGNAL,SLOT |
---|
85 | from time import strftime |
---|
86 | import os |
---|
87 | import shutil |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | # Determine PALM directories |
---|
92 | try: |
---|
93 | devnull = open(os.devnull, 'w') |
---|
94 | palm_dir = os.getcwd() |
---|
95 | palm_bin = palm_dir + '/trunk/SCRIPTS' |
---|
96 | job_dir = palm_dir + '/JOBS' |
---|
97 | user_dir = palm_dir + '/USER_CODE' |
---|
98 | with open(palm_bin + '/palmrungui', 'r') as fh: |
---|
99 | # file found |
---|
100 | out = None |
---|
101 | except: |
---|
102 | print "Error. palmrungui probably called in wrong directory." |
---|
103 | raise SystemExit |
---|
104 | |
---|
105 | |
---|
106 | palmrunline = "" |
---|
107 | set_list = [] |
---|
108 | |
---|
109 | Ui_MainWindow = uic.loadUiType("%s/palmrungui_files/mainwindow.ui" % (palm_bin))[0] |
---|
110 | Ui_helpDialog = uic.loadUiType("%s/palmrungui_files/help.ui" % (palm_bin))[0] |
---|
111 | Ui_aboutDialog = uic.loadUiType("%s/palmrungui_files/about.ui" % (palm_bin))[0] |
---|
112 | |
---|
113 | class HelpDialog(QtGui.QDialog,Ui_helpDialog): |
---|
114 | def __init__(self, parent=None): |
---|
115 | super(HelpDialog,self).__init__() |
---|
116 | self.setupUi(self) |
---|
117 | |
---|
118 | class AboutDialog(QtGui.QDialog,Ui_aboutDialog): |
---|
119 | def __init__(self, parent=None): |
---|
120 | super(AboutDialog,self).__init__() |
---|
121 | self.setupUi(self) |
---|
122 | |
---|
123 | class Mainwindow(QtGui.QMainWindow, Ui_MainWindow): |
---|
124 | def __init__(self, parent=None): |
---|
125 | super(Mainwindow, self).__init__() |
---|
126 | self.setupUi(self) |
---|
127 | |
---|
128 | self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
129 | |
---|
130 | self.recent_jobs(50) |
---|
131 | self.load_jobs() |
---|
132 | |
---|
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 | |
---|
142 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
143 | commandline.setText("") |
---|
144 | |
---|
145 | self.tabWidget.setCurrentIndex(0) |
---|
146 | |
---|
147 | |
---|
148 | filename = "%s/.palmrungui.default" % (palm_dir) |
---|
149 | if os.path.exists(filename): |
---|
150 | pass |
---|
151 | else: |
---|
152 | return |
---|
153 | |
---|
154 | file = open(filename, "r") |
---|
155 | if ( file is not None ): |
---|
156 | # File opened successfully |
---|
157 | palmrunline = file.readline() |
---|
158 | #if neue zeile zeichen |
---|
159 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
160 | file.close() |
---|
161 | |
---|
162 | # In case a palmrunline was found, load it to mainwindow |
---|
163 | if ( palmrunline != ""): |
---|
164 | palmrunline = palmrunline[17:] |
---|
165 | commandline.setText(palmrunline) |
---|
166 | self.setup_gui(palmrunline) |
---|
167 | |
---|
168 | |
---|
169 | |
---|
170 | |
---|
171 | QtGui.QApplication.processEvents() |
---|
172 | |
---|
173 | |
---|
174 | |
---|
175 | # starts xterm with palmrun commandline |
---|
176 | ####################################### |
---|
177 | def startpalmrun(self): |
---|
178 | palmrunline = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()) |
---|
179 | userline = str(self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text()) |
---|
180 | |
---|
181 | # Check for empty line |
---|
182 | palmrunline_save = palmrunline |
---|
183 | if (userline != ""): |
---|
184 | palmrunline = "%s %s" % (palmrunline,userline) |
---|
185 | history_line = palmrunline |
---|
186 | |
---|
187 | # Disable the main window |
---|
188 | self.tabWidget.setEnabled(False) |
---|
189 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
190 | self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(False) |
---|
191 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("wait...") |
---|
192 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmrun in xterm...") |
---|
193 | |
---|
194 | # Wait until all commands have been executed (ugly) ? |
---|
195 | #for i in range(0,21): |
---|
196 | # qApp->processEvents() |
---|
197 | |
---|
198 | # Start xterm as QProcess |
---|
199 | palmrun = QProcess() |
---|
200 | palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels |
---|
201 | palmrun.setWorkingDirectory(palm_dir) |
---|
202 | |
---|
203 | geomet = self.frameGeometry() |
---|
204 | |
---|
205 | posx = geomet.x()+geomet.width() |
---|
206 | posy = geomet.y() |
---|
207 | |
---|
208 | s = " -title \"Executing palmrun...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy) |
---|
209 | palmrunline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'")) |
---|
210 | |
---|
211 | mString = "xterm %s" % (palmrunline) |
---|
212 | palmrun.start(mString) |
---|
213 | |
---|
214 | if( palmrun.waitForStarted() is False ): |
---|
215 | return |
---|
216 | |
---|
217 | # Wait until palmrun has finished or wait for 200 minutes |
---|
218 | palmrun.waitForFinished(3600000) |
---|
219 | |
---|
220 | # Jobs has been submitted or aborted. Continuing... |
---|
221 | # Save the palmrun command to history file |
---|
222 | filename = "%s/.palmrungui.history" % (palm_dir) |
---|
223 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
224 | tag = str(self.groupBox.findChild(QtGui.QLineEdit,"line_tag").text()) |
---|
225 | |
---|
226 | file = open(filename,"a") |
---|
227 | s = "%s %s (%s)\n" % (tmstamp,history_line,tag) |
---|
228 | file.write(s) |
---|
229 | file.close() |
---|
230 | |
---|
231 | # Enable main window again |
---|
232 | self.tabWidget.setEnabled(True) |
---|
233 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
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) |
---|
237 | |
---|
238 | # Reload recent jobs |
---|
239 | self.recent_jobs(50) |
---|
240 | |
---|
241 | |
---|
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 | |
---|
290 | # loads recent jobs |
---|
291 | ###################################### |
---|
292 | def recent_jobs(self, number): |
---|
293 | fileDir = "%s/.palmrungui.history" % (palm_dir) |
---|
294 | if os.path.exists(fileDir): |
---|
295 | pass |
---|
296 | else: |
---|
297 | return |
---|
298 | |
---|
299 | file = open(fileDir,"r") |
---|
300 | history = file.readlines() |
---|
301 | tmphistory = list() |
---|
302 | tmptag = list() |
---|
303 | file.close() |
---|
304 | j = 0 |
---|
305 | |
---|
306 | list_jobname = self.group_history.findChild(QtGui.QListWidget,"list_jobname") |
---|
307 | list_jobname.clear() |
---|
308 | |
---|
309 | # Read history entries and append to recent job list |
---|
310 | i=len(history)-1 |
---|
311 | count = 0 |
---|
312 | while i>=0 and count<number: |
---|
313 | timestamp = history[i][:16] |
---|
314 | listitem = history[i][17:len(history[i])-1] |
---|
315 | tagitem = listitem |
---|
316 | matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly) |
---|
317 | |
---|
318 | if ( len(matchitems) == 0 ): |
---|
319 | listitem = filter(None,listitem.split(" -r"))[1] |
---|
320 | listitem = filter(None,listitem.split(" -"))[0] |
---|
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) |
---|
334 | count = count +1 |
---|
335 | |
---|
336 | j = j+1 |
---|
337 | |
---|
338 | if ( j == number ): |
---|
339 | break |
---|
340 | i = i-1 |
---|
341 | |
---|
342 | # Send to list |
---|
343 | list_jobname.clear() |
---|
344 | |
---|
345 | i=0 |
---|
346 | while i<len(tmphistory): |
---|
347 | list_jobname.addItem(tmphistory[i]) |
---|
348 | list_jobname.item(i).setToolTip(tmptag[i]) |
---|
349 | i = i+1 |
---|
350 | |
---|
351 | |
---|
352 | # Enables coupled settings |
---|
353 | ############################### |
---|
354 | def enable_coupled(self): |
---|
355 | coupledState = self.group_execution.findChild(QtGui.QComboBox, "drop_job").currentText() |
---|
356 | group = self.group_execution.findChild(QtGui.QGroupBox, "group_coupled") |
---|
357 | |
---|
358 | if (coupledState == "Restart run (coupled atmosphere ocean)" or coupledState == "Initial run (coupled atmosphere ocean)"): |
---|
359 | self.group_coupled.setEnabled(True) |
---|
360 | else: |
---|
361 | self.group_coupled.setEnabled(False) |
---|
362 | |
---|
363 | |
---|
364 | # select a job via click from list |
---|
365 | ################################# |
---|
366 | def choosejob_list(self): |
---|
367 | # Get selected item from list |
---|
368 | list_jobname = self.group_history.findChild(QtGui.QListWidget,"list_jobname") |
---|
369 | filename = str(list_jobname.currentItem().text()) |
---|
370 | |
---|
371 | timestamp = filename[:16] |
---|
372 | jobname = filename[18:] |
---|
373 | |
---|
374 | itemint = list_jobname.currentRow() |
---|
375 | |
---|
376 | # Reload list |
---|
377 | self.recent_jobs(50) |
---|
378 | self.load_jobs() |
---|
379 | |
---|
380 | # Set selected item to jobname |
---|
381 | list_jobname.item(itemint).setSelected(True) |
---|
382 | |
---|
383 | # Set selected item to jobname in "available jobs" list |
---|
384 | item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive) |
---|
385 | |
---|
386 | if ( item2int != [] ): |
---|
387 | self.list_jobs.setCurrentItem(item2int[0]) |
---|
388 | self.update_input() |
---|
389 | |
---|
390 | |
---|
391 | fileDir = "%s/.palmrungui.history" % (palm_dir) |
---|
392 | file = open(fileDir,"r") |
---|
393 | history = file.readlines() |
---|
394 | tmphistory = list() |
---|
395 | file.close() |
---|
396 | |
---|
397 | i = len(history) |
---|
398 | while i>=1: |
---|
399 | listitem = history[i-1][17:len(history[i-1])-1] |
---|
400 | listitem = filter(None,listitem.split(" -r"))[1] |
---|
401 | listitem = filter(None,listitem.split(" -"))[0] |
---|
402 | listitem = listitem.replace(" ","") |
---|
403 | |
---|
404 | # Select command line with correct timestamp and jobname |
---|
405 | if (history[i-1][:16] == timestamp and listitem == jobname): |
---|
406 | palmrunline = history[i-1] |
---|
407 | palmrunline = palmrunline[17:] |
---|
408 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
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) |
---|
420 | |
---|
421 | return |
---|
422 | i = i-1 |
---|
423 | |
---|
424 | # Change run identifer (initial, restart, coupled...) |
---|
425 | ###################################################### |
---|
426 | def change_rc_list(self): |
---|
427 | drop_job = self.group_execution.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
428 | self.change_commandline("a","") |
---|
429 | |
---|
430 | # Enable PE distribution for atmosphere/ocean |
---|
431 | if ( drop_job == "Restart run (coupled atmosphere ocean)" or drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
432 | drop_atmos = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").text() |
---|
433 | drop_ocean = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").text() |
---|
434 | s = "%s %s" % (drop_atmos,drop_ocean) |
---|
435 | self.change_commandline("Y",s) |
---|
436 | |
---|
437 | |
---|
438 | if ( drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)"): |
---|
439 | self.change_commandline("r","") |
---|
440 | |
---|
441 | # Check of ocean runs |
---|
442 | else: |
---|
443 | self.delete_commandline("Y") |
---|
444 | if (drop_job == "Precursor run (ocean)"): |
---|
445 | self.activate_flag("y") |
---|
446 | else: |
---|
447 | self.deactivate_flag("y") |
---|
448 | |
---|
449 | # changes commandline depending on parameters |
---|
450 | ########################################################## |
---|
451 | def change_commandline(self, id_str, fwt_str): |
---|
452 | fwt_str = str(fwt_str) |
---|
453 | initialize = False |
---|
454 | palmrunline = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()) |
---|
455 | s = " -%s " % (id_str) |
---|
456 | splitline = filter(None,palmrunline.split(s)) |
---|
457 | |
---|
458 | if ( len(splitline) == 0 ): |
---|
459 | splitline.append("palmrun") |
---|
460 | splitline.append(" ") |
---|
461 | initialize = True |
---|
462 | |
---|
463 | elif ( len(splitline) == 1 ): |
---|
464 | splitline.append(" ") |
---|
465 | |
---|
466 | param = splitline[1].split("-") |
---|
467 | |
---|
468 | # Change in parameter "r" (jobname) |
---|
469 | if (id_str == "r"): |
---|
470 | filename = str(self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").text()) |
---|
471 | s = filename.split("JOBS/") |
---|
472 | param[0] = s[len(s)-1] |
---|
473 | |
---|
474 | if ( initialize == True ):#and self.group_runcontrol.isEnabled() == True ): |
---|
475 | self.group_execution.setEnabled(True) |
---|
476 | self.group_execution.findChild(QtGui.QComboBox,"drop_job").setEnabled(True) |
---|
477 | self.group_advanced.setEnabled(True) |
---|
478 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
479 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(True) |
---|
480 | self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True) |
---|
481 | |
---|
482 | elif ( param[0] == ""): |
---|
483 | self.group_execution.setEnabled(False) |
---|
484 | self.group_execution.findChild(QtGui.QComboBox,"drop_job").setEnabled(False) |
---|
485 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
486 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(False) |
---|
487 | self.group_advanced.setEnabled(False) |
---|
488 | self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True) |
---|
489 | self.delete_commandline("r") |
---|
490 | self.change_commandline("a","remove") |
---|
491 | return 1 |
---|
492 | |
---|
493 | else: |
---|
494 | |
---|
495 | # Check if _p3dr file is available, otherwise notice user |
---|
496 | drop_job = self.group_execution.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
497 | if ( self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() == 2 or |
---|
498 | drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)" ): |
---|
499 | |
---|
500 | jobname = self.group_execution.findChild(QtGui.QLineEdit, "line_jobname").text() |
---|
501 | restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname) |
---|
502 | |
---|
503 | if (os.path.exists(restartfile) == True): |
---|
504 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
505 | |
---|
506 | |
---|
507 | if ( drop_job == "Restart run (coupled atmosphere ocean)" ): |
---|
508 | restartfileo = "%s/JOBS/%s/INPUT/%s_p3dor" % (palm_dir,jobname,jobname) |
---|
509 | if (os.path.exists(restartfileo) == True): |
---|
510 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("hooo") |
---|
511 | |
---|
512 | else: |
---|
513 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dor file found!</font>") |
---|
514 | |
---|
515 | else: |
---|
516 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>") |
---|
517 | |
---|
518 | |
---|
519 | |
---|
520 | self.group_execution.setEnabled(True) |
---|
521 | self.drop_job.setEnabled(True) |
---|
522 | self.group_advanced.setEnabled(True) |
---|
523 | |
---|
524 | # Change in parameter "a" (run control list) |
---|
525 | elif (id_str == "a"): |
---|
526 | |
---|
527 | drop_job = self.group_execution.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
528 | rc_flag = "#" |
---|
529 | |
---|
530 | if (drop_job == "Initial run"): |
---|
531 | rc_flag = "#" |
---|
532 | |
---|
533 | elif (drop_job == "Restart run"): |
---|
534 | rc_flag = "r" |
---|
535 | |
---|
536 | elif (drop_job == "Precursor run (atmosphere)"): |
---|
537 | rc_flag = "#" |
---|
538 | |
---|
539 | elif (drop_job == "Precursor run (ocean)"): |
---|
540 | rc_flag = "o#" |
---|
541 | |
---|
542 | elif (drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
543 | rc_flag = "#" |
---|
544 | |
---|
545 | elif (drop_job == "Restart run (coupled atmosphere ocean)"): |
---|
546 | rc_flag = "r" |
---|
547 | |
---|
548 | param[0] = "\"d3%s" % (rc_flag) |
---|
549 | |
---|
550 | |
---|
551 | if (drop_job == "Restart run (coupled atmosphere ocean)" or drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
552 | if (rc_flag == "#"): |
---|
553 | rc_flag = "o#" |
---|
554 | else: |
---|
555 | rc_flag = "or" |
---|
556 | |
---|
557 | param[0] = "%s d3%s" % (param[0],rc_flag) |
---|
558 | |
---|
559 | status_restarts = self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() |
---|
560 | |
---|
561 | if (status_restarts == 2): |
---|
562 | param[0]="%s restart" % (param[0]) |
---|
563 | |
---|
564 | # Check if _p3dr file is available, otherwise notice user |
---|
565 | if (status_restarts == 2): |
---|
566 | jobname = str(self.group_execution.findChild(QtGui.QLineEdit, "line_jobname").text()) |
---|
567 | restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname) |
---|
568 | if (os.path.exists(restartfile) == True): |
---|
569 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
570 | |
---|
571 | else: |
---|
572 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>") |
---|
573 | |
---|
574 | else: |
---|
575 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
576 | |
---|
577 | status_cycfill = self.group_execution.findChild(QtGui.QCheckBox,"check_cycfill").checkState() |
---|
578 | |
---|
579 | if (status_cycfill == 2): |
---|
580 | param[0]="%s fill" % (param[0]) |
---|
581 | |
---|
582 | status_svf = self.group_execution.findChild(QtGui.QCheckBox,"check_svf").checkState() |
---|
583 | |
---|
584 | if (status_svf == 2): |
---|
585 | param[0]="%s svf" % (param[0]) |
---|
586 | |
---|
587 | param[0]="%s\"" % (param[0]) |
---|
588 | |
---|
589 | |
---|
590 | if ( fwt_str == "remove"): |
---|
591 | self.delete_commandline(id_str) |
---|
592 | return 1 |
---|
593 | |
---|
594 | else: |
---|
595 | self.button_start.setEnabled(True) |
---|
596 | self.action_save.setEnabled(True) |
---|
597 | self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True) |
---|
598 | |
---|
599 | # Change in any other parameter |
---|
600 | else: |
---|
601 | if ( fwt_str != ""): |
---|
602 | param[0] = "\"%s\"" % (fwt_str) |
---|
603 | |
---|
604 | else: |
---|
605 | self.delete_commandline(id_str) |
---|
606 | return 1 |
---|
607 | |
---|
608 | # Join the new palmrunline |
---|
609 | splitline[1]= " -".join(param) |
---|
610 | |
---|
611 | |
---|
612 | s = " -%s " % (id_str) |
---|
613 | newpalmrunline = s.join(splitline) |
---|
614 | |
---|
615 | # Pr the new palmrunline to mainwindow |
---|
616 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
617 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(newpalmrunline) |
---|
618 | |
---|
619 | # change lineinput depending on sender |
---|
620 | ################################################################################### |
---|
621 | def change_lineinput(self): |
---|
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) |
---|
630 | |
---|
631 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_q")): |
---|
632 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_q").text() |
---|
633 | self.change_commandline("q",tmptext) |
---|
634 | |
---|
635 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_account")): |
---|
636 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_account").text() |
---|
637 | self.change_commandline("A",tmptext) |
---|
638 | |
---|
639 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_pe")): |
---|
640 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_pe").text() |
---|
641 | self.change_commandline("X",tmptext) |
---|
642 | |
---|
643 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_tpn")): |
---|
644 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_tpn").text() |
---|
645 | self.change_commandline("T",tmptext) |
---|
646 | |
---|
647 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_time")): |
---|
648 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_time").text() |
---|
649 | self.change_commandline("t",tmptext) |
---|
650 | |
---|
651 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_M")): |
---|
652 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_M").text() |
---|
653 | self.change_commandline("M",tmptext) |
---|
654 | |
---|
655 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_m")): |
---|
656 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_m").text() |
---|
657 | self.change_commandline("m",tmptext) |
---|
658 | |
---|
659 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_D")): |
---|
660 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_D").text() |
---|
661 | self.change_commandline("D",tmptext) |
---|
662 | |
---|
663 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_c")): |
---|
664 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_c").text() |
---|
665 | if ( tmptext == ".palmrungui.config"): |
---|
666 | tmptext = "" |
---|
667 | self.change_commandline("c",tmptext) |
---|
668 | |
---|
669 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_s")): |
---|
670 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_s").text() |
---|
671 | self.change_commandline("s",tmptext) |
---|
672 | |
---|
673 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_w")): |
---|
674 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_w").text() |
---|
675 | self.change_commandline("w",tmptext) |
---|
676 | |
---|
677 | elif ( self.sender() == self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos") or |
---|
678 | self.sender() == self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean")): |
---|
679 | t1 = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").text() |
---|
680 | t2 = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").text() |
---|
681 | tmptext = "%s %s" % (t1,t2) |
---|
682 | |
---|
683 | self.change_commandline("Y",tmptext) |
---|
684 | |
---|
685 | # try catch sowas in der art |
---|
686 | pe1 = 0 |
---|
687 | pe2 = 0 |
---|
688 | |
---|
689 | try: |
---|
690 | pe1 = int(t1) |
---|
691 | except ValueError: |
---|
692 | pass |
---|
693 | |
---|
694 | try: |
---|
695 | pe2 = int(t2) |
---|
696 | except ValueError: |
---|
697 | pass |
---|
698 | |
---|
699 | PE_total = pe1+pe2 |
---|
700 | self.group_execution.findChild(QtGui.QLineEdit,"line_pe").setText(str(PE_total)) |
---|
701 | self.change_commandline("X",str(PE_total)) |
---|
702 | |
---|
703 | # deletes parameter from commandline |
---|
704 | ##################################################################################### |
---|
705 | def delete_commandline(self, id_str): |
---|
706 | # Read palmrunline |
---|
707 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
708 | palmrunline = str(commandline.text()) |
---|
709 | s = " -%s" % (id_str) |
---|
710 | splitline = filter(None,palmrunline.split(s)) |
---|
711 | |
---|
712 | if ( len(splitline) == 1): |
---|
713 | return 1 |
---|
714 | else: |
---|
715 | param = splitline[1].split("-") |
---|
716 | param[0] = "" |
---|
717 | splitline[1]= " -".join(param) |
---|
718 | newpalmrunline = "".join(splitline) |
---|
719 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
720 | |
---|
721 | # Print new palmrunline to screen |
---|
722 | commandline.setText(newpalmrunline) |
---|
723 | |
---|
724 | # controls flags |
---|
725 | ################################################################################### |
---|
726 | def check_flags(self): |
---|
727 | status = self.group_execution.findChild(QtGui.QCheckBox,"check_delete_tmp_files" ).checkState() |
---|
728 | if (status == 2): |
---|
729 | self.activate_flag("B") |
---|
730 | else: |
---|
731 | self.deactivate_flag("B") |
---|
732 | |
---|
733 | status = self.group_execution.findChild(QtGui.QCheckBox,"check_verbose" ).checkState() |
---|
734 | if (status == 2): |
---|
735 | self.activate_flag("v") |
---|
736 | else: |
---|
737 | self.deactivate_flag("v") |
---|
738 | |
---|
739 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_b" ).checkState() |
---|
740 | if (status == 2): |
---|
741 | self.activate_flag("b") |
---|
742 | else: |
---|
743 | self.deactivate_flag("b") |
---|
744 | |
---|
745 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_F" ).checkState() |
---|
746 | if (status == 2): |
---|
747 | self.activate_flag("F") |
---|
748 | else: |
---|
749 | self.deactivate_flag("F") |
---|
750 | |
---|
751 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_I" ).checkState() |
---|
752 | if (status == 2): |
---|
753 | self.activate_flag("I") |
---|
754 | else: |
---|
755 | self.deactivate_flag("I") |
---|
756 | |
---|
757 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_k" ).checkState() |
---|
758 | if (status == 2): |
---|
759 | self.activate_flag("k") |
---|
760 | else: |
---|
761 | self.deactivate_flag("k") |
---|
762 | |
---|
763 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_O" ).checkState() |
---|
764 | if (status == 2): |
---|
765 | self.activate_flag("O") |
---|
766 | else: |
---|
767 | self.deactivate_flag("O") |
---|
768 | |
---|
769 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_x" ).checkState() |
---|
770 | if (status == 2): |
---|
771 | self.activate_flag("x") |
---|
772 | else: |
---|
773 | self.deactivate_flag("x") |
---|
774 | |
---|
775 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_Z" ).checkState() |
---|
776 | if (status == 2): |
---|
777 | self.activate_flag("Z") |
---|
778 | else: |
---|
779 | self.deactivate_flag("Z") |
---|
780 | |
---|
781 | # changes flag to parameter |
---|
782 | ################################################################################## |
---|
783 | def activate_flag(self, id_str): |
---|
784 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
785 | palmrunline = str(commandline.text()) |
---|
786 | s = " -%s" % (id_str) |
---|
787 | splitline = filter(None,palmrunline.split(s)) |
---|
788 | |
---|
789 | if ( len(splitline) == 1): |
---|
790 | splitline.append("") |
---|
791 | s = " -%s" % (id_str) |
---|
792 | newpalmrunline = s.join(splitline) |
---|
793 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
794 | commandline.setText(newpalmrunline) |
---|
795 | |
---|
796 | # deletes flag in commandline |
---|
797 | #################################################################################### |
---|
798 | def deactivate_flag(self, id_str): |
---|
799 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
800 | palmrunline = str(commandline.text()) |
---|
801 | s = " -%s" % (id_str) |
---|
802 | splitline = filter(None,palmrunline.split(s)) |
---|
803 | |
---|
804 | newpalmrunline = "".join(splitline) |
---|
805 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
806 | commandline.setText(newpalmrunline) |
---|
807 | |
---|
808 | # Clears window |
---|
809 | ################################################################################# |
---|
810 | def reset_window(self): |
---|
811 | self.setupUi(self) |
---|
812 | self.tabWidget.setCurrentIndex(0) |
---|
813 | self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
814 | self.recent_jobs(50) |
---|
815 | self.load_jobs() |
---|
816 | |
---|
817 | # Safes current commandline and user Parameters to .sav file |
---|
818 | ################################################################################# |
---|
819 | def save_to_file(self): |
---|
820 | user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text() |
---|
821 | cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text() |
---|
822 | |
---|
823 | string_to_file = cmd_string |
---|
824 | if (user_string != ""): |
---|
825 | string_to_file = "%s%s" % (string_to_file,user_string) |
---|
826 | |
---|
827 | #filename = QtGui.QInputDialog.getText(self, "Save File naming Dialog", "Insert filename", QtGui.QLineEdit.Normal) |
---|
828 | filename = str(QtGui.QFileDialog.getSaveFileName(self, "Save File","filename.sav")) |
---|
829 | extension = ".sav" |
---|
830 | filename = "%s%s" % (filename, "") |
---|
831 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
832 | |
---|
833 | file = open(filename,"w") |
---|
834 | s = "%s %s" % (tmstamp, string_to_file) |
---|
835 | file.write(s) |
---|
836 | file.close() |
---|
837 | |
---|
838 | # Safes current commandline and user parameters to default file |
---|
839 | ################################################################################ |
---|
840 | def save_default(self): |
---|
841 | user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text() |
---|
842 | cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text() |
---|
843 | |
---|
844 | string_to_file = cmd_string |
---|
845 | if (user_string != ""): |
---|
846 | string_to_file = "%s%s" % (string_to_file,user_string) |
---|
847 | |
---|
848 | filename ="%s/.palmrungui.default" % (palm_dir) |
---|
849 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
850 | |
---|
851 | file = open(filename,"w") |
---|
852 | s = "%s %s" % (tmstamp, string_to_file) |
---|
853 | file.write(s) |
---|
854 | file.close() |
---|
855 | |
---|
856 | |
---|
857 | # Executes command which starts watchdog (start palm_wd) |
---|
858 | ######################################################## |
---|
859 | def start_watchdog(self): |
---|
860 | subprocess.Popen(["nohup","palm_wd",">>","/dev/null", "2>&1","&"]) |
---|
861 | |
---|
862 | # Opens "help" dialog |
---|
863 | ################################# |
---|
864 | def help(self): |
---|
865 | dialog = HelpDialog() |
---|
866 | dialog.exec_() |
---|
867 | |
---|
868 | # Opens "about" dialog |
---|
869 | ################################## |
---|
870 | def about_gui(self): |
---|
871 | dialog = AboutDialog() |
---|
872 | dialog.exec_() |
---|
873 | |
---|
874 | # commandline to buttons etc |
---|
875 | ############################## |
---|
876 | def setup_gui(self, palmrun_str): |
---|
877 | |
---|
878 | #self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
879 | |
---|
880 | # Some initial settings |
---|
881 | user = "" |
---|
882 | coupled_run = False |
---|
883 | ocean_run = False |
---|
884 | nojob = False |
---|
885 | |
---|
886 | #Split parameters in palmrunline |
---|
887 | splitline = palmrun_str.split(" -") |
---|
888 | |
---|
889 | if ( splitline[0] != "palmrun"): |
---|
890 | return 1 |
---|
891 | |
---|
892 | else: |
---|
893 | self.group_execution.setEnabled(True) |
---|
894 | |
---|
895 | # Loop for all parameters in palmrunline |
---|
896 | i = len(splitline)-1 |
---|
897 | while i >= 1: |
---|
898 | |
---|
899 | # Determine parameter |
---|
900 | splitparameter = splitline[i].split(" ") |
---|
901 | |
---|
902 | parameter = splitparameter[0] |
---|
903 | splitparameter.pop(0) |
---|
904 | options = " ".join(splitparameter) |
---|
905 | options = options.replace("\"","") |
---|
906 | |
---|
907 | # Check for suitable switch |
---|
908 | if ( parameter == "r"): |
---|
909 | |
---|
910 | if ( options != ""): |
---|
911 | self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").setText(options) |
---|
912 | nojob = False |
---|
913 | |
---|
914 | else: |
---|
915 | nojob = True |
---|
916 | |
---|
917 | elif ( parameter == "c"): |
---|
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) |
---|
923 | elif ( parameter == "q"): |
---|
924 | self.group_execution.findChild(QtGui.QLineEdit,"line_q").setText(options) |
---|
925 | |
---|
926 | elif ( parameter == "A"): |
---|
927 | self.group_execution.findChild(QtGui.QLineEdit,"line_account").setText(options) |
---|
928 | |
---|
929 | elif ( parameter == "X"): |
---|
930 | self.group_execution.findChild(QtGui.QLineEdit,"line_pe").setText(options) |
---|
931 | |
---|
932 | elif ( parameter == "T"): |
---|
933 | self.group_execution.findChild(QtGui.QLineEdit,"line_tpn").setText(options) |
---|
934 | |
---|
935 | elif ( parameter == "t"): |
---|
936 | self.group_execution.findChild(QtGui.QLineEdit,"line_time").setText(options) |
---|
937 | |
---|
938 | elif ( parameter == "B"): |
---|
939 | self.group_execution.findChild(QtGui.QCheckBox,"check_delete_tmp_files").setChecked(True) |
---|
940 | |
---|
941 | elif ( parameter == "v"): |
---|
942 | self.group_execution.findChild(QtGui.QCheckBox,"check_verbose").setChecked(True) |
---|
943 | |
---|
944 | elif ( parameter == "b"): |
---|
945 | self.group_advanced.findChild(QtGui.QCheckBox,"check_b").setChecked(True) |
---|
946 | |
---|
947 | elif ( parameter == "F"): |
---|
948 | self.group_advanced.findChild(QtGui.QCheckBox,"check_F").setChecked(True) |
---|
949 | |
---|
950 | elif ( parameter == "I"): |
---|
951 | self.group_advanced.findChild(QtGui.QCheckBox,"check_I").setChecked(True) |
---|
952 | |
---|
953 | elif ( parameter == "k"): |
---|
954 | self.group_advanced.findChild(QtGui.QCheckBox,"check_k").setChecked(True) |
---|
955 | |
---|
956 | elif ( parameter == "O"): |
---|
957 | self.group_advanced.findChild(QtGui.QCheckBox,"check_O").setChecked(True) |
---|
958 | |
---|
959 | elif ( parameter == "x"): |
---|
960 | self.group_advanced.findChild(QtGui.QCheckBox,"check_x").setChecked(True) |
---|
961 | |
---|
962 | elif ( parameter == "Z"): |
---|
963 | self.group_advanced.findChild(QtGui.QCheckBox,"check_Z").setChecked(True) |
---|
964 | |
---|
965 | elif ( parameter == "m"): |
---|
966 | self.group_advanced.findChild(QtGui.QLineEdit,"line_m").setText(options) |
---|
967 | |
---|
968 | elif ( parameter == "M"): |
---|
969 | self.group_advanced.findChild(QtGui.QLineEdit,"line_M").setText(options) |
---|
970 | |
---|
971 | elif ( parameter == "D"): |
---|
972 | self.group_advanced.findChild(QtGui.QLineEdit,"line_D").setText(options) |
---|
973 | |
---|
974 | elif ( parameter == "c"): |
---|
975 | self.group_advanced.findChild(QtGui.QLineEdit,"line_c").setText(options) |
---|
976 | |
---|
977 | elif ( parameter == "s"): |
---|
978 | self.group_advanced.findChild(QtGui.QLineEdit,"line_s").setText(options) |
---|
979 | |
---|
980 | elif ( parameter == "w"): |
---|
981 | self.group_advanced.findChild(QtGui.QLineEdit,"line_w").setText(options) |
---|
982 | |
---|
983 | |
---|
984 | # Determine settings for coupled restart runs |
---|
985 | elif ( parameter == "Y"): |
---|
986 | optionssplit = options.split(" ") |
---|
987 | |
---|
988 | group_coupled = self.group_execution.findChild(QtGui.QGroupBox,"group_coupled") |
---|
989 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setEnabled(True) |
---|
990 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setEnabled(True) |
---|
991 | group_coupled.findChild(QtGui.QLabel,"label_coupled1").setEnabled(True) |
---|
992 | group_coupled.findChild(QtGui.QLabel,"label_coupled2").setEnabled(True) |
---|
993 | group_coupled.findChild(QtGui.QLabel,"label_coupled3").setEnabled(True) |
---|
994 | group_coupled.findChild(QtGui.QLabel,"label_coupling").setEnabled(True) |
---|
995 | |
---|
996 | if (optionssplit.count() == 2): |
---|
997 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setEnabled(optionssplit[0]) |
---|
998 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setEnabled(optionssplit[1]) |
---|
999 | |
---|
1000 | else: |
---|
1001 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setText("") |
---|
1002 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setText("") |
---|
1003 | |
---|
1004 | |
---|
1005 | coupled_run = True |
---|
1006 | |
---|
1007 | elif ( parameter == "y"): |
---|
1008 | self.group_execution.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(3) |
---|
1009 | |
---|
1010 | |
---|
1011 | # Determine settings for the run control list |
---|
1012 | elif ( parameter == "a"): |
---|
1013 | |
---|
1014 | optionssplit = options.split(" ") |
---|
1015 | |
---|
1016 | options_2 = None |
---|
1017 | options_all = None |
---|
1018 | |
---|
1019 | j = 0 |
---|
1020 | while j < len(optionssplit): |
---|
1021 | |
---|
1022 | options_all = optionssplit[j] |
---|
1023 | options_2 = optionssplit[j][:2] |
---|
1024 | |
---|
1025 | if (options_2 == "d3"): |
---|
1026 | if (options_all[:3][-1] == "#"): |
---|
1027 | self.group_execution.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(0) |
---|
1028 | elif (options_all[:3][-1] == "r"): |
---|
1029 | self.group_execution.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(1) |
---|
1030 | |
---|
1031 | elif (options_all[:3][-1] == "o"): |
---|
1032 | ocean_run = True |
---|
1033 | |
---|
1034 | if (options_all == "restart"): |
---|
1035 | self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").setChecked(True) |
---|
1036 | # Check if _pdf file is available, otherwise notice user |
---|
1037 | jobname = str(self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").text()) |
---|
1038 | |
---|
1039 | restartfile = "%sJOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname) |
---|
1040 | if (os.path.exists(restartfile) == True): |
---|
1041 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
1042 | |
---|
1043 | else: |
---|
1044 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file \found!</font>") |
---|
1045 | j = j+1 |
---|
1046 | |
---|
1047 | # All unknown parameters are set as extra user parameters |
---|
1048 | else: |
---|
1049 | print parameter |
---|
1050 | user = "%s-%s \"%s\" " % (user,parameter,options) |
---|
1051 | splitline.removeAt(i) |
---|
1052 | |
---|
1053 | i = i-1 |
---|
1054 | # Change drop box state in case of ocean precursor or coupled restart runs |
---|
1055 | if ( ocean_run == True ): |
---|
1056 | if ( coupled_run == True ): |
---|
1057 | self.group_execution.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(4) |
---|
1058 | |
---|
1059 | else: |
---|
1060 | self.group_execution.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(3) |
---|
1061 | |
---|
1062 | if ( user != ""): |
---|
1063 | self.group_advanced.findChild(QtGui.QLineEdit,"line_user").setText(user) |
---|
1064 | |
---|
1065 | # Join palmrunline and post it to mainwindow |
---|
1066 | palmrunline = " -".join(splitline) |
---|
1067 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
1068 | |
---|
1069 | # Disable mainwindow if no job was found, otherwise enable |
---|
1070 | if ( nojob == True ): |
---|
1071 | self.group_execution.setEnabled(False) |
---|
1072 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
1073 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(False) |
---|
1074 | self.group_execution.findChild(QtGui.QComboBox, "drop_job").setEnabled(False) |
---|
1075 | self.group_advanced.setEnabled(False) |
---|
1076 | self.check_advanced.setEnabled(False) |
---|
1077 | self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(False) |
---|
1078 | |
---|
1079 | else: |
---|
1080 | self.group_execution.setEnabled(True) |
---|
1081 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
1082 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(True) |
---|
1083 | self.group_execution.findChild(QtGui.QComboBox, "drop_job").setEnabled(True) |
---|
1084 | self.group_advanced.setEnabled(True) |
---|
1085 | self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True) |
---|
1086 | |
---|
1087 | self.tabWidget.setCurrentIndex(0) |
---|
1088 | |
---|
1089 | # open saved commandline |
---|
1090 | ################################## |
---|
1091 | def open_from_file(self): |
---|
1092 | |
---|
1093 | # Select filename and open it |
---|
1094 | filename = QtGui.QFileDialog.getOpenFileName(self, "Open File","Save files (*.sav)") |
---|
1095 | |
---|
1096 | if ( filename != ""): |
---|
1097 | file = open(filename, "r") |
---|
1098 | |
---|
1099 | if ( file is not None ): |
---|
1100 | # File opened successfully |
---|
1101 | palmrunline = file.read() |
---|
1102 | file.close() |
---|
1103 | |
---|
1104 | # In case a palmrunline was found, load it to mainwindow |
---|
1105 | if ( palmrunline != ""): |
---|
1106 | palmrunline = palmrunline[17:] |
---|
1107 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
1108 | self.setup_gui(palmrunline) |
---|
1109 | |
---|
1110 | # open saved commandline |
---|
1111 | ################################## |
---|
1112 | def open_last(self): |
---|
1113 | # Select filename and open it |
---|
1114 | filename = "%s/.palmrungui.history" % (palm_dir) |
---|
1115 | |
---|
1116 | if os.path.exists(filename): |
---|
1117 | pass |
---|
1118 | else: |
---|
1119 | return |
---|
1120 | |
---|
1121 | file = open(filename, "r") |
---|
1122 | if ( file is not None ): |
---|
1123 | # File opened successfully |
---|
1124 | lines = file.readlines() |
---|
1125 | palmrunline = lines[len(lines)-1] |
---|
1126 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
1127 | file.close() |
---|
1128 | |
---|
1129 | # In case a palmrunline was found, load it to mainwindow |
---|
1130 | if ( palmrunline != ""): |
---|
1131 | palmrunline = palmrunline[17:len(palmrunline)] |
---|
1132 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
1133 | self.setup_gui(palmrunline) |
---|
1134 | |
---|
1135 | |
---|
1136 | |
---|
1137 | def update_all(self): |
---|
1138 | |
---|
1139 | self.setEnabled(False) |
---|
1140 | self.list_input.clear() |
---|
1141 | self.list_user.clear() |
---|
1142 | self.list_monitoring.clear() |
---|
1143 | self.list_output.clear() |
---|
1144 | self.load_jobs() |
---|
1145 | self.setEnabled(True) |
---|
1146 | |
---|
1147 | # Load jobs into list |
---|
1148 | def load_jobs(self): |
---|
1149 | |
---|
1150 | self.list_jobs.clear() |
---|
1151 | self.push_copy.setEnabled(False) |
---|
1152 | self.push_create_set.setEnabled(False) |
---|
1153 | |
---|
1154 | self.line_path.setText(job_dir + "/") |
---|
1155 | |
---|
1156 | list_of_files = os.listdir(job_dir) |
---|
1157 | |
---|
1158 | |
---|
1159 | for i in range(0,len(list_of_files)): |
---|
1160 | tmp_file = job_dir + "/" + list_of_files[i] |
---|
1161 | |
---|
1162 | if ( os.path.isdir(tmp_file) ): |
---|
1163 | self.list_jobs.addItem(str(list_of_files[i])) |
---|
1164 | |
---|
1165 | |
---|
1166 | |
---|
1167 | # Update input and user code lists |
---|
1168 | def update_input(self): |
---|
1169 | |
---|
1170 | self.list_input.clear() |
---|
1171 | self.list_user.clear() |
---|
1172 | self.list_monitoring.clear() |
---|
1173 | self.list_output.clear() |
---|
1174 | self.push_copy.setEnabled(True) |
---|
1175 | self.push_create_set.setEnabled(True) |
---|
1176 | |
---|
1177 | job_to_show = job_dir + "/" + self.list_jobs.currentItem().text() + "/INPUT" |
---|
1178 | |
---|
1179 | if ( os.path.isdir(job_to_show) ): |
---|
1180 | |
---|
1181 | list_of_files = os.listdir(job_to_show) |
---|
1182 | |
---|
1183 | for i in range(0,len(list_of_files)): |
---|
1184 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
1185 | |
---|
1186 | if ( os.path.isfile(tmp_file) ): |
---|
1187 | self.list_input.addItem(str(list_of_files[i])) |
---|
1188 | |
---|
1189 | job_to_show = job_dir + "/" + self.list_jobs.currentItem().text() + "/USER_CODE" |
---|
1190 | |
---|
1191 | if ( os.path.isdir(job_to_show) ): |
---|
1192 | |
---|
1193 | list_of_files = os.listdir(job_to_show) |
---|
1194 | |
---|
1195 | for i in range(0,len(list_of_files)): |
---|
1196 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
1197 | |
---|
1198 | if ( os.path.isfile(tmp_file) ): |
---|
1199 | self.list_user.addItem(str(list_of_files[i])) |
---|
1200 | |
---|
1201 | job_to_show = job_dir + "/" + self.list_jobs.currentItem().text() + "/MONITORING" |
---|
1202 | |
---|
1203 | if ( os.path.isdir(job_to_show) ): |
---|
1204 | |
---|
1205 | list_of_files = os.listdir(job_to_show) |
---|
1206 | |
---|
1207 | for i in range(0,len(list_of_files)): |
---|
1208 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
1209 | |
---|
1210 | if ( os.path.isfile(tmp_file) ): |
---|
1211 | self.list_monitoring.addItem(str(list_of_files[i])) |
---|
1212 | |
---|
1213 | job_to_show = job_dir + "/" + self.list_jobs.currentItem().text() + "/OUTPUT" |
---|
1214 | |
---|
1215 | if ( os.path.isdir(job_to_show) ): |
---|
1216 | |
---|
1217 | list_of_files = os.listdir(job_to_show) |
---|
1218 | |
---|
1219 | for i in range(0,len(list_of_files)): |
---|
1220 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
1221 | |
---|
1222 | if ( os.path.isfile(tmp_file) ): |
---|
1223 | self.list_output.addItem(str(list_of_files[i])) |
---|
1224 | |
---|
1225 | self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").setText(self.list_jobs.currentItem().text()) |
---|
1226 | self.group_history.findChild(QtGui.QListWidget,"list_jobname").clearSelection() |
---|
1227 | |
---|
1228 | # Change palmrunline accordingly |
---|
1229 | self.change_commandline("r","") |
---|
1230 | self.change_commandline("a","") |
---|
1231 | |
---|
1232 | |
---|
1233 | # Make a copy of a job |
---|
1234 | def copy_job(self): |
---|
1235 | |
---|
1236 | self.setEnabled(False) |
---|
1237 | old_job_name = self.list_jobs.currentItem().text() |
---|
1238 | |
---|
1239 | text, ret = QtGui.QInputDialog.getText(self, "Copy job", "Enter new job name:", mode = QtGui.QLineEdit.Normal, text = old_job_name) |
---|
1240 | |
---|
1241 | if ( ret ): |
---|
1242 | new_job_name = str(text) |
---|
1243 | else: |
---|
1244 | self.setEnabled(True) |
---|
1245 | return |
---|
1246 | |
---|
1247 | new_input_dir = job_dir + "/" + new_job_name + "/INPUT" |
---|
1248 | |
---|
1249 | # check if a job exists with the new job name |
---|
1250 | if ( os.path.isdir(new_input_dir) ): |
---|
1251 | notify = QtGui.QMessageBox.warning(self,'Create new job directory',"Error. Could not create job directory. A job with the new name already exists.") |
---|
1252 | self.setEnabled(True) |
---|
1253 | return |
---|
1254 | else: |
---|
1255 | os.makedirs(new_input_dir) |
---|
1256 | |
---|
1257 | # copy and rename input files (if present) |
---|
1258 | job_to_copy = job_dir + "/" + old_job_name + "/INPUT" |
---|
1259 | |
---|
1260 | if ( os.path.isdir(job_to_copy) ): |
---|
1261 | |
---|
1262 | list_of_files = os.listdir(job_to_copy) |
---|
1263 | |
---|
1264 | for i in range(0,len(list_of_files)): |
---|
1265 | |
---|
1266 | tmp_file = job_to_copy + "/" + list_of_files[i] |
---|
1267 | new_file = new_input_dir + "/" + list_of_files[i].replace(old_job_name, new_job_name) |
---|
1268 | shutil.copy(tmp_file, new_file) |
---|
1269 | |
---|
1270 | |
---|
1271 | |
---|
1272 | |
---|
1273 | new_user_dir = job_dir + "/" + new_job_name + "/USER_CODE" |
---|
1274 | |
---|
1275 | # check if user code exists in the new job directory |
---|
1276 | if ( os.path.isdir(new_user_dir) ): |
---|
1277 | notify = QtGui.QMessageBox.warning(self,'Create new user code directory',"Error. Could not create user code directory. A user code directiory with the new name already exists.") |
---|
1278 | self.setEnabled(True) |
---|
1279 | return |
---|
1280 | else: |
---|
1281 | os.makedirs(new_user_dir) |
---|
1282 | |
---|
1283 | |
---|
1284 | # copy user code files (if present) |
---|
1285 | user_to_copy = job_dir + "/" + old_job_name + "/USER_CODE" |
---|
1286 | |
---|
1287 | if ( os.path.isdir(user_to_copy) ): |
---|
1288 | |
---|
1289 | list_of_files = os.listdir(user_to_copy) |
---|
1290 | |
---|
1291 | for i in range(0,len(list_of_files)): |
---|
1292 | |
---|
1293 | tmp_file = user_to_copy + "/" + list_of_files[i] |
---|
1294 | new_file = new_user_dir + "/" + list_of_files[i] |
---|
1295 | shutil.copy(tmp_file, new_file) |
---|
1296 | |
---|
1297 | self.load_jobs() |
---|
1298 | self.list_input.clear() |
---|
1299 | self.list_user.clear() |
---|
1300 | self.list_monitoring.clear() |
---|
1301 | self.list_output.clear() |
---|
1302 | self.setEnabled(True) |
---|
1303 | |
---|
1304 | |
---|
1305 | # Create a whole set of jobs |
---|
1306 | def create_set(self): |
---|
1307 | |
---|
1308 | global set_list |
---|
1309 | # disable mainwindow |
---|
1310 | self.setEnabled(False) |
---|
1311 | |
---|
1312 | # show Options Dialog |
---|
1313 | opt = CreateSetBox() |
---|
1314 | opt.exec_() |
---|
1315 | |
---|
1316 | old_job_name = self.list_jobs.currentItem().text() |
---|
1317 | |
---|
1318 | for j in range(0,len(set_list)): |
---|
1319 | |
---|
1320 | if ( set_list[j] != "" ): |
---|
1321 | new_job_name = str(set_list[j]) |
---|
1322 | new_input_dir = job_dir + "/" + str(set_list[j]) + "/INPUT" |
---|
1323 | else: |
---|
1324 | continue |
---|
1325 | |
---|
1326 | # check if a job exists with the new job name |
---|
1327 | if ( os.path.isdir(new_input_dir) ): |
---|
1328 | notify = QtGui.QMessageBox.warning(self,'Create new job directory',"Error. Could not create job directory. A job with the new name already exists.") |
---|
1329 | self.setEnabled(True) |
---|
1330 | return |
---|
1331 | else: |
---|
1332 | os.makedirs(new_input_dir) |
---|
1333 | |
---|
1334 | # copy and rename input files (if present) |
---|
1335 | job_to_copy = job_dir + "/" + old_job_name + "/INPUT" |
---|
1336 | |
---|
1337 | if ( os.path.isdir(job_to_copy) ): |
---|
1338 | |
---|
1339 | list_of_files = os.listdir(job_to_copy) |
---|
1340 | |
---|
1341 | for i in range(0,len(list_of_files)): |
---|
1342 | |
---|
1343 | tmp_file = job_to_copy + "/" + list_of_files[i] |
---|
1344 | new_file = new_input_dir + "/" + list_of_files[i].replace(old_job_name, new_job_name) |
---|
1345 | shutil.copy(tmp_file, new_file) |
---|
1346 | |
---|
1347 | |
---|
1348 | new_user_dir = job_dir + "/" + new_job_name + "/USER_CODE" |
---|
1349 | |
---|
1350 | # check if user code exists in the new job directory |
---|
1351 | if ( os.path.isdir(new_user_dir) ): |
---|
1352 | notify = QtGui.QMessageBox.warning(self,'Create new user code directory',"Error. Could not create user code directory. A user code directiory with the new name already exists.") |
---|
1353 | self.setEnabled(True) |
---|
1354 | return |
---|
1355 | else: |
---|
1356 | os.makedirs(new_user_dir) |
---|
1357 | |
---|
1358 | |
---|
1359 | # copy user code files (if present) |
---|
1360 | user_to_copy = job_dir + "/" + old_job_name + "/USER_CODE" |
---|
1361 | |
---|
1362 | if ( os.path.isdir(user_to_copy) ): |
---|
1363 | |
---|
1364 | list_of_files = os.listdir(user_to_copy) |
---|
1365 | |
---|
1366 | for i in range(0,len(list_of_files)): |
---|
1367 | |
---|
1368 | tmp_file = user_to_copy + "/" + list_of_files[i] |
---|
1369 | new_file = new_user_dir + "/" + list_of_files[i] |
---|
1370 | shutil.copy(tmp_file, new_file) |
---|
1371 | |
---|
1372 | self.load_jobs() |
---|
1373 | self.list_input.clear() |
---|
1374 | self.list_user.clear() |
---|
1375 | self.list_monitoring.clear() |
---|
1376 | self.list_output.clear() |
---|
1377 | |
---|
1378 | self.setEnabled(True) |
---|
1379 | set_list = [] |
---|
1380 | |
---|
1381 | # Add a custom context menu |
---|
1382 | def openmenuinput(self, position): |
---|
1383 | |
---|
1384 | menu = QtGui.QMenu() |
---|
1385 | |
---|
1386 | selection = self.list_input.selectedItems() |
---|
1387 | |
---|
1388 | if ( len(selection) != 0 ): |
---|
1389 | |
---|
1390 | openAction = menu.addAction('Open selected files') |
---|
1391 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
1392 | openAction.triggered.connect(self.OpenFilesInput) |
---|
1393 | action = menu.exec_(self.list_input.mapToGlobal(position)) |
---|
1394 | |
---|
1395 | # Add a custom context menu |
---|
1396 | def openmenuuser(self, position): |
---|
1397 | |
---|
1398 | menu = QtGui.QMenu() |
---|
1399 | |
---|
1400 | selection = self.list_user.selectedItems() |
---|
1401 | |
---|
1402 | if ( len(selection) != 0 ): |
---|
1403 | |
---|
1404 | openAction = menu.addAction('Open selected files') |
---|
1405 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
1406 | openAction.triggered.connect(self.OpenFilesUser) |
---|
1407 | action = menu.exec_(self.list_user.mapToGlobal(position)) |
---|
1408 | |
---|
1409 | # Add a custom context menu |
---|
1410 | def openmenuoutput(self, position): |
---|
1411 | |
---|
1412 | menu = QtGui.QMenu() |
---|
1413 | |
---|
1414 | selection = self.list_output.selectedItems() |
---|
1415 | |
---|
1416 | if ( len(selection) != 0 ): |
---|
1417 | |
---|
1418 | openAction = menu.addAction('Open selected files') |
---|
1419 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
1420 | openAction.triggered.connect(self.OpenFilesOutput) |
---|
1421 | action = menu.exec_(self.list_output.mapToGlobal(position)) |
---|
1422 | |
---|
1423 | # Add a custom context menu |
---|
1424 | def openmenumonitoring(self, position): |
---|
1425 | |
---|
1426 | menu = QtGui.QMenu() |
---|
1427 | |
---|
1428 | selection = self.list_monitoring.selectedItems() |
---|
1429 | |
---|
1430 | if ( len(selection) != 0 ): |
---|
1431 | |
---|
1432 | openAction = menu.addAction('Open selected files') |
---|
1433 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
1434 | openAction.triggered.connect(self.OpenFilesMonitoring) |
---|
1435 | action = menu.exec_(self.list_monitoring.mapToGlobal(position)) |
---|
1436 | |
---|
1437 | def OpenFilesInput(self): |
---|
1438 | |
---|
1439 | sel_job = self.list_jobs.currentItem().text() |
---|
1440 | sel_files = self.list_input.selectedItems() |
---|
1441 | |
---|
1442 | input_dir = job_dir + "/" + sel_job + "/INPUT/" |
---|
1443 | |
---|
1444 | open_files = "" |
---|
1445 | for i in range(0,len(sel_files)): |
---|
1446 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text() + "; " |
---|
1447 | |
---|
1448 | os.system(str(open_files)) |
---|
1449 | |
---|
1450 | def OpenFilesUser(self): |
---|
1451 | |
---|
1452 | sel_job = self.list_jobs.currentItem().text() |
---|
1453 | sel_files = self.list_user.selectedItems() |
---|
1454 | |
---|
1455 | input_dir = job_dir + "/" + sel_job + "/USER_CODE/" |
---|
1456 | |
---|
1457 | open_files = "" |
---|
1458 | for i in range(0,len(sel_files)): |
---|
1459 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text() + "; " |
---|
1460 | |
---|
1461 | os.system(str(open_files)) |
---|
1462 | selection = self.list_jobs.selectedItems() |
---|
1463 | |
---|
1464 | def OpenFilesMonitoring(self): |
---|
1465 | |
---|
1466 | sel_job = self.list_jobs.currentItem().text() |
---|
1467 | sel_files = self.list_monitoring.selectedItems() |
---|
1468 | |
---|
1469 | input_dir = job_dir + "/" + sel_job + "/MONITORING/" |
---|
1470 | |
---|
1471 | open_files = "" |
---|
1472 | for i in range(0,len(sel_files)): |
---|
1473 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text() + "; " |
---|
1474 | |
---|
1475 | os.system(str(open_files)) |
---|
1476 | selection = self.list_jobs.selectedItems() |
---|
1477 | |
---|
1478 | def OpenFilesOutput(self): |
---|
1479 | |
---|
1480 | sel_job = self.list_jobs.currentItem().text() |
---|
1481 | sel_files = self.list_output.selectedItems() |
---|
1482 | |
---|
1483 | input_dir = job_dir + "/" + sel_job + "/OUTPUT/" |
---|
1484 | |
---|
1485 | open_files = "" |
---|
1486 | for i in range(0,len(sel_files)): |
---|
1487 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text() + "; " |
---|
1488 | |
---|
1489 | os.system(str(open_files)) |
---|
1490 | selection = self.list_jobs.selectedItems() |
---|
1491 | |
---|
1492 | # Message box for showing RUN_CONTROL output |
---|
1493 | class CreateSetBox(QtGui.QDialog): |
---|
1494 | def __init__(self): |
---|
1495 | |
---|
1496 | super(CreateSetBox, self).__init__() |
---|
1497 | |
---|
1498 | uic.loadUi(palm_bin + '/palmrungui_files/create_set.ui', self) |
---|
1499 | |
---|
1500 | self.show() |
---|
1501 | |
---|
1502 | return |
---|
1503 | |
---|
1504 | # Cancel button |
---|
1505 | def rejected(self): |
---|
1506 | |
---|
1507 | self.close() |
---|
1508 | |
---|
1509 | return |
---|
1510 | |
---|
1511 | |
---|
1512 | # OK button |
---|
1513 | def accept(self): |
---|
1514 | |
---|
1515 | global set_list |
---|
1516 | |
---|
1517 | text = self.list.toPlainText() |
---|
1518 | set_list = text.split('\n') |
---|
1519 | self.close() |
---|
1520 | |
---|
1521 | return |
---|
1522 | |
---|
1523 | |
---|
1524 | |
---|
1525 | |
---|
1526 | if __name__ == "__main__": |
---|
1527 | app = QtGui.QApplication(sys.argv) |
---|
1528 | window = Mainwindow() |
---|
1529 | window.show() |
---|
1530 | sys.exit(app.exec_()) |
---|