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