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