1 | #!/usr/bin/python -B |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | #--------------------------------------------------------------------------------# |
---|
4 | # This file is part of PALM. |
---|
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-2017 Leibniz Universitaet Hannover |
---|
18 | #--------------------------------------------------------------------------------# |
---|
19 | # |
---|
20 | # Current revisions: |
---|
21 | # ----------------- |
---|
22 | # |
---|
23 | # |
---|
24 | # Former revisions: |
---|
25 | # ----------------- |
---|
26 | # $Id: palmrungui.py 2480 2017-09-19 06:24:14Z raasch $ |
---|
27 | # option -A (project account number) added |
---|
28 | # |
---|
29 | # 2477 2017-09-18 08:42:29Z maronga |
---|
30 | # Renamed restart run appendix from "f" to "r". Bugfix for displaying restart runs.> |
---|
31 | # Revised list of recently submitted jobs |
---|
32 | # |
---|
33 | # 2413 2017-09-06 12:48:29Z maronga |
---|
34 | # Renamed to palmrungui and adapted for use with palmrun instead of mrun. |
---|
35 | # |
---|
36 | # 2316 2017-07-20 07:53:42Z maronga |
---|
37 | # Initial revision in python |
---|
38 | # |
---|
39 | # |
---|
40 | # |
---|
41 | # Description: |
---|
42 | # ------------ |
---|
43 | # Graphical user interface for the palmrun script. |
---|
44 | # @author Felix Gaschler |
---|
45 | # @author Björn Maronga (maronga@muk.uni-hannover.de) |
---|
46 | # |
---|
47 | # Instructions: |
---|
48 | # ------------- |
---|
49 | # |
---|
50 | #------------------------------------------------------------------------------! |
---|
51 | |
---|
52 | import sys |
---|
53 | import subprocess |
---|
54 | from PyQt4 import QtCore, QtGui, uic |
---|
55 | from PyQt4.QtCore import QProcess |
---|
56 | from time import strftime |
---|
57 | import os |
---|
58 | |
---|
59 | |
---|
60 | # Determine PALM directories |
---|
61 | try: |
---|
62 | devnull = open(os.devnull, 'w') |
---|
63 | out = subprocess.check_output("echo $PALM_BIN", shell=True, stderr=subprocess.STDOUT) |
---|
64 | palm_bin = out.rstrip() |
---|
65 | palm_dir = out.split("palm")[0] + "palm/" + out.split("palm")[1].split("/")[1] |
---|
66 | out = None |
---|
67 | except: |
---|
68 | print "Error. $PALM_BIN is not set." |
---|
69 | raise SystemExit |
---|
70 | |
---|
71 | |
---|
72 | palmrunline = "" |
---|
73 | name_of_file = os.path.basename(__file__) |
---|
74 | |
---|
75 | palmrungui_path = os.path.realpath(__file__) |
---|
76 | version_path = palmrungui_path[:len(palmrungui_path)-14-len(name_of_file)-1] |
---|
77 | |
---|
78 | Ui_MainWindow = uic.loadUiType("%s/palmrungui_files/mainwindow.ui" % (palm_bin))[0] |
---|
79 | Ui_helpDialog = uic.loadUiType("%s/palmrungui_files/help.ui" % (palm_bin))[0] |
---|
80 | Ui_aboutDialog = uic.loadUiType("%s/palmrungui_files/about.ui" % (palm_bin))[0] |
---|
81 | |
---|
82 | class HelpDialog(QtGui.QDialog,Ui_helpDialog): |
---|
83 | def __init__(self, parent=None): |
---|
84 | super(HelpDialog,self).__init__() |
---|
85 | self.setupUi(self) |
---|
86 | |
---|
87 | class AboutDialog(QtGui.QDialog,Ui_aboutDialog): |
---|
88 | def __init__(self, parent=None): |
---|
89 | super(AboutDialog,self).__init__() |
---|
90 | self.setupUi(self) |
---|
91 | |
---|
92 | class Mainwindow(QtGui.QMainWindow, Ui_MainWindow): |
---|
93 | def __init__(self, parent=None): |
---|
94 | super(Mainwindow, self).__init__() |
---|
95 | |
---|
96 | self.setupUi(self) |
---|
97 | self.recent_jobs(50) |
---|
98 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
99 | commandline.setText("") |
---|
100 | |
---|
101 | self.tabWidget.setCurrentIndex(0) |
---|
102 | |
---|
103 | filename = "%s/.palmrun.gui.default" % (version_path) |
---|
104 | if os.path.exists(filename): |
---|
105 | pass |
---|
106 | else: |
---|
107 | return |
---|
108 | |
---|
109 | file = open(filename, "r") |
---|
110 | if ( file is not None ): |
---|
111 | # File opened successfully |
---|
112 | palmrunline = file.readline() |
---|
113 | #if neue zeile zeichen |
---|
114 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
115 | file.close() |
---|
116 | |
---|
117 | # In case a palmrunline was found, load it to mainwindow |
---|
118 | if ( palmrunline != ""): |
---|
119 | palmrunline = palmrunline[17:] |
---|
120 | commandline.setText(palmrunline) |
---|
121 | self.setup_gui(palmrunline) |
---|
122 | |
---|
123 | |
---|
124 | # starts xterm with palmrun commandline |
---|
125 | ####################################### |
---|
126 | def startpalmrun(self): |
---|
127 | palmrunline = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()) |
---|
128 | userline = str(self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text()) |
---|
129 | |
---|
130 | # Check for empty line |
---|
131 | palmrunline_save = palmrunline; |
---|
132 | if (userline != ""): |
---|
133 | palmrunline = "%s %s" % (palmrunline,userline) |
---|
134 | history_line = palmrunline |
---|
135 | |
---|
136 | # Disable the main window |
---|
137 | self.tabWidget.setEnabled(False) |
---|
138 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
139 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("wait...") |
---|
140 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmrun in xterm...") |
---|
141 | |
---|
142 | # Wait until all commands have been executed (ugly) ? |
---|
143 | #for i in range(0,21): |
---|
144 | # qApp->processEvents() |
---|
145 | |
---|
146 | # Start xterm as QProcess |
---|
147 | palmrun = QProcess() |
---|
148 | palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels |
---|
149 | palmrun.setWorkingDirectory(version_path) |
---|
150 | |
---|
151 | geomet = self.frameGeometry() |
---|
152 | |
---|
153 | posx = geomet.x()+geomet.width() |
---|
154 | posy = geomet.y() |
---|
155 | |
---|
156 | s = " -title \"Executing palmrun...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy) |
---|
157 | palmrunline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'")) |
---|
158 | |
---|
159 | mString = "xterm %s" % (palmrunline) |
---|
160 | palmrun.start(mString); |
---|
161 | |
---|
162 | if( palmrun.waitForStarted() is False ): |
---|
163 | return |
---|
164 | |
---|
165 | # Wait until palmrun has finished or wait for 200 minutes |
---|
166 | palmrun.waitForFinished(3600000); |
---|
167 | |
---|
168 | # Jobs has been submitted or aborted. Continuing... |
---|
169 | # Save the palmrun command to history file |
---|
170 | filename = "%s/.palm.history" % (version_path) |
---|
171 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
172 | |
---|
173 | file = open(filename,"a") |
---|
174 | s = "%s %s\n" % (tmstamp,history_line) |
---|
175 | file.write(s) |
---|
176 | file.close() |
---|
177 | |
---|
178 | # Enable main window again |
---|
179 | self.tabWidget.setEnabled(True) |
---|
180 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
181 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("Start palmrun") |
---|
182 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline_save); |
---|
183 | |
---|
184 | # Reload recent jobs |
---|
185 | self.recent_jobs(50) |
---|
186 | |
---|
187 | |
---|
188 | # loads recent jobs |
---|
189 | ###################################### |
---|
190 | def recent_jobs(self, number): |
---|
191 | fileDir = "%s/.palm.history" % (version_path) |
---|
192 | if os.path.exists(fileDir): |
---|
193 | pass |
---|
194 | else: |
---|
195 | return |
---|
196 | |
---|
197 | file = open(fileDir,"r") |
---|
198 | history = file.readlines() |
---|
199 | tmphistory = list() |
---|
200 | file.close(); |
---|
201 | j = 0; |
---|
202 | |
---|
203 | list_jobname = self.group_job.findChild(QtGui.QListWidget,"list_jobname") |
---|
204 | list_jobname.clear() |
---|
205 | |
---|
206 | # Read history entries and append to recent job list |
---|
207 | i=len(history)-1 |
---|
208 | count = 0 |
---|
209 | while i>=0 and count<number: |
---|
210 | timestamp = history[i][:16] |
---|
211 | listitem = history[i][17:len(history[i])-1] |
---|
212 | matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly) |
---|
213 | |
---|
214 | if ( len(matchitems) == 0 ): |
---|
215 | listitem = filter(None,listitem.split(" -d"))[1] |
---|
216 | listitem = filter(None,listitem.split(" -"))[0] |
---|
217 | listitem = listitem.replace(" ",""); |
---|
218 | list_jobname.addItem(listitem); |
---|
219 | s = "%s (%s)" % (listitem,timestamp) |
---|
220 | tmphistory.append(s); |
---|
221 | count = count +1 |
---|
222 | j = j+1 |
---|
223 | |
---|
224 | if ( j == number ): |
---|
225 | break |
---|
226 | i = i-1 |
---|
227 | |
---|
228 | # Send to list |
---|
229 | list_jobname.clear(); |
---|
230 | |
---|
231 | i=0 |
---|
232 | while i<len(tmphistory): |
---|
233 | list_jobname.addItem(tmphistory[i]); |
---|
234 | i = i+1 |
---|
235 | |
---|
236 | |
---|
237 | # Enables coupled settings |
---|
238 | ############################### |
---|
239 | def enable_coupled(self): |
---|
240 | coupledState = self.group_job.findChild(QtGui.QComboBox, "drop_job").currentText() |
---|
241 | group = self.group_execution.findChild(QtGui.QGroupBox, "group_coupled") |
---|
242 | |
---|
243 | if (coupledState == "Restart run (coupled atmosphere ocean)" or coupledState == "Initial run (coupled atmosphere ocean)"): |
---|
244 | self.group_coupled.setEnabled(True) |
---|
245 | else: |
---|
246 | self.group_coupled.setEnabled(False) |
---|
247 | |
---|
248 | |
---|
249 | # select a job via "select"-button |
---|
250 | ################################ |
---|
251 | def choosejob(self): |
---|
252 | jobDir = "%s/JOBS" % (version_path) |
---|
253 | |
---|
254 | # Pick a job from dialog |
---|
255 | filename = QtGui.QFileDialog.getExistingDirectory(self, "Open a folder", jobDir, QtGui.QFileDialog.ShowDirsOnly) |
---|
256 | |
---|
257 | # If a file was selected, load it into mainwindow |
---|
258 | if ( filename != ""): |
---|
259 | jobname = os.path.basename(unicode(filename)) |
---|
260 | self.group_job.findChild(QtGui.QLineEdit,"line_jobname").setText(jobname) |
---|
261 | self.group_job.findChild(QtGui.QListWidget,"list_jobname").clearSelection() |
---|
262 | |
---|
263 | # Change palmrunline accordingly |
---|
264 | self.change_commandline("d","") |
---|
265 | self.change_commandline("a","") |
---|
266 | return |
---|
267 | else: |
---|
268 | return |
---|
269 | |
---|
270 | |
---|
271 | # select a job via click from list |
---|
272 | ################################# |
---|
273 | def choosejob_list(self): |
---|
274 | # Get selected item from list |
---|
275 | list_jobname = self.group_job.findChild(QtGui.QListWidget,"list_jobname") |
---|
276 | filename = str(list_jobname.currentItem().text()) |
---|
277 | itemint = list_jobname.currentRow() |
---|
278 | |
---|
279 | # Reload list |
---|
280 | self.setupUi(self) |
---|
281 | self.recent_jobs(50) |
---|
282 | |
---|
283 | # Set selected item to jobname |
---|
284 | list_jobname.item(itemint).setSelected(True); |
---|
285 | |
---|
286 | timestamp = filename[len(filename)-17:][:16] |
---|
287 | jobname = filename[:len(filename) - 19]; |
---|
288 | |
---|
289 | fileDir = "%s/.palm.history" % (version_path) |
---|
290 | file = open(fileDir,"r") |
---|
291 | history = file.readlines() |
---|
292 | tmphistory = list() |
---|
293 | file.close(); |
---|
294 | |
---|
295 | i = len(history) |
---|
296 | while i>=1: |
---|
297 | listitem = history[i-1][17:len(history[i-1])-1] |
---|
298 | listitem = filter(None,listitem.split(" -d"))[1] |
---|
299 | listitem = filter(None,listitem.split(" -"))[0] |
---|
300 | listitem = listitem.replace(" ",""); |
---|
301 | |
---|
302 | # Select command line with correct timestamp and jobname |
---|
303 | if (history[i-1][:16] == timestamp and listitem == jobname): |
---|
304 | palmrunline = history[i-1] |
---|
305 | palmrunline = palmrunline[17:] |
---|
306 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
307 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline); |
---|
308 | self.setup_gui(palmrunline); |
---|
309 | self.list_jobname.item(itemint).setSelected(True); |
---|
310 | |
---|
311 | return |
---|
312 | i = i-1 |
---|
313 | |
---|
314 | # Change run identifer (initial, restart, coupled...) |
---|
315 | ###################################################### |
---|
316 | def change_rc_list(self): |
---|
317 | drop_job = self.group_job.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
318 | self.change_commandline("a","") |
---|
319 | |
---|
320 | # Enable PE distribution for atmosphere/ocean |
---|
321 | if ( drop_job == "Restart run (coupled atmosphere ocean)" or drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
322 | drop_atmos = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").text() |
---|
323 | drop_ocean = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").text() |
---|
324 | s = "%s %s" % (drop_atmos,drop_ocean) |
---|
325 | self.change_commandline("Y",s) |
---|
326 | |
---|
327 | |
---|
328 | if ( drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)"): |
---|
329 | self.change_commandline("d","") |
---|
330 | |
---|
331 | # Check of ocean runs |
---|
332 | else: |
---|
333 | self.delete_commandline("Y") |
---|
334 | if (drop_job == "Precursor run (ocean)"): |
---|
335 | self.activate_flag("y") |
---|
336 | else: |
---|
337 | self.deactivate_flag("y") |
---|
338 | |
---|
339 | # changes commandline depending on parameters |
---|
340 | ########################################################## |
---|
341 | def change_commandline(self, id_str, fwt_str): |
---|
342 | fwt_str = str(fwt_str) |
---|
343 | initialize = False |
---|
344 | palmrunline = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()) |
---|
345 | s = " -%s " % (id_str) |
---|
346 | splitline = filter(None,palmrunline.split(s)) |
---|
347 | |
---|
348 | if ( len(splitline) == 0 ): |
---|
349 | splitline.append("palmrun") |
---|
350 | splitline.append(" ") |
---|
351 | initialize = True |
---|
352 | |
---|
353 | elif ( len(splitline) == 1 ): |
---|
354 | splitline.append(" ") |
---|
355 | |
---|
356 | param = splitline[1].split("-") |
---|
357 | |
---|
358 | # Change in parameter "d" (jobname) |
---|
359 | if (id_str == "d"): |
---|
360 | filename = str(self.group_job.findChild(QtGui.QLineEdit,"line_jobname").text()) |
---|
361 | s = filename.split("JOBS/") |
---|
362 | param[0] = s[len(s)-1] |
---|
363 | |
---|
364 | if ( initialize == True ):#and self.group_runcontrol.isEnabled() == True ): |
---|
365 | self.group_runcontrol.setEnabled(True) |
---|
366 | self.group_execution.setEnabled(True) |
---|
367 | self.group_job.findChild(QtGui.QComboBox,"drop_job").setEnabled(True) |
---|
368 | self.group_advanced.setEnabled(True) |
---|
369 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
370 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(True) |
---|
371 | |
---|
372 | elif ( param[0] == ""): |
---|
373 | self.group_runcontrol.setEnabled(False) |
---|
374 | self.group_execution.setEnabled(False) |
---|
375 | self.group_job.findChild(QtGui.QComboBox,"drop_job").setEnabled(False) |
---|
376 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
377 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(False) |
---|
378 | self.group_advanced.setEnabled(False) |
---|
379 | self.delete_commandline("d") |
---|
380 | self.change_commandline("a","remove") |
---|
381 | self.group_job.findChild(QtGui.QLabel,"label_usercode").setText("") |
---|
382 | return 1 |
---|
383 | |
---|
384 | else: |
---|
385 | # Check if user code is available |
---|
386 | usercode = "%s/JOBS/%s/USER_CODE" % (version_path,param[0]) |
---|
387 | |
---|
388 | if (os.path.exists(usercode) is True): |
---|
389 | self.group_job.findChild(QtGui.QLabel,"label_usercode").setText("<font color='green'>User code found.</font>") |
---|
390 | |
---|
391 | else: |
---|
392 | self.group_job.findChild(QtGui.QLabel,"label_usercode").setText("<font color='red'>Warning: no user code found!</font>") |
---|
393 | |
---|
394 | |
---|
395 | # Check if _pdf file is available, otherwise notice user |
---|
396 | drop_job = self.group_job.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
397 | if ( self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() == 2 or |
---|
398 | drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)" ): |
---|
399 | |
---|
400 | jobname = self.group_job.findChild(QtGui.QLineEdit, "line_jobname").text() |
---|
401 | restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname) |
---|
402 | |
---|
403 | if (os.path.exists(restartfile) == True): |
---|
404 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
405 | |
---|
406 | |
---|
407 | if ( drop_job == "Restart run (coupled atmosphere ocean)" ): |
---|
408 | restartfileo = "%s/JOBS/%s/INPUT/%s_p3dor" % (version_path,jobname,jobname) |
---|
409 | if (os.path.exists(restartfileo) == True): |
---|
410 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("hooo") |
---|
411 | |
---|
412 | else: |
---|
413 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dor file found!</font>") |
---|
414 | |
---|
415 | else: |
---|
416 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>") |
---|
417 | |
---|
418 | |
---|
419 | |
---|
420 | |
---|
421 | self.group_runcontrol.setEnabled(True) |
---|
422 | self.group_execution.setEnabled(True) |
---|
423 | self.drop_job.setEnabled(True) |
---|
424 | self.group_advanced.setEnabled(True) |
---|
425 | |
---|
426 | # Change in parameter "a" (run control list) |
---|
427 | elif (id_str == "a"): |
---|
428 | status_ts = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_ts").checkState() |
---|
429 | status_pr = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_pr").checkState() |
---|
430 | status_xy = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_xy").checkState() |
---|
431 | status_xz = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_xz").checkState() |
---|
432 | status_yz = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_yz").checkState() |
---|
433 | status_3d = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_3d").checkState() |
---|
434 | status_ma = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_ma").checkState() |
---|
435 | status_sp = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_sp").checkState() |
---|
436 | status_pts = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_pts").checkState() |
---|
437 | status_prt = self.group_runcontrol.findChild(QtGui.QCheckBox,"check_prt").checkState() |
---|
438 | |
---|
439 | drop_job = self.group_job.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
440 | rc_flag = "#" |
---|
441 | |
---|
442 | if (drop_job == "Initial run"): |
---|
443 | rc_flag = "#" |
---|
444 | |
---|
445 | elif (drop_job == "Restart run"): |
---|
446 | rc_flag = "r" |
---|
447 | |
---|
448 | elif (drop_job == "Precursor run (atmosphere)"): |
---|
449 | rc_flag = "#" |
---|
450 | |
---|
451 | elif (drop_job == "Precursor run (ocean)"): |
---|
452 | rc_flag = "o#" |
---|
453 | |
---|
454 | elif (drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
455 | rc_flag = "#" |
---|
456 | |
---|
457 | elif (drop_job == "Restart run (coupled atmosphere ocean)"): |
---|
458 | rc_flag = "r" |
---|
459 | |
---|
460 | param[0] = "\"d3%s" % (rc_flag) |
---|
461 | |
---|
462 | if (status_ts == 2): |
---|
463 | param[0] = "%s ts%s" % (param[0],rc_flag) |
---|
464 | |
---|
465 | if (status_pr == 2): |
---|
466 | param[0] = "%s pr%s" % (param[0],rc_flag) |
---|
467 | |
---|
468 | if (status_xy == 2): |
---|
469 | param[0] = "%s xy%s" % (param[0],rc_flag) |
---|
470 | |
---|
471 | if (status_xz == 2): |
---|
472 | param[0] = "%s xz%s" % (param[0],rc_flag) |
---|
473 | |
---|
474 | if (status_yz == 2): |
---|
475 | param[0] = "%s yz%s" % (param[0],rc_flag) |
---|
476 | |
---|
477 | if (status_3d == 2): |
---|
478 | param[0] = "%s 3d%s" % (param[0],rc_flag) |
---|
479 | |
---|
480 | if (status_ma == 2): |
---|
481 | param[0] = "%s ma%s" % (param[0],rc_flag) |
---|
482 | |
---|
483 | if (status_sp == 2): |
---|
484 | param[0] = "%s sp%s" % (param[0],rc_flag) |
---|
485 | |
---|
486 | if (status_prt == 2): |
---|
487 | param[0] = "%s prt%s" % (param[0],rc_flag) |
---|
488 | |
---|
489 | if (status_pts == 2): |
---|
490 | param[0] = "%s pts%s" % (param[0],rc_flag) |
---|
491 | |
---|
492 | |
---|
493 | if (drop_job == "Restart run (coupled atmosphere ocean)" or drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
494 | if (rc_flag == "#"): |
---|
495 | rc_flag = "o#" |
---|
496 | else: |
---|
497 | rc_flag = "of" |
---|
498 | |
---|
499 | param[0] = "%s d3%s" % (param[0],rc_flag) |
---|
500 | |
---|
501 | if (status_ts == 2): |
---|
502 | param[0] = "%s ts%s" % (param[0],rc_flag) |
---|
503 | |
---|
504 | if (status_pr == 2): |
---|
505 | param[0] = "%s pr%s" % (param[0],rc_flag) |
---|
506 | |
---|
507 | if (status_xy == 2): |
---|
508 | param[0] = "%s xy%s" % (param[0],rc_flag) |
---|
509 | |
---|
510 | if (status_xz == 2): |
---|
511 | param[0] = "%s xz%s" % (param[0],rc_flag) |
---|
512 | |
---|
513 | if (status_yz == 2): |
---|
514 | param[0] = "%s yz%s" % (param[0],rc_flag) |
---|
515 | |
---|
516 | if (status_3d == 2): |
---|
517 | param[0] = "%s 3d%s" % (param[0],rc_flag) |
---|
518 | |
---|
519 | if (status_ma == 2): |
---|
520 | param[0] = "%s ma%s" % (param[0],rc_flag) |
---|
521 | |
---|
522 | if (status_sp == 2): |
---|
523 | param[0] = "%s sp%s" % (param[0],rc_flag) |
---|
524 | |
---|
525 | if (status_prt == 2): |
---|
526 | param[0] = "%s prt%s" % (param[0],rc_flag) |
---|
527 | |
---|
528 | if (status_pts == 2): |
---|
529 | param[0] = "%s pts%s" % (param[0],rc_flag) |
---|
530 | |
---|
531 | status_restarts = self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() |
---|
532 | |
---|
533 | if (status_restarts == 2): |
---|
534 | param[0]="%s restart" % (param[0]) |
---|
535 | |
---|
536 | # Check if _p3dr file is available, otherwise notice user |
---|
537 | if (status_restarts == 2): |
---|
538 | jobname = str(self.group_job.findChild(QtGui.QLineEdit, "line_jobname").text())[len(version_path)+len("/JOBS/"):] |
---|
539 | restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname) |
---|
540 | |
---|
541 | if (os.path.exists(restartfile) == True): |
---|
542 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
543 | |
---|
544 | else: |
---|
545 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>") |
---|
546 | |
---|
547 | else: |
---|
548 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
549 | |
---|
550 | status_cycfill = self.group_execution.findChild(QtGui.QCheckBox,"check_cycfill").checkState() |
---|
551 | |
---|
552 | if (status_cycfill == 2): |
---|
553 | param[0]="%s cycfill" % (param[0]) |
---|
554 | |
---|
555 | param[0]="%s\"" % (param[0]) |
---|
556 | |
---|
557 | if ( fwt_str == "remove"): |
---|
558 | self.delete_commandline(id_str) |
---|
559 | return 1 |
---|
560 | |
---|
561 | else: |
---|
562 | self.button_start.setEnabled(True) |
---|
563 | self.action_save.setEnabled(True) |
---|
564 | |
---|
565 | # Change in any other parameter |
---|
566 | else: |
---|
567 | if ( fwt_str != ""): |
---|
568 | param[0] = "\"%s\"" % (fwt_str) |
---|
569 | |
---|
570 | else: |
---|
571 | self.delete_commandline(id_str) |
---|
572 | return 1 |
---|
573 | |
---|
574 | # Join the new palmrunline |
---|
575 | splitline[1]= " -".join(param) |
---|
576 | |
---|
577 | |
---|
578 | s = " -%s " % (id_str) |
---|
579 | newpalmrunline = s.join(splitline) |
---|
580 | |
---|
581 | # Pr the new palmrunline to mainwindow |
---|
582 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
583 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(newpalmrunline) |
---|
584 | |
---|
585 | # change lineinput depending on sender |
---|
586 | ################################################################################### |
---|
587 | def change_lineinput(self): |
---|
588 | if ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit, "line_host") ): |
---|
589 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_host").text() |
---|
590 | self.change_commandline("h",tmptext) |
---|
591 | |
---|
592 | elif ( self.sender() == self.group_job.findChild(QtGui.QLineEdit, "line_jobname") ): |
---|
593 | tmptext = self.group_job.findChild(QtGui.QLineEdit,"line_jobname").text() |
---|
594 | self.change_commandline("d",tmptext) |
---|
595 | |
---|
596 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_q")): |
---|
597 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_q").text() |
---|
598 | self.change_commandline("q",tmptext) |
---|
599 | |
---|
600 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_account")): |
---|
601 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_account").text() |
---|
602 | self.change_commandline("A",tmptext) |
---|
603 | |
---|
604 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_pe")): |
---|
605 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_pe").text() |
---|
606 | self.change_commandline("X",tmptext) |
---|
607 | |
---|
608 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_tpn")): |
---|
609 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_tpn").text() |
---|
610 | self.change_commandline("T",tmptext) |
---|
611 | |
---|
612 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_time")): |
---|
613 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_time").text() |
---|
614 | self.change_commandline("t",tmptext) |
---|
615 | |
---|
616 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_M")): |
---|
617 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_M").text() |
---|
618 | self.change_commandline("M",tmptext) |
---|
619 | |
---|
620 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_m")): |
---|
621 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_m").text() |
---|
622 | self.change_commandline("m",tmptext) |
---|
623 | |
---|
624 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_D")): |
---|
625 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_D").text() |
---|
626 | self.change_commandline("D",tmptext) |
---|
627 | |
---|
628 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_c")): |
---|
629 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_c").text() |
---|
630 | if ( tmptext == ".palmgui.config"): |
---|
631 | tmptext = "" |
---|
632 | self.change_commandline("c",tmptext) |
---|
633 | |
---|
634 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_s")): |
---|
635 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_s").text() |
---|
636 | self.change_commandline("s",tmptext) |
---|
637 | |
---|
638 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_w")): |
---|
639 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_w").text() |
---|
640 | self.change_commandline("w",tmptext) |
---|
641 | |
---|
642 | elif ( self.sender() == self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos") or |
---|
643 | self.sender() == self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean")): |
---|
644 | t1 = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").text() |
---|
645 | t2 = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").text() |
---|
646 | tmptext = "%s %s" % (t1,t2) |
---|
647 | |
---|
648 | self.change_commandline("Y",tmptext) |
---|
649 | |
---|
650 | # try catch sowas in der art |
---|
651 | pe1 = 0 |
---|
652 | pe2 = 0 |
---|
653 | |
---|
654 | try: |
---|
655 | pe1 = int(t1) |
---|
656 | except ValueError: |
---|
657 | pass |
---|
658 | |
---|
659 | try: |
---|
660 | pe2 = int(t2) |
---|
661 | except ValueError: |
---|
662 | pass |
---|
663 | |
---|
664 | PE_total = pe1+pe2 |
---|
665 | self.group_execution.findChild(QtGui.QLineEdit,"line_pe").setText(str(PE_total)) |
---|
666 | self.change_commandline("X",str(PE_total)) |
---|
667 | |
---|
668 | # deletes parameter from commandline |
---|
669 | ##################################################################################### |
---|
670 | def delete_commandline(self, id_str): |
---|
671 | # Read palmrunline |
---|
672 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
673 | palmrunline = str(commandline.text()) |
---|
674 | s = " -%s" % (id_str) |
---|
675 | splitline = filter(None,palmrunline.split(s)) |
---|
676 | |
---|
677 | if ( len(splitline) == 1): |
---|
678 | return 1 |
---|
679 | else: |
---|
680 | param = splitline[1].split("-") |
---|
681 | param[0] = "" |
---|
682 | splitline[1]= " -".join(param) |
---|
683 | newpalmrunline = "".join(splitline) |
---|
684 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
685 | |
---|
686 | # Print new palmrunline to screen |
---|
687 | commandline.setText(newpalmrunline) |
---|
688 | |
---|
689 | # controls flags |
---|
690 | ################################################################################### |
---|
691 | def check_flags(self): |
---|
692 | status = self.group_execution.findChild(QtGui.QCheckBox,"check_delete_tmp_files" ).checkState() |
---|
693 | if (status == 2): |
---|
694 | self.activate_flag("B") |
---|
695 | else: |
---|
696 | self.deactivate_flag("B") |
---|
697 | |
---|
698 | status = self.group_execution.findChild(QtGui.QCheckBox,"check_verbose" ).checkState() |
---|
699 | if (status == 2): |
---|
700 | self.activate_flag("v") |
---|
701 | else: |
---|
702 | self.deactivate_flag("v") |
---|
703 | |
---|
704 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_b" ).checkState() |
---|
705 | if (status == 2): |
---|
706 | self.activate_flag("b") |
---|
707 | else: |
---|
708 | self.deactivate_flag("b") |
---|
709 | |
---|
710 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_F" ).checkState() |
---|
711 | if (status == 2): |
---|
712 | self.activate_flag("F") |
---|
713 | else: |
---|
714 | self.deactivate_flag("F") |
---|
715 | |
---|
716 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_I" ).checkState() |
---|
717 | if (status == 2): |
---|
718 | self.activate_flag("I") |
---|
719 | else: |
---|
720 | self.deactivate_flag("I") |
---|
721 | |
---|
722 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_k" ).checkState() |
---|
723 | if (status == 2): |
---|
724 | self.activate_flag("k") |
---|
725 | else: |
---|
726 | self.deactivate_flag("k") |
---|
727 | |
---|
728 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_O" ).checkState() |
---|
729 | if (status == 2): |
---|
730 | self.activate_flag("O") |
---|
731 | else: |
---|
732 | self.deactivate_flag("O") |
---|
733 | |
---|
734 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_x" ).checkState() |
---|
735 | if (status == 2): |
---|
736 | self.activate_flag("x") |
---|
737 | else: |
---|
738 | self.deactivate_flag("x") |
---|
739 | |
---|
740 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_Z" ).checkState() |
---|
741 | if (status == 2): |
---|
742 | self.activate_flag("Z") |
---|
743 | else: |
---|
744 | self.deactivate_flag("Z") |
---|
745 | |
---|
746 | # changes flag to parameter |
---|
747 | ################################################################################## |
---|
748 | def activate_flag(self, id_str): |
---|
749 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
750 | palmrunline = str(commandline.text()) |
---|
751 | s = " -%s" % (id_str) |
---|
752 | splitline = filter(None,palmrunline.split(s)) |
---|
753 | |
---|
754 | if ( len(splitline) == 1): |
---|
755 | splitline.append("") |
---|
756 | s = " -%s" % (id_str) |
---|
757 | newpalmrunline = s.join(splitline) |
---|
758 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
759 | commandline.setText(newpalmrunline) |
---|
760 | |
---|
761 | # deletes flag in commandline |
---|
762 | #################################################################################### |
---|
763 | def deactivate_flag(self, id_str): |
---|
764 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
765 | palmrunline = str(commandline.text()) |
---|
766 | s = " -%s" % (id_str) |
---|
767 | splitline = filter(None,palmrunline.split(s)) |
---|
768 | |
---|
769 | newpalmrunline = "".join(splitline) |
---|
770 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
771 | commandline.setText(newpalmrunline) |
---|
772 | |
---|
773 | # Clears window |
---|
774 | ################################################################################# |
---|
775 | def reset_window(self): |
---|
776 | self.setupUi(self) |
---|
777 | self.tabWidget.setCurrentIndex(0) |
---|
778 | self.recent_jobs(50) |
---|
779 | |
---|
780 | # Safes current commandline and user Parameters to .sav file |
---|
781 | ################################################################################# |
---|
782 | def save_to_file(self): |
---|
783 | user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text() |
---|
784 | cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text() |
---|
785 | |
---|
786 | string_to_file = cmd_string |
---|
787 | if (user_string != ""): |
---|
788 | string_to_file = "%s%s" % (string_to_file,user_string) |
---|
789 | |
---|
790 | #filename = QtGui.QInputDialog.getText(self, "Save File naming Dialog", "Insert filename", QtGui.QLineEdit.Normal) |
---|
791 | filename = str(QtGui.QFileDialog.getSaveFileName(self, "Save File","filename.sav")) |
---|
792 | extension = ".sav" |
---|
793 | filename = "%s%s" % (filename, "") |
---|
794 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
795 | |
---|
796 | file = open(filename,"w") |
---|
797 | s = "%s %s" % (tmstamp, string_to_file) |
---|
798 | file.write(s) |
---|
799 | file.close() |
---|
800 | |
---|
801 | # Safes current commandline and user parameters to default file |
---|
802 | ################################################################################ |
---|
803 | def save_default(self): |
---|
804 | user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text() |
---|
805 | cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text() |
---|
806 | |
---|
807 | string_to_file = cmd_string |
---|
808 | if (user_string != ""): |
---|
809 | string_to_file = "%s%s" % (string_to_file,user_string) |
---|
810 | |
---|
811 | filename ="%s/.palmgui.default" % (version_path) |
---|
812 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
813 | |
---|
814 | file = open(filename,"w") |
---|
815 | s = "%s %s" % (tmstamp, string_to_file) |
---|
816 | file.write(s) |
---|
817 | file.close() |
---|
818 | |
---|
819 | # Execute command which starts jobmanager (start palm_jm) |
---|
820 | ####################################################### |
---|
821 | def start_jobmanager(self): |
---|
822 | subprocess.Popen(["nohup","palm_jm",">>","/dev/null", "2>&1","&"]) |
---|
823 | |
---|
824 | # Executes command which starts watchdog (start palm_wd) |
---|
825 | ######################################################## |
---|
826 | def start_watchdog(self): |
---|
827 | subprocess.Popen(["nohup","palm_wd",">>","/dev/null", "2>&1","&"]) |
---|
828 | |
---|
829 | # Opens "help" dialog |
---|
830 | ################################# |
---|
831 | def help(self): |
---|
832 | dialog = HelpDialog() |
---|
833 | dialog.exec_() |
---|
834 | |
---|
835 | # Opens "about" dialog |
---|
836 | ################################## |
---|
837 | def about_gui(self): |
---|
838 | dialog = AboutDialog() |
---|
839 | dialog.exec_() |
---|
840 | |
---|
841 | # commandline to buttons etc |
---|
842 | ############################## |
---|
843 | def setup_gui(self, palmrun_str): |
---|
844 | # Some initial settings |
---|
845 | user = "" |
---|
846 | coupled_run = False |
---|
847 | ocean_run = False |
---|
848 | nojob = False |
---|
849 | |
---|
850 | #Split parameters in palmrunline |
---|
851 | splitline = palmrun_str.split(" -") |
---|
852 | |
---|
853 | if ( splitline[0] != "palmrun"): |
---|
854 | return 1 |
---|
855 | |
---|
856 | else: |
---|
857 | self.group_job.setEnabled(True) |
---|
858 | |
---|
859 | # Loop for all parameters in palmrunline |
---|
860 | i = len(splitline)-1 |
---|
861 | while i >= 1: |
---|
862 | |
---|
863 | # Determine parameter |
---|
864 | splitparameter = splitline[i].split(" ") |
---|
865 | |
---|
866 | parameter = splitparameter[0] |
---|
867 | splitparameter.pop(0) |
---|
868 | options = " ".join(splitparameter) |
---|
869 | options = options.replace("\"","") |
---|
870 | |
---|
871 | # Check for suitable switch |
---|
872 | if ( parameter == "d"): |
---|
873 | |
---|
874 | if ( options != ""): |
---|
875 | self.group_job.findChild(QtGui.QLineEdit,"line_jobname").setText(options) |
---|
876 | nojob = False |
---|
877 | |
---|
878 | else: |
---|
879 | nojob = True |
---|
880 | |
---|
881 | elif ( parameter == "h"): |
---|
882 | self.group_execution.findChild(QtGui.QLineEdit,"line_host").setText(options) |
---|
883 | |
---|
884 | elif ( parameter == "q"): |
---|
885 | self.group_execution.findChild(QtGui.QLineEdit,"line_q").setText(options) |
---|
886 | |
---|
887 | elif ( parameter == "A"): |
---|
888 | self.group_execution.findChild(QtGui.QLineEdit,"line_account").setText(options) |
---|
889 | |
---|
890 | elif ( parameter == "X"): |
---|
891 | self.group_execution.findChild(QtGui.QLineEdit,"line_pe").setText(options) |
---|
892 | |
---|
893 | elif ( parameter == "T"): |
---|
894 | self.group_execution.findChild(QtGui.QLineEdit,"line_tpn").setText(options) |
---|
895 | |
---|
896 | elif ( parameter == "t"): |
---|
897 | self.group_execution.findChild(QtGui.QLineEdit,"line_time").setText(options) |
---|
898 | |
---|
899 | elif ( parameter == "B"): |
---|
900 | self.group_execution.findChild(QtGui.QCheckBox,"check_delete_tmp_files").setChecked(True) |
---|
901 | |
---|
902 | elif ( parameter == "v"): |
---|
903 | self.group_execution.findChild(QtGui.QCheckBox,"check_verbose").setChecked(True) |
---|
904 | |
---|
905 | elif ( parameter == "b"): |
---|
906 | self.group_advanced.findChild(QtGui.QCheckBox,"check_b").setChecked(True) |
---|
907 | |
---|
908 | elif ( parameter == "F"): |
---|
909 | self.group_advanced.findChild(QtGui.QCheckBox,"check_F").setChecked(True) |
---|
910 | |
---|
911 | elif ( parameter == "I"): |
---|
912 | self.group_advanced.findChild(QtGui.QCheckBox,"check_I").setChecked(True) |
---|
913 | |
---|
914 | elif ( parameter == "k"): |
---|
915 | self.group_advanced.findChild(QtGui.QCheckBox,"check_k").setChecked(True) |
---|
916 | |
---|
917 | elif ( parameter == "O"): |
---|
918 | self.group_advanced.findChild(QtGui.QCheckBox,"check_O").setChecked(True) |
---|
919 | |
---|
920 | elif ( parameter == "x"): |
---|
921 | self.group_advanced.findChild(QtGui.QCheckBox,"check_x").setChecked(True) |
---|
922 | |
---|
923 | elif ( parameter == "Z"): |
---|
924 | self.group_advanced.findChild(QtGui.QCheckBox,"check_Z").setChecked(True) |
---|
925 | |
---|
926 | elif ( parameter == "m"): |
---|
927 | self.group_advanced.findChild(QtGui.QLineEdit,"line_m").setText(options) |
---|
928 | |
---|
929 | elif ( parameter == "M"): |
---|
930 | self.group_advanced.findChild(QtGui.QLineEdit,"line_M").setText(options) |
---|
931 | |
---|
932 | elif ( parameter == "D"): |
---|
933 | self.group_advanced.findChild(QtGui.QLineEdit,"line_D").setText(options) |
---|
934 | |
---|
935 | elif ( parameter == "c"): |
---|
936 | self.group_advanced.findChild(QtGui.QLineEdit,"line_c").setText(options) |
---|
937 | |
---|
938 | elif ( parameter == "s"): |
---|
939 | self.group_advanced.findChild(QtGui.QLineEdit,"line_s").setText(options) |
---|
940 | |
---|
941 | elif ( parameter == "w"): |
---|
942 | self.group_advanced.findChild(QtGui.QLineEdit,"line_w").setText(options) |
---|
943 | |
---|
944 | |
---|
945 | # Determine settings for coupled restart runs |
---|
946 | elif ( parameter == "Y"): |
---|
947 | optionssplit = options.split(" ") |
---|
948 | |
---|
949 | group_coupled = self.group_execution.findChild(QtGui.QGroupBox,"group_coupled") |
---|
950 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setEnabled(True) |
---|
951 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setEnabled(True) |
---|
952 | group_coupled.findChild(QtGui.QLabel,"label_coupled1").setEnabled(True) |
---|
953 | group_coupled.findChild(QtGui.QLabel,"label_coupled2").setEnabled(True) |
---|
954 | group_coupled.findChild(QtGui.QLabel,"label_coupled3").setEnabled(True) |
---|
955 | group_coupled.findChild(QtGui.QLabel,"label_coupling").setEnabled(True) |
---|
956 | |
---|
957 | if (optionssplit.count() == 2): |
---|
958 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setEnabled(optionssplit[0]) |
---|
959 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setEnabled(optionssplit[1]) |
---|
960 | |
---|
961 | else: |
---|
962 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setText("") |
---|
963 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setText("") |
---|
964 | |
---|
965 | |
---|
966 | coupled_run = True |
---|
967 | |
---|
968 | elif ( parameter == "y"): |
---|
969 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(3) |
---|
970 | |
---|
971 | |
---|
972 | # Determine settings for the run control list |
---|
973 | elif ( parameter == "a"): |
---|
974 | |
---|
975 | optionssplit = options.split(" ") |
---|
976 | |
---|
977 | options_2 = None |
---|
978 | options_all = None |
---|
979 | |
---|
980 | j = 0 |
---|
981 | while j < len(optionssplit): |
---|
982 | |
---|
983 | options_all = optionssplit[j] |
---|
984 | options_2 = optionssplit[j][:2] |
---|
985 | |
---|
986 | if (options_2 == "ts"): |
---|
987 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_ts").setChecked(True) |
---|
988 | |
---|
989 | if (options_2 == "pr" and options_all[:3] is not "prt"): |
---|
990 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_pr").setChecked(True) |
---|
991 | |
---|
992 | if (options_2 == "xy"): |
---|
993 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_xy").setChecked(True) |
---|
994 | |
---|
995 | if (options_2 == "xz"): |
---|
996 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_xz").setChecked(True) |
---|
997 | |
---|
998 | if (options_2 == "yz"): |
---|
999 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_yz").setChecked(True) |
---|
1000 | |
---|
1001 | if (options_2 == "3d"): |
---|
1002 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_3d").setChecked(True) |
---|
1003 | |
---|
1004 | if (options_2 == "ma"): |
---|
1005 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_ma").setChecked(True) |
---|
1006 | |
---|
1007 | if (options_2 == "sp"): |
---|
1008 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_sp").setChecked(True) |
---|
1009 | |
---|
1010 | if (options_all[:3] == "prt"): |
---|
1011 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_prt").setChecked(True) |
---|
1012 | |
---|
1013 | if (options_all[:3] == "pts"): |
---|
1014 | self.group_runcontrol.findChild(QtGui.QCheckBox,"check_pts").setChecked(True) |
---|
1015 | |
---|
1016 | if (options_2 == "d3"): |
---|
1017 | if (options_all[:3][-1] == "#"): |
---|
1018 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(0) |
---|
1019 | elif (options_all[:3][-1] == "r"): |
---|
1020 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(1) |
---|
1021 | |
---|
1022 | elif (options_all[:3][-1] == "o"): |
---|
1023 | ocean_run = True |
---|
1024 | |
---|
1025 | if (options_all == "restart"): |
---|
1026 | self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").setChecked(True) |
---|
1027 | # Check if _pdf file is available, otherwise notice user |
---|
1028 | jobname = str(self.group_job.findChild(QtGui.QLineEdit,"line_jobname").text())[len(version_path)+len("/JOBS/"):] |
---|
1029 | |
---|
1030 | restartfile = "%sJOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname) |
---|
1031 | if (os.path.exists(restartfile) == True): |
---|
1032 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
1033 | |
---|
1034 | else: |
---|
1035 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file \found!</font>") |
---|
1036 | j = j+1 |
---|
1037 | |
---|
1038 | # All unknown parameters are set as extra user parameters |
---|
1039 | else: |
---|
1040 | print parameter |
---|
1041 | user = "%s-%s \"%s\" " % (user,parameter,options) |
---|
1042 | splitline.removeAt(i) |
---|
1043 | |
---|
1044 | i = i-1 |
---|
1045 | # Change drop box state in case of ocean precursor or coupled restart runs |
---|
1046 | if ( ocean_run == True ): |
---|
1047 | if ( coupled_run == True ): |
---|
1048 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(4) |
---|
1049 | |
---|
1050 | else: |
---|
1051 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(3) |
---|
1052 | |
---|
1053 | if ( user != ""): |
---|
1054 | self.group_advanced.findChild(QtGui.QLineEdit,"line_user").setText(user) |
---|
1055 | |
---|
1056 | # Join palmrunline and post it to mainwindow |
---|
1057 | palmrunline = " -".join(splitline) |
---|
1058 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
1059 | |
---|
1060 | # Disable mainwindow if no job was found, otherwise enable |
---|
1061 | if ( nojob == True ): |
---|
1062 | self.group_execution.setEnabled(False) |
---|
1063 | self.group_runcontrol.setEnabled(False) |
---|
1064 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
1065 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(False) |
---|
1066 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setEnabled(False) |
---|
1067 | self.group_advanced.setEnabled(False) |
---|
1068 | self.check_advanced.setEnabled(False) |
---|
1069 | |
---|
1070 | else: |
---|
1071 | self.group_execution.setEnabled(True) |
---|
1072 | self.group_runcontrol.setEnabled(True) |
---|
1073 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
1074 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(True) |
---|
1075 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setEnabled(True) |
---|
1076 | self.group_advanced.setEnabled(True) |
---|
1077 | |
---|
1078 | self.tabWidget.setCurrentIndex(0) |
---|
1079 | |
---|
1080 | # open saved commandline |
---|
1081 | ################################## |
---|
1082 | def open_from_file(self): |
---|
1083 | |
---|
1084 | # Select filename and open it |
---|
1085 | filename = QtGui.QFileDialog.getOpenFileName(self, "Open File","Save files (*.sav)") |
---|
1086 | |
---|
1087 | if ( filename != ""): |
---|
1088 | file = open(filename, "r") |
---|
1089 | |
---|
1090 | if ( file is not None ): |
---|
1091 | # File opened successfully |
---|
1092 | palmrunline = file.read() |
---|
1093 | file.close() |
---|
1094 | |
---|
1095 | # In case a palmrunline was found, load it to mainwindow |
---|
1096 | if ( palmrunline != ""): |
---|
1097 | palmrunline = palmrunline[17:] |
---|
1098 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
1099 | self.setup_gui(palmrunline) |
---|
1100 | |
---|
1101 | # open saved commandline |
---|
1102 | ################################## |
---|
1103 | def open_last(self): |
---|
1104 | # Select filename and open it |
---|
1105 | filename = "%s/.palm.history" % (version_path) |
---|
1106 | |
---|
1107 | if os.path.exists(filename): |
---|
1108 | pass |
---|
1109 | else: |
---|
1110 | return |
---|
1111 | |
---|
1112 | file = open(filename, "r") |
---|
1113 | if ( file is not None ): |
---|
1114 | # File opened successfully |
---|
1115 | lines = file.readlines() |
---|
1116 | palmrunline = lines[len(lines)-1] |
---|
1117 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
1118 | file.close() |
---|
1119 | |
---|
1120 | # In case a palmrunline was found, load it to mainwindow |
---|
1121 | if ( palmrunline != ""): |
---|
1122 | palmrunline = palmrunline[17:len(palmrunline)] |
---|
1123 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
1124 | self.setup_gui(palmrunline) |
---|
1125 | |
---|
1126 | |
---|
1127 | if __name__ == "__main__": |
---|
1128 | app = QtGui.QApplication(sys.argv) |
---|
1129 | window = Mainwindow() |
---|
1130 | window.show() |
---|
1131 | sys.exit(app.exec_()) |
---|